# HG changeset patch # User Marcin Kuzminski # Date 1353097624 -3600 # Node ID bf96fd1920c10857eb1a4417730c569b8a529732 # Parent f0e19116f154e5ee32670a9e02e6168d693a37fd Enabled compare engine for tags Implemented compare engine for git repositories diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/controllers/compare.py Fri Nov 16 21:27:04 2012 +0100 @@ -102,9 +102,14 @@ log.error('Could not found repo %s or %s' % (org_repo, other_repo)) raise HTTPNotFound - if c.org_repo.scm_instance.alias != 'hg': - log.error('Review not available for GIT REPOS') + if c.org_repo != c.other_repo and h.is_git(c.rhodecode_repo): + log.error('compare of two remote repos not available for GIT REPOS') raise HTTPNotFound + + if c.org_repo.scm_instance.alias != c.other_repo.scm_instance.alias: + log.error('compare of two different kind of remote repos not available') + raise HTTPNotFound + partial = request.environ.get('HTTP_X_PARTIAL_XHR') self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial) self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial) diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/controllers/forks.py --- a/rhodecode/controllers/forks.py Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/controllers/forks.py Fri Nov 16 21:27:04 2012 +0100 @@ -99,8 +99,8 @@ c.repo_last_rev) * 100) defaults = RepoModel()._get_defaults(repo_name) - # add prefix to fork - defaults['repo_name'] = 'fork-' + defaults['repo_name'] + # add suffix to fork + defaults['repo_name'] = '%s-fork' % defaults['repo_name'] return defaults @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/lib/diffs.py --- a/rhodecode/lib/diffs.py Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/lib/diffs.py Fri Nov 16 21:27:04 2012 +0100 @@ -720,13 +720,21 @@ bundlerepo = None ignore_whitespace = ignore_whitespace context = context - org_repo = org_repo.scm_instance._repo + org_repo_scm = org_repo.scm_instance + org_repo = org_repo_scm._repo other_repo = other_repo.scm_instance._repo opts = diffopts(git=True, ignorews=ignore_whitespace, context=context) org_ref = org_ref[1] other_ref = other_ref[1] - if org_repo != other_repo and bundle_compare: + if org_repo == other_repo: + log.debug('running diff between %s@%s and %s@%s' + % (org_repo, org_ref, other_repo, other_ref)) + _diff = org_repo_scm.get_diff(rev1=other_ref, rev2=org_ref, + ignore_whitespace=ignore_whitespace, context=context) + return _diff + + elif bundle_compare: common, incoming, rheads = discovery_data other_repo_peer = localrepo.locallegacypeer(other_repo.local()) @@ -760,8 +768,4 @@ node1=org_repo[org_ref].node(), node2=other_repo[other_ref].node(), opts=opts)) - else: - log.debug('running diff between %s@%s and %s@%s' - % (org_repo, org_ref, other_repo, other_ref)) - return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref, - opts=opts)) + diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/model/pull_request.py Fri Nov 16 21:27:04 2012 +0100 @@ -26,6 +26,7 @@ import logging import binascii import datetime +import re from pylons.i18n.translation import _ @@ -144,7 +145,7 @@ pull_request.updated_on = datetime.datetime.now() self.sa.add(pull_request) - def _get_changesets(self, org_repo, org_ref, other_repo, other_ref, + def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref, discovery_data): """ Returns a list of changesets that are incoming from org_repo@org_ref @@ -173,23 +174,33 @@ for cs in reversed(map(binascii.hexlify, revs)): changesets.append(org_repo.get_changeset(cs)) else: - _revset_predicates = { - 'branch': 'branch', - 'book': 'bookmark', - 'tag': 'tag', - 'rev': 'id', - } + #no remote compare do it on the same repository + if alias == 'hg': + _revset_predicates = { + 'branch': 'branch', + 'book': 'bookmark', + 'tag': 'tag', + 'rev': 'id', + } - revs = [ - "ancestors(%s('%s')) and not ancestors(%s('%s'))" % ( - _revset_predicates[org_ref[0]], org_ref[1], - _revset_predicates[other_ref[0]], other_ref[1] - ) - ] + revs = [ + "ancestors(%s('%s')) and not ancestors(%s('%s'))" % ( + _revset_predicates[org_ref[0]], org_ref[1], + _revset_predicates[other_ref[0]], other_ref[1] + ) + ] - out = scmutil.revrange(org_repo._repo, revs) - for cs in reversed(out): - changesets.append(org_repo.get_changeset(cs)) + out = scmutil.revrange(org_repo._repo, revs) + for cs in reversed(out): + changesets.append(org_repo.get_changeset(cs)) + elif alias == 'git': + so, se = org_repo.run_git_command( + 'log --pretty="format: %%H" -s -p %s..%s' % (org_ref[1], + other_ref[1]) + ) + ids = re.findall(r'[0-9a-fA-F]{40}', so) + for cs in reversed(ids): + changesets.append(org_repo.get_changeset(cs)) return changesets @@ -231,7 +242,8 @@ def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): """ - Returns a tuple of incomming changesets, and discoverydata cache + Returns a tuple of incomming changesets, and discoverydata cache for + mercurial repositories :param org_repo: :type org_repo: @@ -249,14 +261,17 @@ if len(other_ref) != 2 or not isinstance(org_ref, (list, tuple)): raise Exception('other_ref must be a two element list/tuple') - discovery_data = self._get_discovery(org_repo.scm_instance, - org_ref, - other_repo.scm_instance, - other_ref) - cs_ranges = self._get_changesets(org_repo.scm_instance, - org_ref, - other_repo.scm_instance, - other_ref, + org_repo_scm = org_repo.scm_instance + other_repo_scm = other_repo.scm_instance + + alias = org_repo.scm_instance.alias + discovery_data = [None, None, None] + if alias == 'hg': + discovery_data = self._get_discovery(org_repo_scm, org_ref, + other_repo_scm, other_ref) + cs_ranges = self._get_changesets(alias, + org_repo_scm, org_ref, + other_repo_scm, other_ref, discovery_data) return cs_ranges, discovery_data diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/templates/branches/branches.html --- a/rhodecode/templates/branches/branches.html Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/templates/branches/branches.html Fri Nov 16 21:27:04 2012 +0100 @@ -44,8 +44,7 @@ .replace('__OTHER__',other.value); window.location=u; } - -}) +}); // main table sorting var myColumnDefs = [ {key:"name",label:"${_('Name')}",sortable:true}, diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/templates/branches/branches_data.html --- a/rhodecode/templates/branches/branches_data.html Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/templates/branches/branches_data.html Fri Nov 16 21:27:04 2012 +0100 @@ -3,11 +3,11 @@ - - - - - + + + + + %for cnt,branch in enumerate(c.repo_branches.items()): diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/templates/changelog/changelog.html Fri Nov 16 21:27:04 2012 +0100 @@ -37,7 +37,7 @@ %if c.rhodecode_db_repo.fork: - ${_('Compare fork')} + ${_('Compare fork with parent')} %endif %if h.is_hg(c.rhodecode_repo): ${_('Open new pull request')} diff -r f0e19116f154 -r bf96fd1920c1 rhodecode/templates/tags/tags.html --- a/rhodecode/templates/tags/tags.html Fri Nov 16 21:09:50 2012 +0100 +++ b/rhodecode/templates/tags/tags.html Fri Nov 16 21:27:04 2012 +0100 @@ -25,11 +25,26 @@ ${self.breadcrumbs()} + %if c.repo_tags: +
${_('Compare tags')}
+ %endif
<%include file='tags_data.html'/>
${_('name')}${_('date')}${_('author')}${_('revision')}${_('compare')}${_('Name')}${_('Date')}${_('Author')}${_('Revision')}${_('Compare')}