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