##// END OF EJS Templates
changelog pagination with branch filtering now uses...
marcink -
r3747:600ffde2 beta
parent child Browse files
Show More
@@ -69,19 +69,14 b' class ChangelogController(BaseRepoContro'
69 69 p = safe_int(request.params.get('page', 1), 1)
70 70 branch_name = request.params.get('branch', None)
71 71 try:
72 if branch_name:
73 collection = [z for z in
74 c.rhodecode_repo.get_changesets(start=0,
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)
72 collection = c.rhodecode_repo.get_changesets(start=0,
73 branch_name=branch_name)
74 c.total_cs = len(collection)
80 75
81 76 c.pagination = RepoPage(collection, page=p, item_count=c.total_cs,
82 77 items_per_page=c.size, branch=branch_name)
83 78 collection = list(c.pagination)
84 page_revisions = [x.raw_id for x in collection]
79 page_revisions = [x.raw_id for x in c.pagination]
85 80 c.comments = c.rhodecode_db_repo.get_comments(page_revisions)
86 81 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
87 82 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
@@ -89,12 +84,13 b' class ChangelogController(BaseRepoContro'
89 84 h.flash(str(e), category='error')
90 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 87 c.branch_name = branch_name
95 88 c.branch_filters = [('', _('All Branches'))] + \
96 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 94 return render('changelog/changelog.html')
99 95
100 96 def changelog_details(self, cs):
@@ -102,20 +98,22 b' class ChangelogController(BaseRepoContro'
102 98 c.cs = c.rhodecode_repo.get_changeset(cs)
103 99 return render('changelog/changelog_details.html')
104 100
105 def _graph(self, repo, collection, repo_size, size, p):
101 def _graph(self, repo, revs_int, repo_size, size, p):
106 102 """
107 Generates a DAG graph for mercurial
103 Generates a DAG graph for repo
108 104
109 :param repo: repo instance
110 :param size: number of commits to show
111 :param p: page number
105 :param repo:
106 :param revs_int:
107 :param repo_size:
108 :param size:
109 :param p:
112 110 """
113 if not collection:
111 if not revs_int:
114 112 c.jsdata = json.dumps([])
115 113 return
116 114
117 115 data = []
118 revs = [x.revision for x in collection]
116 revs = revs_int
119 117
120 118 dag = _dagwalker(repo, revs, repo.alias)
121 119 dag = _colored(dag)
@@ -1002,3 +1002,27 b' class EmptyChangeset(BaseChangeset):'
1002 1002
1003 1003 def get_file_size(self, path):
1004 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 22 from string import Template
23 23
24 24 import rhodecode
25 from rhodecode.lib.vcs.backends.base import BaseRepository
25 from rhodecode.lib.vcs.backends.base import BaseRepository, CollectionGenerator
26 26 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
27 27 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
28 28 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
@@ -533,8 +533,7 b' class GitRepository(BaseRepository):'
533 533 revs = revs[start_pos:end_pos]
534 534 if reverse:
535 535 revs = reversed(revs)
536 for rev in revs:
537 yield self.get_changeset(rev)
536 return CollectionGenerator(self, revs)
538 537
539 538 def get_diff(self, rev1, rev2, path=None, ignore_whitespace=False,
540 539 context=3):
@@ -4,7 +4,7 b' import datetime'
4 4 import urllib
5 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 8 from .workdir import MercurialWorkdir
9 9 from .changeset import MercurialChangeset
10 10 from .inmemory import MercurialInMemoryChangeset
@@ -474,24 +474,22 b' class MercurialRepository(BaseRepository'
474 474 if end_pos is not None:
475 475 end_pos += 1
476 476 #filter branches
477
477 filter_ = []
478 478 if branch_name:
479 revisions = scmutil.revrange(self._repo,
480 ['branch("%s")' % (branch_name)])
479 filter_.append('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 487 else:
482 488 revisions = self.revisions
483
484 slice_ = reversed(revisions[start_pos:end_pos]) if reverse else \
489 revs = reversed(revisions[start_pos:end_pos]) if reverse else \
485 490 revisions[start_pos:end_pos]
486 491
487 for id_ in slice_:
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
492 return CollectionGenerator(self, revs)
495 493
496 494 def pull(self, url):
497 495 """
General Comments 0
You need to be logged in to leave comments. Login now