Show More
@@ -69,19 +69,14 b' class ChangelogController(BaseRepoContro' | |||||
69 | p = safe_int(request.params.get('page', 1), 1) |
|
69 | p = safe_int(request.params.get('page', 1), 1) | |
70 | branch_name = request.params.get('branch', None) |
|
70 | branch_name = request.params.get('branch', None) | |
71 | try: |
|
71 | try: | |
72 | if branch_name: |
|
72 | collection = c.rhodecode_repo.get_changesets(start=0, | |
73 | collection = [z for z in |
|
73 | branch_name=branch_name) | |
74 | c.rhodecode_repo.get_changesets(start=0, |
|
74 | c.total_cs = len(collection) | |
75 | branch_name=branch_name)] |
|
|||
76 | c.total_cs = len(collection) |
|
|||
77 | else: |
|
|||
78 | collection = c.rhodecode_repo |
|
|||
79 | c.total_cs = len(c.rhodecode_repo) |
|
|||
80 |
|
75 | |||
81 | c.pagination = RepoPage(collection, page=p, item_count=c.total_cs, |
|
76 | c.pagination = RepoPage(collection, page=p, item_count=c.total_cs, | |
82 | items_per_page=c.size, branch=branch_name) |
|
77 | items_per_page=c.size, branch=branch_name) | |
83 | collection = list(c.pagination) |
|
78 | collection = list(c.pagination) | |
84 |
page_revisions = [x.raw_id for x in c |
|
79 | page_revisions = [x.raw_id for x in c.pagination] | |
85 | c.comments = c.rhodecode_db_repo.get_comments(page_revisions) |
|
80 | c.comments = c.rhodecode_db_repo.get_comments(page_revisions) | |
86 | c.statuses = c.rhodecode_db_repo.statuses(page_revisions) |
|
81 | c.statuses = c.rhodecode_db_repo.statuses(page_revisions) | |
87 | except (RepositoryError, ChangesetDoesNotExistError, Exception), e: |
|
82 | except (RepositoryError, ChangesetDoesNotExistError, Exception), e: | |
@@ -89,12 +84,13 b' class ChangelogController(BaseRepoContro' | |||||
89 | h.flash(str(e), category='error') |
|
84 | h.flash(str(e), category='error') | |
90 | return redirect(url('changelog_home', repo_name=c.repo_name)) |
|
85 | return redirect(url('changelog_home', repo_name=c.repo_name)) | |
91 |
|
86 | |||
92 | self._graph(c.rhodecode_repo, collection, c.total_cs, c.size, p) |
|
|||
93 |
|
||||
94 | c.branch_name = branch_name |
|
87 | c.branch_name = branch_name | |
95 | c.branch_filters = [('', _('All Branches'))] + \ |
|
88 | c.branch_filters = [('', _('All Branches'))] + \ | |
96 | [(k, k) for k in c.rhodecode_repo.branches.keys()] |
|
89 | [(k, k) for k in c.rhodecode_repo.branches.keys()] | |
97 |
|
90 | |||
|
91 | self._graph(c.rhodecode_repo, [x.revision for x in c.pagination], | |||
|
92 | c.total_cs, c.size, p) | |||
|
93 | ||||
98 | return render('changelog/changelog.html') |
|
94 | return render('changelog/changelog.html') | |
99 |
|
95 | |||
100 | def changelog_details(self, cs): |
|
96 | def changelog_details(self, cs): | |
@@ -102,20 +98,22 b' class ChangelogController(BaseRepoContro' | |||||
102 | c.cs = c.rhodecode_repo.get_changeset(cs) |
|
98 | c.cs = c.rhodecode_repo.get_changeset(cs) | |
103 | return render('changelog/changelog_details.html') |
|
99 | return render('changelog/changelog_details.html') | |
104 |
|
100 | |||
105 |
def _graph(self, repo, |
|
101 | def _graph(self, repo, revs_int, repo_size, size, p): | |
106 | """ |
|
102 | """ | |
107 |
Generates a DAG graph for |
|
103 | Generates a DAG graph for repo | |
108 |
|
104 | |||
109 |
:param repo: |
|
105 | :param repo: | |
110 | :param size: number of commits to show |
|
106 | :param revs_int: | |
111 |
:param |
|
107 | :param repo_size: | |
|
108 | :param size: | |||
|
109 | :param p: | |||
112 | """ |
|
110 | """ | |
113 |
if not |
|
111 | if not revs_int: | |
114 | c.jsdata = json.dumps([]) |
|
112 | c.jsdata = json.dumps([]) | |
115 | return |
|
113 | return | |
116 |
|
114 | |||
117 | data = [] |
|
115 | data = [] | |
118 |
revs = |
|
116 | revs = revs_int | |
119 |
|
117 | |||
120 | dag = _dagwalker(repo, revs, repo.alias) |
|
118 | dag = _dagwalker(repo, revs, repo.alias) | |
121 | dag = _colored(dag) |
|
119 | dag = _colored(dag) |
@@ -1002,3 +1002,27 b' class EmptyChangeset(BaseChangeset):' | |||||
1002 |
|
1002 | |||
1003 | def get_file_size(self, path): |
|
1003 | def get_file_size(self, path): | |
1004 | return 0 |
|
1004 | return 0 | |
|
1005 | ||||
|
1006 | ||||
|
1007 | class CollectionGenerator(object): | |||
|
1008 | ||||
|
1009 | def __init__(self, repo, revs): | |||
|
1010 | self.repo = repo | |||
|
1011 | self.revs = revs | |||
|
1012 | ||||
|
1013 | def __len__(self): | |||
|
1014 | return len(self.revs) | |||
|
1015 | ||||
|
1016 | def __iter__(self): | |||
|
1017 | for rev in self.revs: | |||
|
1018 | yield self.repo.get_changeset(rev) | |||
|
1019 | ||||
|
1020 | def __getslice__(self, i, j): | |||
|
1021 | """ | |||
|
1022 | Returns a iterator of sliced repository | |||
|
1023 | """ | |||
|
1024 | sliced_revs = self.revs[i:j] | |||
|
1025 | return CollectionGenerator(self.repo, sliced_revs) | |||
|
1026 | ||||
|
1027 | def __repr__(self): | |||
|
1028 | return 'CollectionGenerator<%s>' % (len(self)) |
@@ -22,7 +22,7 b' from dulwich.objects import Tag' | |||||
22 | from string import Template |
|
22 | from string import Template | |
23 |
|
23 | |||
24 | import rhodecode |
|
24 | import rhodecode | |
25 | from rhodecode.lib.vcs.backends.base import BaseRepository |
|
25 | from rhodecode.lib.vcs.backends.base import BaseRepository, CollectionGenerator | |
26 | from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError |
|
26 | from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError | |
27 | from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError |
|
27 | from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError | |
28 | from rhodecode.lib.vcs.exceptions import EmptyRepositoryError |
|
28 | from rhodecode.lib.vcs.exceptions import EmptyRepositoryError | |
@@ -533,8 +533,7 b' class GitRepository(BaseRepository):' | |||||
533 | revs = revs[start_pos:end_pos] |
|
533 | revs = revs[start_pos:end_pos] | |
534 | if reverse: |
|
534 | if reverse: | |
535 | revs = reversed(revs) |
|
535 | revs = reversed(revs) | |
536 | for rev in revs: |
|
536 | return CollectionGenerator(self, revs) | |
537 | yield self.get_changeset(rev) |
|
|||
538 |
|
537 | |||
539 | def get_diff(self, rev1, rev2, path=None, ignore_whitespace=False, |
|
538 | def get_diff(self, rev1, rev2, path=None, ignore_whitespace=False, | |
540 | context=3): |
|
539 | context=3): |
@@ -4,7 +4,7 b' import datetime' | |||||
4 | import urllib |
|
4 | import urllib | |
5 | import urllib2 |
|
5 | import urllib2 | |
6 |
|
6 | |||
7 | from rhodecode.lib.vcs.backends.base import BaseRepository |
|
7 | from rhodecode.lib.vcs.backends.base import BaseRepository, CollectionGenerator | |
8 | from .workdir import MercurialWorkdir |
|
8 | from .workdir import MercurialWorkdir | |
9 | from .changeset import MercurialChangeset |
|
9 | from .changeset import MercurialChangeset | |
10 | from .inmemory import MercurialInMemoryChangeset |
|
10 | from .inmemory import MercurialInMemoryChangeset | |
@@ -474,24 +474,22 b' class MercurialRepository(BaseRepository' | |||||
474 | if end_pos is not None: |
|
474 | if end_pos is not None: | |
475 | end_pos += 1 |
|
475 | end_pos += 1 | |
476 | #filter branches |
|
476 | #filter branches | |
477 |
|
477 | filter_ = [] | ||
478 | if branch_name: |
|
478 | if branch_name: | |
479 | revisions = scmutil.revrange(self._repo, |
|
479 | filter_.append('branch("%s")' % (branch_name)) | |
480 | ['branch("%s")' % (branch_name)]) |
|
480 | ||
|
481 | if start_date: | |||
|
482 | filter_.append('date(">%s")' % start_date) | |||
|
483 | if end_date: | |||
|
484 | filter_.append('date("<%s")' % end_date) | |||
|
485 | if filter_: | |||
|
486 | revisions = scmutil.revrange(self._repo, filter_) | |||
481 | else: |
|
487 | else: | |
482 | revisions = self.revisions |
|
488 | revisions = self.revisions | |
483 |
|
489 | revs = reversed(revisions[start_pos:end_pos]) if reverse else \ | ||
484 | slice_ = reversed(revisions[start_pos:end_pos]) if reverse else \ |
|
|||
485 | revisions[start_pos:end_pos] |
|
490 | revisions[start_pos:end_pos] | |
486 |
|
491 | |||
487 | for id_ in slice_: |
|
492 | return CollectionGenerator(self, revs) | |
488 | cs = self.get_changeset(id_) |
|
|||
489 | if start_date and cs.date < start_date: |
|
|||
490 | continue |
|
|||
491 | if end_date and cs.date > end_date: |
|
|||
492 | continue |
|
|||
493 |
|
||||
494 | yield cs |
|
|||
495 |
|
493 | |||
496 | def pull(self, url): |
|
494 | def pull(self, url): | |
497 | """ |
|
495 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now