commits: hide evolve commits. Fixes #5392
This commit is contained in:
parent
bab4242396
commit
862e0c122b
9 changed files with 73 additions and 18 deletions
|
|
@ -34,7 +34,7 @@ from rhodecode.lib.auth import (
|
|||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib.graphmod import _colored, _dagwalker
|
||||
from rhodecode.lib.helpers import RepoPage
|
||||
from rhodecode.lib.utils2 import safe_int, safe_str
|
||||
from rhodecode.lib.utils2 import safe_int, safe_str, str2bool
|
||||
from rhodecode.lib.vcs.exceptions import (
|
||||
RepositoryError, CommitDoesNotExistError,
|
||||
CommitError, NodeDoesNotExistError, EmptyRepositoryError)
|
||||
|
|
@ -181,6 +181,7 @@ class RepoChangelogView(RepoAppView):
|
|||
|
||||
commit_id = self.request.matchdict.get('commit_id')
|
||||
f_path = self._get_f_path(self.request.matchdict)
|
||||
show_hidden = str2bool(self.request.GET.get('evolve'))
|
||||
|
||||
chunk_size = 20
|
||||
|
||||
|
|
@ -188,6 +189,8 @@ class RepoChangelogView(RepoAppView):
|
|||
c.book_name = book_name = self.request.GET.get('bookmark') or ''
|
||||
c.f_path = f_path
|
||||
c.commit_id = commit_id
|
||||
c.show_hidden = show_hidden
|
||||
|
||||
hist_limit = safe_int(self.request.GET.get('limit')) or None
|
||||
|
||||
p = safe_int(self.request.GET.get('page', 1), 1)
|
||||
|
|
@ -227,7 +230,8 @@ class RepoChangelogView(RepoAppView):
|
|||
collection = list(reversed(collection))
|
||||
else:
|
||||
collection = self.rhodecode_vcs_repo.get_commits(
|
||||
branch_name=branch_name, pre_load=pre_load)
|
||||
branch_name=branch_name, show_hidden=show_hidden,
|
||||
pre_load=pre_load)
|
||||
|
||||
self._load_changelog_data(
|
||||
c, collection, p, chunk_size, c.branch_name,
|
||||
|
|
@ -279,6 +283,8 @@ class RepoChangelogView(RepoAppView):
|
|||
c = self.load_default_context()
|
||||
commit_id = self.request.matchdict.get('commit_id')
|
||||
f_path = self._get_f_path(self.request.matchdict)
|
||||
show_hidden = str2bool(self.request.GET.get('evolve'))
|
||||
|
||||
chunk_size = 20
|
||||
hist_limit = safe_int(self.request.GET.get('limit')) or None
|
||||
|
||||
|
|
@ -292,6 +298,7 @@ class RepoChangelogView(RepoAppView):
|
|||
c.book_name = book_name = self.request.GET.get('bookmark') or ''
|
||||
c.f_path = f_path
|
||||
c.commit_id = commit_id
|
||||
c.show_hidden = show_hidden
|
||||
|
||||
c.selected_name = branch_name or book_name
|
||||
if branch_name and branch_name not in self.rhodecode_vcs_repo.branches_all:
|
||||
|
|
@ -307,7 +314,7 @@ class RepoChangelogView(RepoAppView):
|
|||
collection = list(reversed(collection))
|
||||
else:
|
||||
collection = self.rhodecode_vcs_repo.get_commits(
|
||||
branch_name=branch_name, pre_load=pre_load)
|
||||
branch_name=branch_name, show_hidden=show_hidden, pre_load=pre_load)
|
||||
|
||||
p = safe_int(self.request.GET.get('page', 1), 1)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ class BaseRepository(object):
|
|||
|
||||
def get_commits(
|
||||
self, start_id=None, end_id=None, start_date=None, end_date=None,
|
||||
branch_name=None, pre_load=None):
|
||||
branch_name=None, show_hidden=False, pre_load=None):
|
||||
"""
|
||||
Returns iterator of `BaseCommit` objects from start to end
|
||||
not inclusive. This should behave just like a list, ie. end is not
|
||||
|
|
@ -309,6 +309,7 @@ class BaseRepository(object):
|
|||
:param start_date:
|
||||
:param end_date:
|
||||
:param branch_name:
|
||||
:param show_hidden:
|
||||
:param pre_load:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ class GitRepository(BaseRepository):
|
|||
|
||||
def get_commits(
|
||||
self, start_id=None, end_id=None, start_date=None, end_date=None,
|
||||
branch_name=None, pre_load=None):
|
||||
branch_name=None, show_hidden=False, pre_load=None):
|
||||
"""
|
||||
Returns generator of `GitCommit` objects from start to end (both
|
||||
are inclusive), in ascending date order.
|
||||
|
|
@ -433,7 +433,8 @@ class GitRepository(BaseRepository):
|
|||
``end_date`` would be filtered out from returned set
|
||||
:param branch_name: if specified, commits not reachable from given
|
||||
branch would be filtered out from returned set
|
||||
|
||||
:param show_hidden: Show hidden commits such as obsolete or hidden from
|
||||
Mercurial evolve
|
||||
:raise BranchDoesNotExistError: If given `branch_name` does not
|
||||
exist.
|
||||
:raise CommitDoesNotExistError: If commits for given `start` or
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ class MercurialRepository(BaseRepository):
|
|||
|
||||
def get_commits(
|
||||
self, start_id=None, end_id=None, start_date=None, end_date=None,
|
||||
branch_name=None, pre_load=None):
|
||||
branch_name=None, show_hidden=False, pre_load=None):
|
||||
"""
|
||||
Returns generator of ``MercurialCommit`` objects from start to end
|
||||
(both are inclusive)
|
||||
|
|
@ -475,7 +475,8 @@ class MercurialRepository(BaseRepository):
|
|||
``end_date`` would be filtered out from returned set
|
||||
:param branch_name: if specified, commits not reachable from given
|
||||
branch would be filtered out from returned set
|
||||
|
||||
:param show_hidden: Show hidden commits such as obsolete or hidden from
|
||||
Mercurial evolve
|
||||
:raise BranchDoesNotExistError: If given ``branch_name`` does not
|
||||
exist.
|
||||
:raise CommitDoesNotExistError: If commit for given ``start`` or
|
||||
|
|
@ -510,23 +511,29 @@ class MercurialRepository(BaseRepository):
|
|||
end_pos += 1
|
||||
|
||||
commit_filter = []
|
||||
|
||||
if branch_name and not branch_ancestors:
|
||||
commit_filter.append('branch("%s")' % branch_name)
|
||||
commit_filter.append('branch("%s")' % (branch_name,))
|
||||
elif branch_name and branch_ancestors:
|
||||
commit_filter.append('ancestors(branch("%s"))' % branch_name)
|
||||
commit_filter.append('ancestors(branch("%s"))' % (branch_name,))
|
||||
|
||||
if start_date and not end_date:
|
||||
commit_filter.append('date(">%s")' % start_date)
|
||||
commit_filter.append('date(">%s")' % (start_date,))
|
||||
if end_date and not start_date:
|
||||
commit_filter.append('date("<%s")' % end_date)
|
||||
commit_filter.append('date("<%s")' % (end_date,))
|
||||
if start_date and end_date:
|
||||
commit_filter.append(
|
||||
'date(">%s") and date("<%s")' % (start_date, end_date))
|
||||
|
||||
if not show_hidden:
|
||||
commit_filter.append('not obsolete()')
|
||||
commit_filter.append('not hidden()')
|
||||
|
||||
# TODO: johbo: Figure out a simpler way for this solution
|
||||
collection_generator = CollectionGenerator
|
||||
if commit_filter:
|
||||
commit_filter = map(safe_str, commit_filter)
|
||||
revisions = self._remote.rev_range(commit_filter)
|
||||
commit_filter = ' and '.join(map(safe_str, commit_filter))
|
||||
revisions = self._remote.rev_range([commit_filter])
|
||||
collection_generator = MercurialIndexBasedCollectionGenerator
|
||||
else:
|
||||
revisions = self.commit_ids
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ class SubversionRepository(base.BaseRepository):
|
|||
|
||||
def get_commits(
|
||||
self, start_id=None, end_id=None, start_date=None, end_date=None,
|
||||
branch_name=None, pre_load=None):
|
||||
branch_name=None, show_hidden=False, pre_load=None):
|
||||
if self.is_empty():
|
||||
raise EmptyRepositoryError("There are no commit_ids yet")
|
||||
self._validate_branch_name(branch_name)
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ input + .action-link, .action-link.first{
|
|||
color: @grey4;
|
||||
}
|
||||
|
||||
.action-link.disabled {
|
||||
color: @grey4;
|
||||
cursor: inherit;
|
||||
}
|
||||
|
||||
.clipboard-action {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,17 @@
|
|||
%endif
|
||||
</div>
|
||||
${self.breadcrumbs('breadcrumbs_light')}
|
||||
<div class="pull-right">
|
||||
% if h.is_hg(c.rhodecode_repo):
|
||||
% if c.show_hidden:
|
||||
<a class="action-link" href="${h.current_route_path(request, evolve=0)}">${_('Hide obsolete/hidden')}</a>
|
||||
% else:
|
||||
<a class="action-link" href="${h.current_route_path(request, evolve=1)}">${_('Show obsolete/hidden')}</a>
|
||||
% endif
|
||||
% else:
|
||||
<span class="action-link disabled">${_('Show hidden')}</span>
|
||||
% endif
|
||||
</div>
|
||||
<div id="commit-counter" data-total=${c.total_cs} class="pull-right">
|
||||
${_ungettext('showing %d out of %d commit', 'showing %d out of %d commits', c.showing_commits) % (c.showing_commits, c.total_cs)}
|
||||
</div>
|
||||
|
|
@ -103,6 +114,8 @@
|
|||
<th colspan="2"></th>
|
||||
|
||||
<th>${_('Commit')}</th>
|
||||
## Mercurial phase/evolve state
|
||||
<th></th>
|
||||
## commit message expand arrow
|
||||
<th></th>
|
||||
<th>${_('Commit Message')}</th>
|
||||
|
|
@ -270,10 +283,14 @@
|
|||
});
|
||||
$('#branch_filter').on('change', function(e){
|
||||
var data = $('#branch_filter').select2('data');
|
||||
//type: branch_closed
|
||||
var selected = data.text;
|
||||
var filter = {'repo_name': '${c.repo_name}'};
|
||||
if(data.type == 'branch' || data.type == 'branch_closed'){
|
||||
filter["branch"] = selected;
|
||||
if (data.type == 'branch_closed') {
|
||||
filter["evolve"] = '1';
|
||||
}
|
||||
}
|
||||
else if (data.type == 'book'){
|
||||
filter["bookmark"] = selected;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@
|
|||
<span class="${'commit_hash obsolete' if getattr(commit, 'obsolete', None) else 'commit_hash'}">${h.show_id(commit)}</span>
|
||||
</a>
|
||||
<i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${commit.raw_id}" title="${_('Copy the full commit id')}"></i>
|
||||
</code>
|
||||
</td>
|
||||
<td class="td-tags tags-col">
|
||||
## phase
|
||||
% if hasattr(commit, 'phase'):
|
||||
% if commit.phase != 'public':
|
||||
<span class="tag phase-${commit.phase} tooltip" title="${_('Commit phase')}">${commit.phase}</span>
|
||||
|
|
@ -69,8 +73,6 @@
|
|||
<span class="tag obsolete-${commit.hidden} tooltip" title="${_('Evolve State')}">${_('hidden')}</span>
|
||||
% endif
|
||||
% endif
|
||||
|
||||
</code>
|
||||
</td>
|
||||
<td class="td-message expand_commit" data-commit-id="${commit.raw_id}" title="${_('Expand commit message')}" onclick="commitsController.expandCommit(this); return false">
|
||||
<div class="show_more_col">
|
||||
|
|
@ -130,7 +132,7 @@
|
|||
|
||||
% if c.next_page:
|
||||
<tr>
|
||||
<td colspan="9" class="load-more-commits">
|
||||
<td colspan="10" class="load-more-commits">
|
||||
<a class="next-commits" href="#loadNextCommits" onclick="commitsController.loadNext(this, ${c.next_page}, '${c.branch_name}', '${c.commit_id}', '${c.f_path}');return false">
|
||||
${_('load next')}
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -390,6 +390,11 @@ class TestCommits(BackendTestMixin):
|
|||
with pytest.raises(EmptyRepositoryError):
|
||||
list(repo.get_commits(start_id='foobar'))
|
||||
|
||||
def test_get_commits_respects_hidden(self):
|
||||
commits = self.repo.get_commits(show_hidden=True)
|
||||
assert isinstance(commits, CollectionGenerator)
|
||||
assert len(commits) == 5
|
||||
|
||||
def test_get_commits_includes_end_commit(self):
|
||||
second_id = self.repo.commit_ids[1]
|
||||
commits = self.repo.get_commits(end_id=second_id)
|
||||
|
|
@ -407,6 +412,16 @@ class TestCommits(BackendTestMixin):
|
|||
for c in commits:
|
||||
assert c.date >= start_date
|
||||
|
||||
def test_get_commits_respects_start_date_with_branch(self):
|
||||
start_date = datetime.datetime(2010, 1, 2)
|
||||
commits = self.repo.get_commits(
|
||||
start_date=start_date, branch_name=self.repo.DEFAULT_BRANCH_NAME)
|
||||
assert isinstance(commits, CollectionGenerator)
|
||||
# Should be 4 commits after 2010-01-02 00:00:00
|
||||
assert len(commits) == 4
|
||||
for c in commits:
|
||||
assert c.date >= start_date
|
||||
|
||||
def test_get_commits_respects_start_date_and_end_date(self):
|
||||
start_date = datetime.datetime(2010, 1, 2)
|
||||
end_date = datetime.datetime(2010, 1, 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue