Show More
@@ -6,7 +6,7 b' from rhodecode.config.routing import mak' | |||||
6 | from rhodecode.lib.auth import set_available_permissions, set_base_path |
|
6 | from rhodecode.lib.auth import set_available_permissions, set_base_path | |
7 | from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config |
|
7 | from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config | |
8 | from rhodecode.model import init_model |
|
8 | from rhodecode.model import init_model | |
9 |
from rhodecode.model. |
|
9 | from rhodecode.model.scm import ScmModel | |
10 | from sqlalchemy import engine_from_config |
|
10 | from sqlalchemy import engine_from_config | |
11 | import logging |
|
11 | import logging | |
12 | import os |
|
12 | import os | |
@@ -71,7 +71,7 b' def load_environment(global_conf, app_co' | |||||
71 | config['pylons.app_globals'].baseui = make_ui('db') |
|
71 | config['pylons.app_globals'].baseui = make_ui('db') | |
72 |
|
72 | |||
73 | g = config['pylons.app_globals'] |
|
73 | g = config['pylons.app_globals'] | |
74 |
repo2db_mapper( |
|
74 | repo2db_mapper(ScmModel().repo_scan(g.paths[0][1], g.baseui, initial)) | |
75 | set_available_permissions(config) |
|
75 | set_available_permissions(config) | |
76 | set_base_path(config) |
|
76 | set_base_path(config) | |
77 | set_rhodecode_config(config) |
|
77 | set_rhodecode_config(config) |
@@ -35,7 +35,7 b' from rhodecode.lib.base import BaseContr' | |||||
35 | from rhodecode.lib.utils import invalidate_cache, action_logger |
|
35 | from rhodecode.lib.utils import invalidate_cache, action_logger | |
36 | from rhodecode.model.db import User |
|
36 | from rhodecode.model.db import User | |
37 | from rhodecode.model.forms import RepoForm |
|
37 | from rhodecode.model.forms import RepoForm | |
38 |
from rhodecode.model. |
|
38 | from rhodecode.model.scm import ScmModel | |
39 | from rhodecode.model.repo import RepoModel |
|
39 | from rhodecode.model.repo import RepoModel | |
40 | import formencode |
|
40 | import formencode | |
41 | import logging |
|
41 | import logging | |
@@ -60,7 +60,7 b' class ReposController(BaseController):' | |||||
60 | def index(self, format='html'): |
|
60 | def index(self, format='html'): | |
61 | """GET /repos: All items in the collection""" |
|
61 | """GET /repos: All items in the collection""" | |
62 | # url('repos') |
|
62 | # url('repos') | |
63 |
cached_repo_list = |
|
63 | cached_repo_list = ScmModel().get_repos() | |
64 | c.repos_list = sorted(cached_repo_list, key=itemgetter('name_sort')) |
|
64 | c.repos_list = sorted(cached_repo_list, key=itemgetter('name_sort')) | |
65 | return render('admin/repos/repos.html') |
|
65 | return render('admin/repos/repos.html') | |
66 |
|
66 |
@@ -36,7 +36,7 b' from rhodecode.lib.utils import repo2db_' | |||||
36 | from rhodecode.model.db import RhodeCodeSettings, RhodeCodeUi, Repository |
|
36 | from rhodecode.model.db import RhodeCodeSettings, RhodeCodeUi, Repository | |
37 | from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ |
|
37 | from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ | |
38 | ApplicationUiSettingsForm |
|
38 | ApplicationUiSettingsForm | |
39 |
from rhodecode.model. |
|
39 | from rhodecode.model.scm import ScmModel | |
40 | from rhodecode.model.user import UserModel |
|
40 | from rhodecode.model.user import UserModel | |
41 | from rhodecode.lib.celerylib import tasks, run_task |
|
41 | from rhodecode.lib.celerylib import tasks, run_task | |
42 | from sqlalchemy import func |
|
42 | from sqlalchemy import func | |
@@ -99,7 +99,7 b' class SettingsController(BaseController)' | |||||
99 | rm_obsolete = request.POST.get('destroy', False) |
|
99 | rm_obsolete = request.POST.get('destroy', False) | |
100 | log.debug('Rescanning directories with destroy=%s', rm_obsolete) |
|
100 | log.debug('Rescanning directories with destroy=%s', rm_obsolete) | |
101 |
|
101 | |||
102 |
initial = |
|
102 | initial = ScmModel().repo_scan(g.paths[0][1], g.baseui) | |
103 | for repo_name in initial.keys(): |
|
103 | for repo_name in initial.keys(): | |
104 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
104 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
105 |
|
105 | |||
@@ -253,7 +253,7 b' class SettingsController(BaseController)' | |||||
253 | .filter(Repository.user_id == c.user.user_id)\ |
|
253 | .filter(Repository.user_id == c.user.user_id)\ | |
254 | .order_by(func.lower(Repository.repo_name))\ |
|
254 | .order_by(func.lower(Repository.repo_name))\ | |
255 | .all() |
|
255 | .all() | |
256 |
c.user_repos = |
|
256 | c.user_repos = ScmModel().get_repos(all_repos) | |
257 |
|
257 | |||
258 | if c.user.username == 'default': |
|
258 | if c.user.username == 'default': | |
259 | h.flash(_("You can't edit this user since it's" |
|
259 | h.flash(_("You can't edit this user since it's" | |
@@ -294,7 +294,7 b' class SettingsController(BaseController)' | |||||
294 | .filter(Repository.user_id == c.user.user_id)\ |
|
294 | .filter(Repository.user_id == c.user.user_id)\ | |
295 | .order_by(func.lower(Repository.repo_name))\ |
|
295 | .order_by(func.lower(Repository.repo_name))\ | |
296 | .all() |
|
296 | .all() | |
297 |
c.user_repos = |
|
297 | c.user_repos = ScmModel().get_repos(all_repos) | |
298 |
|
298 | |||
299 | return htmlfill.render( |
|
299 | return htmlfill.render( | |
300 | render('admin/users/user_edit_my_account.html'), |
|
300 | render('admin/users/user_edit_my_account.html'), |
@@ -26,7 +26,7 b' from pylons import tmpl_context as c' | |||||
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
27 | from rhodecode.lib.base import BaseController, render |
|
27 | from rhodecode.lib.base import BaseController, render | |
28 | from rhodecode.lib.utils import OrderedDict |
|
28 | from rhodecode.lib.utils import OrderedDict | |
29 |
from rhodecode.model. |
|
29 | from rhodecode.model.scm import ScmModel | |
30 | import logging |
|
30 | import logging | |
31 | log = logging.getLogger(__name__) |
|
31 | log = logging.getLogger(__name__) | |
32 |
|
32 | |||
@@ -38,7 +38,7 b' class BranchesController(BaseController)' | |||||
38 | super(BranchesController, self).__before__() |
|
38 | super(BranchesController, self).__before__() | |
39 |
|
39 | |||
40 | def index(self): |
|
40 | def index(self): | |
41 |
hg_model = |
|
41 | hg_model = ScmModel() | |
42 | c.repo_info = hg_model.get_repo(c.repo_name) |
|
42 | c.repo_info = hg_model.get_repo(c.repo_name) | |
43 | c.repo_branches = OrderedDict() |
|
43 | c.repo_branches = OrderedDict() | |
44 | for name, hash_ in c.repo_info.branches.items(): |
|
44 | for name, hash_ in c.repo_info.branches.items(): |
@@ -32,7 +32,7 b' from mercurial.graphmod import colored, ' | |||||
32 | from pylons import request, session, tmpl_context as c |
|
32 | from pylons import request, session, tmpl_context as c | |
33 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
33 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
34 | from rhodecode.lib.base import BaseController, render |
|
34 | from rhodecode.lib.base import BaseController, render | |
35 |
from rhodecode.model. |
|
35 | from rhodecode.model.scm import ScmModel | |
36 | from webhelpers.paginate import Page |
|
36 | from webhelpers.paginate import Page | |
37 | import logging |
|
37 | import logging | |
38 | log = logging.getLogger(__name__) |
|
38 | log = logging.getLogger(__name__) | |
@@ -60,7 +60,7 b' class ChangelogController(BaseController' | |||||
60 | else: |
|
60 | else: | |
61 | c.size = int(session.get('changelog_size', default)) |
|
61 | c.size = int(session.get('changelog_size', default)) | |
62 |
|
62 | |||
63 |
changesets = |
|
63 | changesets = ScmModel().get_repo(c.repo_name) | |
64 |
|
64 | |||
65 | p = int(request.params.get('page', 1)) |
|
65 | p = int(request.params.get('page', 1)) | |
66 | c.total_cs = len(changesets) |
|
66 | c.total_cs = len(changesets) |
@@ -28,7 +28,7 b' from rhodecode.lib.auth import LoginRequ' | |||||
28 | from rhodecode.lib.base import BaseController, render |
|
28 | from rhodecode.lib.base import BaseController, render | |
29 | from rhodecode.lib.utils import EmptyChangeset |
|
29 | from rhodecode.lib.utils import EmptyChangeset | |
30 | import rhodecode.lib.helpers as h |
|
30 | import rhodecode.lib.helpers as h | |
31 |
from rhodecode.model. |
|
31 | from rhodecode.model.scm import ScmModel | |
32 | from vcs.exceptions import RepositoryError, ChangesetError |
|
32 | from vcs.exceptions import RepositoryError, ChangesetError | |
33 | from vcs.nodes import FileNode |
|
33 | from vcs.nodes import FileNode | |
34 | from vcs.utils import diffs as differ |
|
34 | from vcs.utils import diffs as differ | |
@@ -46,7 +46,7 b' class ChangesetController(BaseController' | |||||
46 | super(ChangesetController, self).__before__() |
|
46 | super(ChangesetController, self).__before__() | |
47 |
|
47 | |||
48 | def index(self, revision): |
|
48 | def index(self, revision): | |
49 |
hg_model = |
|
49 | hg_model = ScmModel() | |
50 | cut_off_limit = 1024 * 250 |
|
50 | cut_off_limit = 1024 * 250 | |
51 |
|
51 | |||
52 | def wrap_to_table(str): |
|
52 | def wrap_to_table(str): | |
@@ -132,7 +132,7 b' class ChangesetController(BaseController' | |||||
132 |
|
132 | |||
133 | def raw_changeset(self, revision): |
|
133 | def raw_changeset(self, revision): | |
134 |
|
134 | |||
135 |
hg_model = |
|
135 | hg_model = ScmModel() | |
136 | method = request.GET.get('diff', 'show') |
|
136 | method = request.GET.get('diff', 'show') | |
137 | try: |
|
137 | try: | |
138 | r = hg_model.get_repo(c.repo_name) |
|
138 | r = hg_model.get_repo(c.repo_name) |
@@ -24,7 +24,7 b' feed controller for pylons' | |||||
24 | """ |
|
24 | """ | |
25 | from pylons import tmpl_context as c, url, response |
|
25 | from pylons import tmpl_context as c, url, response | |
26 | from rhodecode.lib.base import BaseController, render |
|
26 | from rhodecode.lib.base import BaseController, render | |
27 |
from rhodecode.model. |
|
27 | from rhodecode.model.scm import ScmModel | |
28 | from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed |
|
28 | from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed | |
29 | import logging |
|
29 | import logging | |
30 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
@@ -49,7 +49,7 b' class FeedController(BaseController):' | |||||
49 | language=self.language, |
|
49 | language=self.language, | |
50 | ttl=self.ttl) |
|
50 | ttl=self.ttl) | |
51 |
|
51 | |||
52 |
changesets = |
|
52 | changesets = ScmModel().get_repo(repo_name) | |
53 |
|
53 | |||
54 | for cs in changesets[:self.feed_nr]: |
|
54 | for cs in changesets[:self.feed_nr]: | |
55 | feed.add_item(title=cs.message, |
|
55 | feed.add_item(title=cs.message, | |
@@ -69,7 +69,7 b' class FeedController(BaseController):' | |||||
69 | language=self.language, |
|
69 | language=self.language, | |
70 | ttl=self.ttl) |
|
70 | ttl=self.ttl) | |
71 |
|
71 | |||
72 |
changesets = |
|
72 | changesets = ScmModel().get_repo(repo_name) | |
73 | for cs in changesets[:self.feed_nr]: |
|
73 | for cs in changesets[:self.feed_nr]: | |
74 | feed.add_item(title=cs.message, |
|
74 | feed.add_item(title=cs.message, | |
75 | link=url('changeset_home', repo_name=repo_name, |
|
75 | link=url('changeset_home', repo_name=repo_name, |
@@ -29,7 +29,7 b' from pylons.controllers.util import redi' | |||||
29 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
29 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
30 | from rhodecode.lib.base import BaseController, render |
|
30 | from rhodecode.lib.base import BaseController, render | |
31 | from rhodecode.lib.utils import EmptyChangeset |
|
31 | from rhodecode.lib.utils import EmptyChangeset | |
32 |
from rhodecode.model. |
|
32 | from rhodecode.model.scm import ScmModel | |
33 | from vcs.exceptions import RepositoryError, ChangesetError |
|
33 | from vcs.exceptions import RepositoryError, ChangesetError | |
34 | from vcs.nodes import FileNode |
|
34 | from vcs.nodes import FileNode | |
35 | from vcs.utils import diffs as differ |
|
35 | from vcs.utils import diffs as differ | |
@@ -49,7 +49,7 b' class FilesController(BaseController):' | |||||
49 | c.file_size_limit = 250 * 1024 #limit of file size to display |
|
49 | c.file_size_limit = 250 * 1024 #limit of file size to display | |
50 |
|
50 | |||
51 | def index(self, repo_name, revision, f_path): |
|
51 | def index(self, repo_name, revision, f_path): | |
52 |
hg_model = |
|
52 | hg_model = ScmModel() | |
53 | c.repo = hg_model.get_repo(c.repo_name) |
|
53 | c.repo = hg_model.get_repo(c.repo_name) | |
54 | revision = request.POST.get('at_rev', None) or revision |
|
54 | revision = request.POST.get('at_rev', None) or revision | |
55 |
|
55 | |||
@@ -95,7 +95,7 b' class FilesController(BaseController):' | |||||
95 | return render('files/files.html') |
|
95 | return render('files/files.html') | |
96 |
|
96 | |||
97 | def rawfile(self, repo_name, revision, f_path): |
|
97 | def rawfile(self, repo_name, revision, f_path): | |
98 |
hg_model = |
|
98 | hg_model = ScmModel() | |
99 | c.repo = hg_model.get_repo(c.repo_name) |
|
99 | c.repo = hg_model.get_repo(c.repo_name) | |
100 | file_node = c.repo.get_changeset(revision).get_node(f_path) |
|
100 | file_node = c.repo.get_changeset(revision).get_node(f_path) | |
101 | response.content_type = file_node.mimetype |
|
101 | response.content_type = file_node.mimetype | |
@@ -104,7 +104,7 b' class FilesController(BaseController):' | |||||
104 | return file_node.content |
|
104 | return file_node.content | |
105 |
|
105 | |||
106 | def raw(self, repo_name, revision, f_path): |
|
106 | def raw(self, repo_name, revision, f_path): | |
107 |
hg_model = |
|
107 | hg_model = ScmModel() | |
108 | c.repo = hg_model.get_repo(c.repo_name) |
|
108 | c.repo = hg_model.get_repo(c.repo_name) | |
109 | file_node = c.repo.get_changeset(revision).get_node(f_path) |
|
109 | file_node = c.repo.get_changeset(revision).get_node(f_path) | |
110 | response.content_type = 'text/plain' |
|
110 | response.content_type = 'text/plain' | |
@@ -112,7 +112,7 b' class FilesController(BaseController):' | |||||
112 | return file_node.content |
|
112 | return file_node.content | |
113 |
|
113 | |||
114 | def annotate(self, repo_name, revision, f_path): |
|
114 | def annotate(self, repo_name, revision, f_path): | |
115 |
hg_model = |
|
115 | hg_model = ScmModel() | |
116 | c.repo = hg_model.get_repo(c.repo_name) |
|
116 | c.repo = hg_model.get_repo(c.repo_name) | |
117 | c.cs = c.repo.get_changeset(revision) |
|
117 | c.cs = c.repo.get_changeset(revision) | |
118 | c.file = c.cs.get_node(f_path) |
|
118 | c.file = c.cs.get_node(f_path) | |
@@ -141,7 +141,7 b' class FilesController(BaseController):' | |||||
141 | yield data |
|
141 | yield data | |
142 |
|
142 | |||
143 | archive = tempfile.TemporaryFile() |
|
143 | archive = tempfile.TemporaryFile() | |
144 |
repo = |
|
144 | repo = ScmModel().get_repo(repo_name).repo | |
145 | fname = '%s-%s%s' % (repo_name, revision, fileformat) |
|
145 | fname = '%s-%s%s' % (repo_name, revision, fileformat) | |
146 | archival.archive(repo, archive, revision, archive_specs[fileformat][1], |
|
146 | archival.archive(repo, archive, revision, archive_specs[fileformat][1], | |
147 | prefix='%s-%s' % (repo_name, revision)) |
|
147 | prefix='%s-%s' % (repo_name, revision)) | |
@@ -151,7 +151,7 b' class FilesController(BaseController):' | |||||
151 | return read_in_chunks(archive) |
|
151 | return read_in_chunks(archive) | |
152 |
|
152 | |||
153 | def diff(self, repo_name, f_path): |
|
153 | def diff(self, repo_name, f_path): | |
154 |
hg_model = |
|
154 | hg_model = ScmModel() | |
155 | diff1 = request.GET.get('diff1') |
|
155 | diff1 = request.GET.get('diff1') | |
156 | diff2 = request.GET.get('diff2') |
|
156 | diff2 = request.GET.get('diff2') | |
157 | c.action = request.GET.get('diff') |
|
157 | c.action = request.GET.get('diff') |
@@ -26,7 +26,7 b' from operator import itemgetter' | |||||
26 | from pylons import tmpl_context as c, request |
|
26 | from pylons import tmpl_context as c, request | |
27 | from rhodecode.lib.auth import LoginRequired |
|
27 | from rhodecode.lib.auth import LoginRequired | |
28 | from rhodecode.lib.base import BaseController, render |
|
28 | from rhodecode.lib.base import BaseController, render | |
29 |
from rhodecode.model. |
|
29 | from rhodecode.model.scm import ScmModel | |
30 | import logging |
|
30 | import logging | |
31 | log = logging.getLogger(__name__) |
|
31 | log = logging.getLogger(__name__) | |
32 |
|
32 | |||
@@ -47,7 +47,7 b' class HomeController(BaseController):' | |||||
47 | else: |
|
47 | else: | |
48 | c.sort_by = current_sort |
|
48 | c.sort_by = current_sort | |
49 | c.sort_slug = current_sort_slug |
|
49 | c.sort_slug = current_sort_slug | |
50 |
cached_repo_list = |
|
50 | cached_repo_list = ScmModel().get_repos() | |
51 |
|
51 | |||
52 | sort_key = current_sort_slug + '_sort' |
|
52 | sort_key = current_sort_slug + '_sort' | |
53 | if c.sort_by.startswith('-'): |
|
53 | if c.sort_by.startswith('-'): |
@@ -25,7 +25,7 b' shortlog controller for pylons' | |||||
25 | from pylons import tmpl_context as c, request |
|
25 | from pylons import tmpl_context as c, request | |
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
27 | from rhodecode.lib.base import BaseController, render |
|
27 | from rhodecode.lib.base import BaseController, render | |
28 |
from rhodecode.model. |
|
28 | from rhodecode.model.scm import ScmModel | |
29 | from webhelpers.paginate import Page |
|
29 | from webhelpers.paginate import Page | |
30 | import logging |
|
30 | import logging | |
31 | log = logging.getLogger(__name__) |
|
31 | log = logging.getLogger(__name__) | |
@@ -40,7 +40,7 b' class ShortlogController(BaseController)' | |||||
40 |
|
40 | |||
41 | def index(self): |
|
41 | def index(self): | |
42 | p = int(request.params.get('page', 1)) |
|
42 | p = int(request.params.get('page', 1)) | |
43 |
repo = |
|
43 | repo = ScmModel().get_repo(c.repo_name) | |
44 | c.repo_changesets = Page(repo, page=p, items_per_page=20) |
|
44 | c.repo_changesets = Page(repo, page=p, items_per_page=20) | |
45 | c.shortlog_data = render('shortlog/shortlog_data.html') |
|
45 | c.shortlog_data = render('shortlog/shortlog_data.html') | |
46 | if request.params.get('partial'): |
|
46 | if request.params.get('partial'): |
@@ -27,7 +27,7 b' from vcs.exceptions import ChangesetErro' | |||||
27 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
27 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
28 | from rhodecode.lib.base import BaseController, render |
|
28 | from rhodecode.lib.base import BaseController, render | |
29 | from rhodecode.lib.utils import OrderedDict, EmptyChangeset |
|
29 | from rhodecode.lib.utils import OrderedDict, EmptyChangeset | |
30 |
from rhodecode.model. |
|
30 | from rhodecode.model.scm import ScmModel | |
31 | from rhodecode.model.db import Statistics |
|
31 | from rhodecode.model.db import Statistics | |
32 | from webhelpers.paginate import Page |
|
32 | from webhelpers.paginate import Page | |
33 | from rhodecode.lib.celerylib import run_task |
|
33 | from rhodecode.lib.celerylib import run_task | |
@@ -52,7 +52,7 b' class SummaryController(BaseController):' | |||||
52 | super(SummaryController, self).__before__() |
|
52 | super(SummaryController, self).__before__() | |
53 |
|
53 | |||
54 | def index(self): |
|
54 | def index(self): | |
55 |
hg_model = |
|
55 | hg_model = ScmModel() | |
56 | c.repo_info = hg_model.get_repo(c.repo_name) |
|
56 | c.repo_info = hg_model.get_repo(c.repo_name) | |
57 | def url_generator(**kw): |
|
57 | def url_generator(**kw): | |
58 | return url('shortlog_home', repo_name=c.repo_name, **kw) |
|
58 | return url('shortlog_home', repo_name=c.repo_name, **kw) |
@@ -26,7 +26,7 b' from pylons import tmpl_context as c' | |||||
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
26 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
27 | from rhodecode.lib.base import BaseController, render |
|
27 | from rhodecode.lib.base import BaseController, render | |
28 | from rhodecode.lib.utils import OrderedDict |
|
28 | from rhodecode.lib.utils import OrderedDict | |
29 |
from rhodecode.model. |
|
29 | from rhodecode.model.scm import ScmModel | |
30 | import logging |
|
30 | import logging | |
31 | log = logging.getLogger(__name__) |
|
31 | log = logging.getLogger(__name__) | |
32 |
|
32 | |||
@@ -38,7 +38,7 b' class TagsController(BaseController):' | |||||
38 | super(TagsController, self).__before__() |
|
38 | super(TagsController, self).__before__() | |
39 |
|
39 | |||
40 | def index(self): |
|
40 | def index(self): | |
41 |
hg_model = |
|
41 | hg_model = ScmModel() | |
42 | c.repo_info = hg_model.get_repo(c.repo_name) |
|
42 | c.repo_info = hg_model.get_repo(c.repo_name) | |
43 | c.repo_tags = OrderedDict() |
|
43 | c.repo_tags = OrderedDict() | |
44 | for name, hash_ in c.repo_info.tags.items(): |
|
44 | for name, hash_ in c.repo_info.tags.items(): |
@@ -9,7 +9,7 b' from rhodecode import __version__' | |||||
9 | from rhodecode.lib import auth |
|
9 | from rhodecode.lib import auth | |
10 | from rhodecode.lib.utils import get_repo_slug |
|
10 | from rhodecode.lib.utils import get_repo_slug | |
11 | from rhodecode.model import meta |
|
11 | from rhodecode.model import meta | |
12 |
from rhodecode.model. |
|
12 | from rhodecode.model.scm import ScmModel | |
13 | from vcs import BACKENDS |
|
13 | from vcs import BACKENDS | |
14 |
|
14 | |||
15 | class BaseController(WSGIController): |
|
15 | class BaseController(WSGIController): | |
@@ -18,11 +18,11 b' class BaseController(WSGIController):' | |||||
18 | c.rhodecode_version = __version__ |
|
18 | c.rhodecode_version = __version__ | |
19 | c.rhodecode_name = config['rhodecode_title'] |
|
19 | c.rhodecode_name = config['rhodecode_title'] | |
20 | c.repo_name = get_repo_slug(request) |
|
20 | c.repo_name = get_repo_slug(request) | |
21 |
c.cached_repo_list = |
|
21 | c.cached_repo_list = ScmModel().get_repos() | |
22 | c.backends = BACKENDS.keys() |
|
22 | c.backends = BACKENDS.keys() | |
23 |
|
23 | |||
24 | if c.repo_name: |
|
24 | if c.repo_name: | |
25 |
cached_repo = |
|
25 | cached_repo = ScmModel().get(c.repo_name) | |
26 |
|
26 | |||
27 | if cached_repo: |
|
27 | if cached_repo: | |
28 | c.repository_tags = cached_repo.tags |
|
28 | c.repository_tags = cached_repo.tags |
@@ -10,7 +10,7 b' from time import mktime' | |||||
10 | import os |
|
10 | import os | |
11 | import traceback |
|
11 | import traceback | |
12 | from vcs.backends import get_repo |
|
12 | from vcs.backends import get_repo | |
13 |
from rhodecode.model. |
|
13 | from rhodecode.model.scm import ScmModel | |
14 | try: |
|
14 | try: | |
15 | import json |
|
15 | import json | |
16 | except ImportError: |
|
16 | except ImportError: | |
@@ -62,7 +62,7 b' def get_commits_stats(repo_name, ts_min_' | |||||
62 |
|
62 | |||
63 | commits_by_day_author_aggregate = {} |
|
63 | commits_by_day_author_aggregate = {} | |
64 | commits_by_day_aggregate = {} |
|
64 | commits_by_day_aggregate = {} | |
65 |
repos_path = |
|
65 | repos_path = ScmModel().repos_path | |
66 | p = os.path.join(repos_path, repo_name) |
|
66 | p = os.path.join(repos_path, repo_name) | |
67 | repo = get_repo(p) |
|
67 | repo = get_repo(p) | |
68 |
|
68 | |||
@@ -274,7 +274,7 b' def create_repo_fork(form_data, cur_user' | |||||
274 | repo_model = RepoModel(get_session()) |
|
274 | repo_model = RepoModel(get_session()) | |
275 | repo_model.create(form_data, cur_user, just_db=True, fork=True) |
|
275 | repo_model.create(form_data, cur_user, just_db=True, fork=True) | |
276 | repo_name = form_data['repo_name'] |
|
276 | repo_name = form_data['repo_name'] | |
277 |
repos_path = |
|
277 | repos_path = ScmModel().repos_path | |
278 | repo_path = os.path.join(repos_path, repo_name) |
|
278 | repo_path = os.path.join(repos_path, repo_name) | |
279 | repo_fork_path = os.path.join(repos_path, form_data['fork_name']) |
|
279 | repo_fork_path = os.path.join(repos_path, form_data['fork_name']) | |
280 | alias = form_data['repo_type'] |
|
280 | alias = form_data['repo_type'] | |
@@ -291,7 +291,7 b' def __get_codes_stats(repo_name):' | |||||
291 | 's', 'sh', 'tpl', 'txt', 'vim', 'wss', 'xhtml', 'xml', 'xsl', 'xslt', 'yaws'] |
|
291 | 's', 'sh', 'tpl', 'txt', 'vim', 'wss', 'xhtml', 'xml', 'xsl', 'xslt', 'yaws'] | |
292 |
|
292 | |||
293 |
|
293 | |||
294 |
repos_path = |
|
294 | repos_path = ScmModel().repos_path | |
295 | p = os.path.join(repos_path, repo_name) |
|
295 | p = os.path.join(repos_path, repo_name) | |
296 | repo = get_repo(p) |
|
296 | repo = get_repo(p) | |
297 | tip = repo.get_changeset() |
|
297 | tip = repo.get_changeset() |
@@ -6,7 +6,7 b' from os.path import dirname as dn, join ' | |||||
6 | sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) |
|
6 | sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) | |
7 |
|
7 | |||
8 | from rhodecode.config.environment import load_environment |
|
8 | from rhodecode.config.environment import load_environment | |
9 |
from rhodecode.model. |
|
9 | from rhodecode.model.scm import ScmModel | |
10 | from shutil import rmtree |
|
10 | from shutil import rmtree | |
11 | from webhelpers.html.builder import escape |
|
11 | from webhelpers.html.builder import escape | |
12 | from vcs.utils.lazy import LazyProperty |
|
12 | from vcs.utils.lazy import LazyProperty |
@@ -33,7 +33,7 b' project_path = dn(dn(dn(dn(os.path.realp' | |||||
33 | sys.path.append(project_path) |
|
33 | sys.path.append(project_path) | |
34 |
|
34 | |||
35 |
|
35 | |||
36 |
from rhodecode.model. |
|
36 | from rhodecode.model.scm import ScmModel | |
37 | from rhodecode.lib.helpers import safe_unicode |
|
37 | from rhodecode.lib.helpers import safe_unicode | |
38 | from whoosh.index import create_in, open_dir |
|
38 | from whoosh.index import create_in, open_dir | |
39 | from shutil import rmtree |
|
39 | from shutil import rmtree | |
@@ -78,7 +78,7 b' class WhooshIndexingDaemon(object):' | |||||
78 | if not repo_location: |
|
78 | if not repo_location: | |
79 | raise Exception('You have to provide repositories location') |
|
79 | raise Exception('You have to provide repositories location') | |
80 |
|
80 | |||
81 |
self.repo_paths = |
|
81 | self.repo_paths = ScmModel().repo_scan(self.repo_location, None, True) | |
82 | self.initial = False |
|
82 | self.initial = False | |
83 | if not os.path.isdir(self.index_location): |
|
83 | if not os.path.isdir(self.index_location): | |
84 | os.mkdir(self.index_location) |
|
84 | os.mkdir(self.index_location) |
@@ -40,7 +40,7 b' import time' | |||||
40 |
|
40 | |||
41 | log = logging.getLogger(__name__) |
|
41 | log = logging.getLogger(__name__) | |
42 |
|
42 | |||
43 |
class |
|
43 | class ScmModel(object): | |
44 | """ |
|
44 | """ | |
45 | Mercurial Model |
|
45 | Mercurial Model | |
46 | """ |
|
46 | """ |
@@ -1,6 +1,6 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 |
|
2 | |||
3 | class TestPermissionsController(TestController): |
|
3 | class TestAdminPermissionsController(TestController): | |
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | response = self.app.get(url('permissions')) |
|
6 | response = self.app.get(url('permissions')) |
@@ -1,7 +1,7 b'' | |||||
1 | from rhodecode.model.db import Repository |
|
1 | from rhodecode.model.db import Repository | |
2 | from rhodecode.tests import * |
|
2 | from rhodecode.tests import * | |
3 |
|
3 | |||
4 | class TestReposController(TestController): |
|
4 | class TestAdminReposController(TestController): | |
5 |
|
5 | |||
6 | def test_index(self): |
|
6 | def test_index(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
@@ -21,11 +21,8 b' class TestReposController(TestController' | |||||
21 | 'description':description, |
|
21 | 'description':description, | |
22 | 'private':private}) |
|
22 | 'private':private}) | |
23 |
|
23 | |||
24 | print response |
|
|||
25 |
|
24 | |||
26 | #test if we have a message for that repository |
|
25 | #test if we have a message for that repository | |
27 | print '-' * 100 |
|
|||
28 | print response.session |
|
|||
29 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' |
|
26 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |
30 |
|
27 | |||
31 | #test if the fork was created in the database |
|
28 | #test if the fork was created in the database | |
@@ -49,11 +46,8 b' class TestReposController(TestController' | |||||
49 | 'description':description, |
|
46 | 'description':description, | |
50 | 'private':private}) |
|
47 | 'private':private}) | |
51 |
|
48 | |||
52 | print response |
|
|||
53 |
|
49 | |||
54 | #test if we have a message for that repository |
|
50 | #test if we have a message for that repository | |
55 | print '-' * 100 |
|
|||
56 | print response.session |
|
|||
57 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' |
|
51 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |
58 |
|
52 | |||
59 | #test if the fork was created in the database |
|
53 | #test if the fork was created in the database | |
@@ -91,11 +85,8 b' class TestReposController(TestController' | |||||
91 | 'description':description, |
|
85 | 'description':description, | |
92 | 'private':private}) |
|
86 | 'private':private}) | |
93 |
|
87 | |||
94 | print response |
|
|||
95 |
|
88 | |||
96 | #test if we have a message for that repository |
|
89 | #test if we have a message for that repository | |
97 | print '-' * 100 |
|
|||
98 | print response.session |
|
|||
99 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' |
|
90 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |
100 |
|
91 | |||
101 | #test if the repo was created in the database |
|
92 | #test if the repo was created in the database | |
@@ -112,8 +103,6 b' class TestReposController(TestController' | |||||
112 |
|
103 | |||
113 | response = self.app.delete(url('repo', repo_name=repo_name)) |
|
104 | response = self.app.delete(url('repo', repo_name=repo_name)) | |
114 |
|
105 | |||
115 | print '-' * 100 |
|
|||
116 | print response.session |
|
|||
117 | assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo' |
|
106 | assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo' | |
118 |
|
107 | |||
119 | response.follow() |
|
108 | response.follow() |
@@ -1,7 +1,7 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 | from rhodecode.model.db import User |
|
2 | from rhodecode.model.db import User | |
3 |
|
3 | |||
4 | class TestSettingsController(TestController): |
|
4 | class TestAdminSettingsController(TestController): | |
5 |
|
5 | |||
6 | def test_index(self): |
|
6 | def test_index(self): | |
7 | response = self.app.get(url('admin_settings')) |
|
7 | response = self.app.get(url('admin_settings')) | |
@@ -48,9 +48,9 b' class TestSettingsController(TestControl' | |||||
48 | response = self.app.get(url('admin_settings_my_account')) |
|
48 | response = self.app.get(url('admin_settings_my_account')) | |
49 | print response |
|
49 | print response | |
50 | assert 'value="test_admin' in response.body |
|
50 | assert 'value="test_admin' in response.body | |
51 |
|
51 | |||
52 |
|
52 | |||
53 |
|
53 | |||
54 | def test_my_account_update(self): |
|
54 | def test_my_account_update(self): | |
55 | self.log_user() |
|
55 | self.log_user() | |
56 | new_email = 'new@mail.pl' |
|
56 | new_email = 'new@mail.pl' | |
@@ -64,16 +64,16 b' class TestSettingsController(TestControl' | |||||
64 | email=new_email,)) |
|
64 | email=new_email,)) | |
65 | response.follow() |
|
65 | response.follow() | |
66 | print response |
|
66 | print response | |
67 |
|
67 | |||
68 | print 'x' * 100 |
|
68 | print 'x' * 100 | |
69 | print response.session |
|
69 | print response.session | |
70 | assert 'Your account was updated succesfully' in response.session['flash'][0][1], 'no flash message about success of change' |
|
70 | assert 'Your account was updated succesfully' in response.session['flash'][0][1], 'no flash message about success of change' | |
71 | user = self.sa.query(User).filter(User.username == 'test_admin').one() |
|
71 | user = self.sa.query(User).filter(User.username == 'test_admin').one() | |
72 | assert user.email == new_email , 'incorrect user email after update got %s vs %s' % (user.email, new_email) |
|
72 | assert user.email == new_email , 'incorrect user email after update got %s vs %s' % (user.email, new_email) | |
73 |
|
73 | |||
74 | def test_my_account_update_own_email_ok(self): |
|
74 | def test_my_account_update_own_email_ok(self): | |
75 | self.log_user() |
|
75 | self.log_user() | |
76 |
|
76 | |||
77 | new_email = 'new@mail.pl' |
|
77 | new_email = 'new@mail.pl' | |
78 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
|
78 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( | |
79 | _method='put', |
|
79 | _method='put', | |
@@ -83,10 +83,10 b' class TestSettingsController(TestControl' | |||||
83 | lastname='NewLastname', |
|
83 | lastname='NewLastname', | |
84 | email=new_email,)) |
|
84 | email=new_email,)) | |
85 | print response |
|
85 | print response | |
86 |
|
86 | |||
87 | def test_my_account_update_err_email_exists(self): |
|
87 | def test_my_account_update_err_email_exists(self): | |
88 | self.log_user() |
|
88 | self.log_user() | |
89 |
|
89 | |||
90 | new_email = 'test_regular@mail.com'#already exisitn email |
|
90 | new_email = 'test_regular@mail.com'#already exisitn email | |
91 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
|
91 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( | |
92 | _method='put', |
|
92 | _method='put', | |
@@ -96,13 +96,13 b' class TestSettingsController(TestControl' | |||||
96 | lastname='NewLastname', |
|
96 | lastname='NewLastname', | |
97 | email=new_email,)) |
|
97 | email=new_email,)) | |
98 | print response |
|
98 | print response | |
99 |
|
99 | |||
100 | assert 'That e-mail address is already taken' in response.body, 'Missing error message about existing email' |
|
100 | assert 'That e-mail address is already taken' in response.body, 'Missing error message about existing email' | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | def test_my_account_update_err(self): |
|
103 | def test_my_account_update_err(self): | |
104 | self.log_user('test_regular2', 'test12') |
|
104 | self.log_user('test_regular2', 'test12') | |
105 |
|
105 | |||
106 | new_email = 'newmail.pl' |
|
106 | new_email = 'newmail.pl' | |
107 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
|
107 | response = self.app.post(url('admin_settings_my_account_update'), params=dict( | |
108 | _method='put', |
|
108 | _method='put', |
@@ -1,6 +1,9 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
|
2 | from rhodecode.model.db import User | |||
|
3 | from rhodecode.lib.auth import check_password | |||
|
4 | from sqlalchemy.orm.exc import NoResultFound | |||
2 |
|
5 | |||
3 | class TestUsersController(TestController): |
|
6 | class TestAdminUsersController(TestController): | |
4 |
|
7 | |||
5 | def test_index(self): |
|
8 | def test_index(self): | |
6 | response = self.app.get(url('users')) |
|
9 | response = self.app.get(url('users')) | |
@@ -11,12 +14,59 b' class TestUsersController(TestController' | |||||
11 |
|
14 | |||
12 | def test_create(self): |
|
15 | def test_create(self): | |
13 | self.log_user() |
|
16 | self.log_user() | |
14 |
|
|
17 | username = 'newtestuser' | |
15 | # response = self.app.post(url('users'),{'repo_name':user_name, |
|
18 | password = 'test12' | |
16 | # 'repo_type':'hg', |
|
19 | name = 'name' | |
17 | # 'description':description, |
|
20 | lastname = 'lastname' | |
18 | # 'private':private}) |
|
21 | email = 'mail@mail.com' | |
|
22 | ||||
|
23 | response = self.app.post(url('users'), {'username':username, | |||
|
24 | 'password':password, | |||
|
25 | 'name':name, | |||
|
26 | 'active':True, | |||
|
27 | 'lastname':lastname, | |||
|
28 | 'email':email}) | |||
|
29 | ||||
|
30 | ||||
|
31 | assert '''created user %s''' % (username) in response.session['flash'][0], 'No flash message about new user' | |||
|
32 | ||||
|
33 | new_user = self.sa.query(User).filter(User.username == username).one() | |||
|
34 | ||||
|
35 | ||||
|
36 | assert new_user.username == username, 'wrong info about username' | |||
|
37 | assert check_password(password, new_user.password) == True , 'wrong info about password' | |||
|
38 | assert new_user.name == name, 'wrong info about name' | |||
|
39 | assert new_user.lastname == lastname, 'wrong info about lastname' | |||
|
40 | assert new_user.email == email, 'wrong info about email' | |||
|
41 | ||||
19 |
|
42 | |||
|
43 | response.follow() | |||
|
44 | response = response.follow() | |||
|
45 | assert """edit">newtestuser</a>""" in response.body | |||
|
46 | ||||
|
47 | def test_create_err(self): | |||
|
48 | self.log_user() | |||
|
49 | username = 'new_user' | |||
|
50 | password = '' | |||
|
51 | name = 'name' | |||
|
52 | lastname = 'lastname' | |||
|
53 | email = 'errmail.com' | |||
|
54 | ||||
|
55 | response = self.app.post(url('users'), {'username':username, | |||
|
56 | 'password':password, | |||
|
57 | 'name':name, | |||
|
58 | 'active':False, | |||
|
59 | 'lastname':lastname, | |||
|
60 | 'email':email}) | |||
|
61 | ||||
|
62 | assert """<span class="error-message">Invalid username</span>""" in response.body | |||
|
63 | assert """<span class="error-message">Please enter a value</span>""" in response.body | |||
|
64 | assert """<span class="error-message">An email address must contain a single @</span>""" in response.body | |||
|
65 | ||||
|
66 | def get_user(): | |||
|
67 | self.sa.query(User).filter(User.username == username).one() | |||
|
68 | ||||
|
69 | self.assertRaises(NoResultFound, get_user), 'found user in database' | |||
20 |
|
70 | |||
21 | def test_new(self): |
|
71 | def test_new(self): | |
22 | response = self.app.get(url('new_user')) |
|
72 | response = self.app.get(url('new_user')) | |
@@ -31,7 +81,27 b' class TestUsersController(TestController' | |||||
31 | response = self.app.post(url('user', id=1), params=dict(_method='put')) |
|
81 | response = self.app.post(url('user', id=1), params=dict(_method='put')) | |
32 |
|
82 | |||
33 | def test_delete(self): |
|
83 | def test_delete(self): | |
34 | response = self.app.delete(url('user', id=1)) |
|
84 | self.log_user() | |
|
85 | username = 'newtestuserdeleteme' | |||
|
86 | password = 'test12' | |||
|
87 | name = 'name' | |||
|
88 | lastname = 'lastname' | |||
|
89 | email = 'todeletemail@mail.com' | |||
|
90 | ||||
|
91 | response = self.app.post(url('users'), {'username':username, | |||
|
92 | 'password':password, | |||
|
93 | 'name':name, | |||
|
94 | 'active':True, | |||
|
95 | 'lastname':lastname, | |||
|
96 | 'email':email}) | |||
|
97 | ||||
|
98 | response = response.follow() | |||
|
99 | ||||
|
100 | new_user = self.sa.query(User).filter(User.username == username).one() | |||
|
101 | response = self.app.delete(url('user', id=new_user.user_id)) | |||
|
102 | ||||
|
103 | assert """sucessfully deleted user""" in response.session['flash'][0], 'No info about user deletion' | |||
|
104 | ||||
35 |
|
105 | |||
36 | def test_delete_browser_fakeout(self): |
|
106 | def test_delete_browser_fakeout(self): | |
37 | response = self.app.post(url('user', id=1), params=dict(_method='delete')) |
|
107 | response = self.app.post(url('user', id=1), params=dict(_method='delete')) |
@@ -1,6 +1,6 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 |
|
2 | |||
3 |
class Test |
|
3 | class TestHomeController(TestController): | |
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() |
@@ -102,7 +102,6 b' class TestLoginController(TestController' | |||||
102 | 'email':email, |
|
102 | 'email':email, | |
103 | 'name':name, |
|
103 | 'name':name, | |
104 | 'lastname':lastname}) |
|
104 | 'lastname':lastname}) | |
105 | print response.body |
|
|||
106 | assert response.status == '302 Found', 'Wrong response from register page got %s' % response.status |
|
105 | assert response.status == '302 Found', 'Wrong response from register page got %s' % response.status | |
107 | assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' |
|
106 | assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' | |
108 |
|
107 |
@@ -5,7 +5,7 b' py_version = sys.version_info' | |||||
5 | requirements = [ |
|
5 | requirements = [ | |
6 | "Pylons>=1.0.0", |
|
6 | "Pylons>=1.0.0", | |
7 | "SQLAlchemy>=0.6.5", |
|
7 | "SQLAlchemy>=0.6.5", | |
8 |
"Mako>=0.3. |
|
8 | "Mako>=0.3.6", | |
9 | "vcs>=0.1.10", |
|
9 | "vcs>=0.1.10", | |
10 | "pygments>=1.3.0", |
|
10 | "pygments>=1.3.0", | |
11 | "mercurial>=1.6.4", |
|
11 | "mercurial>=1.6.4", |
General Comments 0
You need to be logged in to leave comments.
Login now