changeset 2630:f79320e47e99 beta

Merged pull request #56 - fixed issue with resolution of ref_types for mercurial - now properly handles ref type - added option to compare by specific revisions also
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 18 Jul 2012 19:09:12 +0200
parents d2901d906ef3
children f597cfb492f9
files rhodecode/config/routing.py rhodecode/model/pull_request.py
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/routing.py	Wed Jul 18 18:42:08 2012 +0200
+++ b/rhodecode/config/routing.py	Wed Jul 18 19:09:12 2012 +0200
@@ -437,8 +437,8 @@
                  '/{repo_name:.*}/compare/{org_ref_type}@{org_ref}...{other_ref_type}@{other_ref}',
                  controller='compare', action='index',
                  conditions=dict(function=check_repo),
-                 requirements=dict(org_ref_type='(branch|book|tag)',
-                                   other_ref_type='(branch|book|tag)'))
+                 requirements=dict(org_ref_type='(branch|book|tag|rev)',
+                                   other_ref_type='(branch|book|tag|rev)'))
 
     rmap.connect('pullrequest_home',
                  '/{repo_name:.*}/pull-request/new', controller='pullrequests',
--- a/rhodecode/model/pull_request.py	Wed Jul 18 18:42:08 2012 +0200
+++ b/rhodecode/model/pull_request.py	Wed Jul 18 19:09:12 2012 +0200
@@ -161,8 +161,20 @@
             for cs in reversed(map(binascii.hexlify, revs)):
                 changesets.append(org_repo.get_changeset(cs))
         else:
-            revs = ['ancestors(%s) and not ancestors(%s)' % (org_ref[1],
-                                                             other_ref[1])]
+            _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]
+               )
+            ]
+
             from mercurial import scmutil
             out = scmutil.revrange(org_repo._repo, revs)
             for cs in reversed(out):