##// END OF EJS Templates
commits: hide evolve commits. Fixes #5392
marcink -
r2144:9e9e365e default
parent child Browse files
Show More
@@ -34,7 +34,7 b' from rhodecode.lib.auth import ('
34 from rhodecode.lib.ext_json import json
34 from rhodecode.lib.ext_json import json
35 from rhodecode.lib.graphmod import _colored, _dagwalker
35 from rhodecode.lib.graphmod import _colored, _dagwalker
36 from rhodecode.lib.helpers import RepoPage
36 from rhodecode.lib.helpers import RepoPage
37 from rhodecode.lib.utils2 import safe_int, safe_str
37 from rhodecode.lib.utils2 import safe_int, safe_str, str2bool
38 from rhodecode.lib.vcs.exceptions import (
38 from rhodecode.lib.vcs.exceptions import (
39 RepositoryError, CommitDoesNotExistError,
39 RepositoryError, CommitDoesNotExistError,
40 CommitError, NodeDoesNotExistError, EmptyRepositoryError)
40 CommitError, NodeDoesNotExistError, EmptyRepositoryError)
@@ -181,6 +181,7 b' class RepoChangelogView(RepoAppView):'
181
181
182 commit_id = self.request.matchdict.get('commit_id')
182 commit_id = self.request.matchdict.get('commit_id')
183 f_path = self._get_f_path(self.request.matchdict)
183 f_path = self._get_f_path(self.request.matchdict)
184 show_hidden = str2bool(self.request.GET.get('evolve'))
184
185
185 chunk_size = 20
186 chunk_size = 20
186
187
@@ -188,6 +189,8 b' class RepoChangelogView(RepoAppView):'
188 c.book_name = book_name = self.request.GET.get('bookmark') or ''
189 c.book_name = book_name = self.request.GET.get('bookmark') or ''
189 c.f_path = f_path
190 c.f_path = f_path
190 c.commit_id = commit_id
191 c.commit_id = commit_id
192 c.show_hidden = show_hidden
193
191 hist_limit = safe_int(self.request.GET.get('limit')) or None
194 hist_limit = safe_int(self.request.GET.get('limit')) or None
192
195
193 p = safe_int(self.request.GET.get('page', 1), 1)
196 p = safe_int(self.request.GET.get('page', 1), 1)
@@ -227,7 +230,8 b' class RepoChangelogView(RepoAppView):'
227 collection = list(reversed(collection))
230 collection = list(reversed(collection))
228 else:
231 else:
229 collection = self.rhodecode_vcs_repo.get_commits(
232 collection = self.rhodecode_vcs_repo.get_commits(
230 branch_name=branch_name, pre_load=pre_load)
233 branch_name=branch_name, show_hidden=show_hidden,
234 pre_load=pre_load)
231
235
232 self._load_changelog_data(
236 self._load_changelog_data(
233 c, collection, p, chunk_size, c.branch_name,
237 c, collection, p, chunk_size, c.branch_name,
@@ -279,6 +283,8 b' class RepoChangelogView(RepoAppView):'
279 c = self.load_default_context()
283 c = self.load_default_context()
280 commit_id = self.request.matchdict.get('commit_id')
284 commit_id = self.request.matchdict.get('commit_id')
281 f_path = self._get_f_path(self.request.matchdict)
285 f_path = self._get_f_path(self.request.matchdict)
286 show_hidden = str2bool(self.request.GET.get('evolve'))
287
282 chunk_size = 20
288 chunk_size = 20
283 hist_limit = safe_int(self.request.GET.get('limit')) or None
289 hist_limit = safe_int(self.request.GET.get('limit')) or None
284
290
@@ -292,6 +298,7 b' class RepoChangelogView(RepoAppView):'
292 c.book_name = book_name = self.request.GET.get('bookmark') or ''
298 c.book_name = book_name = self.request.GET.get('bookmark') or ''
293 c.f_path = f_path
299 c.f_path = f_path
294 c.commit_id = commit_id
300 c.commit_id = commit_id
301 c.show_hidden = show_hidden
295
302
296 c.selected_name = branch_name or book_name
303 c.selected_name = branch_name or book_name
297 if branch_name and branch_name not in self.rhodecode_vcs_repo.branches_all:
304 if branch_name and branch_name not in self.rhodecode_vcs_repo.branches_all:
@@ -307,7 +314,7 b' class RepoChangelogView(RepoAppView):'
307 collection = list(reversed(collection))
314 collection = list(reversed(collection))
308 else:
315 else:
309 collection = self.rhodecode_vcs_repo.get_commits(
316 collection = self.rhodecode_vcs_repo.get_commits(
310 branch_name=branch_name, pre_load=pre_load)
317 branch_name=branch_name, show_hidden=show_hidden, pre_load=pre_load)
311
318
312 p = safe_int(self.request.GET.get('page', 1), 1)
319 p = safe_int(self.request.GET.get('page', 1), 1)
313 try:
320 try:
@@ -298,7 +298,7 b' class BaseRepository(object):'
298
298
299 def get_commits(
299 def get_commits(
300 self, start_id=None, end_id=None, start_date=None, end_date=None,
300 self, start_id=None, end_id=None, start_date=None, end_date=None,
301 branch_name=None, pre_load=None):
301 branch_name=None, show_hidden=False, pre_load=None):
302 """
302 """
303 Returns iterator of `BaseCommit` objects from start to end
303 Returns iterator of `BaseCommit` objects from start to end
304 not inclusive. This should behave just like a list, ie. end is not
304 not inclusive. This should behave just like a list, ie. end is not
@@ -309,6 +309,7 b' class BaseRepository(object):'
309 :param start_date:
309 :param start_date:
310 :param end_date:
310 :param end_date:
311 :param branch_name:
311 :param branch_name:
312 :param show_hidden:
312 :param pre_load:
313 :param pre_load:
313 """
314 """
314 raise NotImplementedError
315 raise NotImplementedError
@@ -420,7 +420,7 b' class GitRepository(BaseRepository):'
420
420
421 def get_commits(
421 def get_commits(
422 self, start_id=None, end_id=None, start_date=None, end_date=None,
422 self, start_id=None, end_id=None, start_date=None, end_date=None,
423 branch_name=None, pre_load=None):
423 branch_name=None, show_hidden=False, pre_load=None):
424 """
424 """
425 Returns generator of `GitCommit` objects from start to end (both
425 Returns generator of `GitCommit` objects from start to end (both
426 are inclusive), in ascending date order.
426 are inclusive), in ascending date order.
@@ -433,7 +433,8 b' class GitRepository(BaseRepository):'
433 ``end_date`` would be filtered out from returned set
433 ``end_date`` would be filtered out from returned set
434 :param branch_name: if specified, commits not reachable from given
434 :param branch_name: if specified, commits not reachable from given
435 branch would be filtered out from returned set
435 branch would be filtered out from returned set
436
436 :param show_hidden: Show hidden commits such as obsolete or hidden from
437 Mercurial evolve
437 :raise BranchDoesNotExistError: If given `branch_name` does not
438 :raise BranchDoesNotExistError: If given `branch_name` does not
438 exist.
439 exist.
439 :raise CommitDoesNotExistError: If commits for given `start` or
440 :raise CommitDoesNotExistError: If commits for given `start` or
@@ -462,7 +462,7 b' class MercurialRepository(BaseRepository'
462
462
463 def get_commits(
463 def get_commits(
464 self, start_id=None, end_id=None, start_date=None, end_date=None,
464 self, start_id=None, end_id=None, start_date=None, end_date=None,
465 branch_name=None, pre_load=None):
465 branch_name=None, show_hidden=False, pre_load=None):
466 """
466 """
467 Returns generator of ``MercurialCommit`` objects from start to end
467 Returns generator of ``MercurialCommit`` objects from start to end
468 (both are inclusive)
468 (both are inclusive)
@@ -475,7 +475,8 b' class MercurialRepository(BaseRepository'
475 ``end_date`` would be filtered out from returned set
475 ``end_date`` would be filtered out from returned set
476 :param branch_name: if specified, commits not reachable from given
476 :param branch_name: if specified, commits not reachable from given
477 branch would be filtered out from returned set
477 branch would be filtered out from returned set
478
478 :param show_hidden: Show hidden commits such as obsolete or hidden from
479 Mercurial evolve
479 :raise BranchDoesNotExistError: If given ``branch_name`` does not
480 :raise BranchDoesNotExistError: If given ``branch_name`` does not
480 exist.
481 exist.
481 :raise CommitDoesNotExistError: If commit for given ``start`` or
482 :raise CommitDoesNotExistError: If commit for given ``start`` or
@@ -510,23 +511,29 b' class MercurialRepository(BaseRepository'
510 end_pos += 1
511 end_pos += 1
511
512
512 commit_filter = []
513 commit_filter = []
514
513 if branch_name and not branch_ancestors:
515 if branch_name and not branch_ancestors:
514 commit_filter.append('branch("%s")' % branch_name)
516 commit_filter.append('branch("%s")' % (branch_name,))
515 elif branch_name and branch_ancestors:
517 elif branch_name and branch_ancestors:
516 commit_filter.append('ancestors(branch("%s"))' % branch_name)
518 commit_filter.append('ancestors(branch("%s"))' % (branch_name,))
519
517 if start_date and not end_date:
520 if start_date and not end_date:
518 commit_filter.append('date(">%s")' % start_date)
521 commit_filter.append('date(">%s")' % (start_date,))
519 if end_date and not start_date:
522 if end_date and not start_date:
520 commit_filter.append('date("<%s")' % end_date)
523 commit_filter.append('date("<%s")' % (end_date,))
521 if start_date and end_date:
524 if start_date and end_date:
522 commit_filter.append(
525 commit_filter.append(
523 'date(">%s") and date("<%s")' % (start_date, end_date))
526 'date(">%s") and date("<%s")' % (start_date, end_date))
524
527
528 if not show_hidden:
529 commit_filter.append('not obsolete()')
530 commit_filter.append('not hidden()')
531
525 # TODO: johbo: Figure out a simpler way for this solution
532 # TODO: johbo: Figure out a simpler way for this solution
526 collection_generator = CollectionGenerator
533 collection_generator = CollectionGenerator
527 if commit_filter:
534 if commit_filter:
528 commit_filter = map(safe_str, commit_filter)
535 commit_filter = ' and '.join(map(safe_str, commit_filter))
529 revisions = self._remote.rev_range(commit_filter)
536 revisions = self._remote.rev_range([commit_filter])
530 collection_generator = MercurialIndexBasedCollectionGenerator
537 collection_generator = MercurialIndexBasedCollectionGenerator
531 else:
538 else:
532 revisions = self.commit_ids
539 revisions = self.commit_ids
@@ -264,7 +264,7 b' class SubversionRepository(base.BaseRepo'
264
264
265 def get_commits(
265 def get_commits(
266 self, start_id=None, end_id=None, start_date=None, end_date=None,
266 self, start_id=None, end_id=None, start_date=None, end_date=None,
267 branch_name=None, pre_load=None):
267 branch_name=None, show_hidden=False, pre_load=None):
268 if self.is_empty():
268 if self.is_empty():
269 raise EmptyRepositoryError("There are no commit_ids yet")
269 raise EmptyRepositoryError("There are no commit_ids yet")
270 self._validate_branch_name(branch_name)
270 self._validate_branch_name(branch_name)
@@ -100,6 +100,11 b' input + .action-link, .action-link.first'
100 color: @grey4;
100 color: @grey4;
101 }
101 }
102
102
103 .action-link.disabled {
104 color: @grey4;
105 cursor: inherit;
106 }
107
103 .clipboard-action {
108 .clipboard-action {
104 cursor: pointer;
109 cursor: pointer;
105 }
110 }
@@ -83,6 +83,17 b''
83 %endif
83 %endif
84 </div>
84 </div>
85 ${self.breadcrumbs('breadcrumbs_light')}
85 ${self.breadcrumbs('breadcrumbs_light')}
86 <div class="pull-right">
87 % if h.is_hg(c.rhodecode_repo):
88 % if c.show_hidden:
89 <a class="action-link" href="${h.current_route_path(request, evolve=0)}">${_('Hide obsolete/hidden')}</a>
90 % else:
91 <a class="action-link" href="${h.current_route_path(request, evolve=1)}">${_('Show obsolete/hidden')}</a>
92 % endif
93 % else:
94 <span class="action-link disabled">${_('Show hidden')}</span>
95 % endif
96 </div>
86 <div id="commit-counter" data-total=${c.total_cs} class="pull-right">
97 <div id="commit-counter" data-total=${c.total_cs} class="pull-right">
87 ${_ungettext('showing %d out of %d commit', 'showing %d out of %d commits', c.showing_commits) % (c.showing_commits, c.total_cs)}
98 ${_ungettext('showing %d out of %d commit', 'showing %d out of %d commits', c.showing_commits) % (c.showing_commits, c.total_cs)}
88 </div>
99 </div>
@@ -103,6 +114,8 b''
103 <th colspan="2"></th>
114 <th colspan="2"></th>
104
115
105 <th>${_('Commit')}</th>
116 <th>${_('Commit')}</th>
117 ## Mercurial phase/evolve state
118 <th></th>
106 ## commit message expand arrow
119 ## commit message expand arrow
107 <th></th>
120 <th></th>
108 <th>${_('Commit Message')}</th>
121 <th>${_('Commit Message')}</th>
@@ -270,10 +283,14 b''
270 });
283 });
271 $('#branch_filter').on('change', function(e){
284 $('#branch_filter').on('change', function(e){
272 var data = $('#branch_filter').select2('data');
285 var data = $('#branch_filter').select2('data');
286 //type: branch_closed
273 var selected = data.text;
287 var selected = data.text;
274 var filter = {'repo_name': '${c.repo_name}'};
288 var filter = {'repo_name': '${c.repo_name}'};
275 if(data.type == 'branch' || data.type == 'branch_closed'){
289 if(data.type == 'branch' || data.type == 'branch_closed'){
276 filter["branch"] = selected;
290 filter["branch"] = selected;
291 if (data.type == 'branch_closed') {
292 filter["evolve"] = '1';
293 }
277 }
294 }
278 else if (data.type == 'book'){
295 else if (data.type == 'book'){
279 filter["bookmark"] = selected;
296 filter["bookmark"] = selected;
@@ -50,6 +50,10 b''
50 <span class="${'commit_hash obsolete' if getattr(commit, 'obsolete', None) else 'commit_hash'}">${h.show_id(commit)}</span>
50 <span class="${'commit_hash obsolete' if getattr(commit, 'obsolete', None) else 'commit_hash'}">${h.show_id(commit)}</span>
51 </a>
51 </a>
52 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${commit.raw_id}" title="${_('Copy the full commit id')}"></i>
52 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${commit.raw_id}" title="${_('Copy the full commit id')}"></i>
53 </code>
54 </td>
55 <td class="td-tags tags-col">
56 ## phase
53 % if hasattr(commit, 'phase'):
57 % if hasattr(commit, 'phase'):
54 % if commit.phase != 'public':
58 % if commit.phase != 'public':
55 <span class="tag phase-${commit.phase} tooltip" title="${_('Commit phase')}">${commit.phase}</span>
59 <span class="tag phase-${commit.phase} tooltip" title="${_('Commit phase')}">${commit.phase}</span>
@@ -69,8 +73,6 b''
69 <span class="tag obsolete-${commit.hidden} tooltip" title="${_('Evolve State')}">${_('hidden')}</span>
73 <span class="tag obsolete-${commit.hidden} tooltip" title="${_('Evolve State')}">${_('hidden')}</span>
70 % endif
74 % endif
71 % endif
75 % endif
72
73 </code>
74 </td>
76 </td>
75 <td class="td-message expand_commit" data-commit-id="${commit.raw_id}" title="${_('Expand commit message')}" onclick="commitsController.expandCommit(this); return false">
77 <td class="td-message expand_commit" data-commit-id="${commit.raw_id}" title="${_('Expand commit message')}" onclick="commitsController.expandCommit(this); return false">
76 <div class="show_more_col">
78 <div class="show_more_col">
@@ -130,7 +132,7 b''
130
132
131 % if c.next_page:
133 % if c.next_page:
132 <tr>
134 <tr>
133 <td colspan="9" class="load-more-commits">
135 <td colspan="10" class="load-more-commits">
134 <a class="next-commits" href="#loadNextCommits" onclick="commitsController.loadNext(this, ${c.next_page}, '${c.branch_name}', '${c.commit_id}', '${c.f_path}');return false">
136 <a class="next-commits" href="#loadNextCommits" onclick="commitsController.loadNext(this, ${c.next_page}, '${c.branch_name}', '${c.commit_id}', '${c.f_path}');return false">
135 ${_('load next')}
137 ${_('load next')}
136 </a>
138 </a>
@@ -390,6 +390,11 b' class TestCommits(BackendTestMixin):'
390 with pytest.raises(EmptyRepositoryError):
390 with pytest.raises(EmptyRepositoryError):
391 list(repo.get_commits(start_id='foobar'))
391 list(repo.get_commits(start_id='foobar'))
392
392
393 def test_get_commits_respects_hidden(self):
394 commits = self.repo.get_commits(show_hidden=True)
395 assert isinstance(commits, CollectionGenerator)
396 assert len(commits) == 5
397
393 def test_get_commits_includes_end_commit(self):
398 def test_get_commits_includes_end_commit(self):
394 second_id = self.repo.commit_ids[1]
399 second_id = self.repo.commit_ids[1]
395 commits = self.repo.get_commits(end_id=second_id)
400 commits = self.repo.get_commits(end_id=second_id)
@@ -407,6 +412,16 b' class TestCommits(BackendTestMixin):'
407 for c in commits:
412 for c in commits:
408 assert c.date >= start_date
413 assert c.date >= start_date
409
414
415 def test_get_commits_respects_start_date_with_branch(self):
416 start_date = datetime.datetime(2010, 1, 2)
417 commits = self.repo.get_commits(
418 start_date=start_date, branch_name=self.repo.DEFAULT_BRANCH_NAME)
419 assert isinstance(commits, CollectionGenerator)
420 # Should be 4 commits after 2010-01-02 00:00:00
421 assert len(commits) == 4
422 for c in commits:
423 assert c.date >= start_date
424
410 def test_get_commits_respects_start_date_and_end_date(self):
425 def test_get_commits_respects_start_date_and_end_date(self):
411 start_date = datetime.datetime(2010, 1, 2)
426 start_date = datetime.datetime(2010, 1, 2)
412 end_date = datetime.datetime(2010, 1, 3)
427 end_date = datetime.datetime(2010, 1, 3)
General Comments 0
You need to be logged in to leave comments. Login now