Mercurial > kallithea
changeset 2350:d787da66c292 codereview
Changed compare-view of remote repos to use incoming option instead of outgoing.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 28 May 2012 02:00:14 +0200 |
parents | 0edbffa9e2e2 |
children | 29a8096820dc |
files | rhodecode/controllers/compare.py rhodecode/templates/compare/compare_diff.html |
diffstat | 2 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/compare.py Mon May 28 00:09:39 2012 +0200 +++ b/rhodecode/controllers/compare.py Mon May 28 02:00:14 2012 +0200 @@ -91,8 +91,19 @@ #case two independent repos if org_repo != other_repo: from mercurial import discovery - out = discovery.findcommonoutgoing(org_repo._repo, other_repo._repo) - for cs in map(binascii.hexlify, out.missing): + other = org_repo._repo + repo = other_repo._repo + onlyheads = None + tmp = discovery.findcommonincoming(repo=repo, + remote=other, + heads=onlyheads, force=False) + common, incoming, rheads = tmp + if not incoming: + revs = [] + else: + revs = other.changelog.findmissing(common, rheads) + + for cs in map(binascii.hexlify, revs): changesets.append(org_repo.get_changeset(cs)) else: revs = ['ancestors(%s) and not ancestors(%s)' % (org_ref[1], @@ -106,7 +117,9 @@ def index(self, ref): org_repo, org_ref, other_repo, other_ref = self._handle_ref(ref) - + c.swap_url = h.url('compare_home', repo_name=c.repo_name, + ref='%s...%s' % (':'.join(other_ref), + ':'.join(org_ref))) c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) @@ -117,15 +130,16 @@ c.org_ref = org_ref[1] c.other_ref = other_ref[1] - - _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) + # diff needs to have swapped org with other to generate proper diff + _diff = diffs.differ(other_repo, other_ref, org_repo, org_ref) diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') _parsed = diff_processor.prepare() c.files = [] c.changes = {} - - for f in _parsed: + # sort Added first then Modified last Deleted files + sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation']) + for f in sorted(_parsed, key=sorter): fid = h.FID('', f['filename']) c.files.append([fid, f['operation'], f['filename'], f['stats']]) diff = diff_processor.as_html(enable_comments=False, diff_lines=[f])
--- a/rhodecode/templates/compare/compare_diff.html Mon May 28 00:09:39 2012 +0200 +++ b/rhodecode/templates/compare/compare_diff.html Mon May 28 02:00:14 2012 +0200 @@ -26,7 +26,7 @@ <div class="table"> <div id="body" class="diffblock"> <div class="code-header cv"> - <h3 class="code-header-title">${_('Compare View')}</h3> + <h3 class="code-header-title">${_('Compare View')} <a href="${c.swap_url}">swap</a></h3> <div> ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} </div>