changeset 3387:bd5420ea396b beta

better handling of EmptyChangeset case in cherry pick pull request
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 19 Feb 2013 23:42:37 +0100
parents 934f1fd5d549
children cb40b3f6428c
files rhodecode/controllers/compare.py rhodecode/model/pull_request.py
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/compare.py	Tue Feb 19 20:47:55 2013 +0100
+++ b/rhodecode/controllers/compare.py	Tue Feb 19 23:42:37 2013 +0100
@@ -137,7 +137,7 @@
             # get parent of
             # rev start to include it in the diff
             _cs = other_repo.scm_instance.get_changeset(rev_start)
-            rev_start = _cs.parents[0].raw_id if _cs.parents else EmptyChangeset()
+            rev_start = _cs.parents[0].raw_id if _cs.parents else EmptyChangeset().raw_id
             org_ref = ('rev', rev_start)
             other_ref = ('rev', rev_end)
             #if we cherry pick it's not remote, make the other_repo org_repo
--- a/rhodecode/model/pull_request.py	Tue Feb 19 20:47:55 2013 +0100
+++ b/rhodecode/model/pull_request.py	Tue Feb 19 23:42:37 2013 +0100
@@ -39,6 +39,7 @@
 
 from rhodecode.lib.vcs.utils.hgcompat import scmutil
 from rhodecode.lib.vcs.utils import safe_str
+from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
 log = logging.getLogger(__name__)
 
@@ -180,13 +181,21 @@
                     'tag': 'tag',
                     'rev': 'id',
                 }
+
             org_rev_spec = "%s('%s')" % (_revset_predicates[org_ref[0]],
                                          safe_str(org_ref[1]))
-            org_rev = scmutil.revsingle(org_repo._repo,
-                                         org_rev_spec)
+            if org_ref[1] == EmptyChangeset().raw_id:
+                org_rev = org_ref[1]
+            else:
+                org_rev = org_repo._repo[scmutil.revrange(org_repo._repo,
+                                                          [org_rev_spec])[-1]]
             other_rev_spec = "%s('%s')" % (_revset_predicates[other_ref[0]],
                                            safe_str(other_ref[1]))
-            other_rev = scmutil.revsingle(other_repo._repo, other_rev_spec)
+            if other_ref[1] == EmptyChangeset().raw_id:
+                other_rev = other_ref[1]
+            else:
+                other_rev = other_repo._repo[scmutil.revrange(other_repo._repo,
+                                                        [other_rev_spec])[-1]]
 
             #case two independent repos
             if org_repo != other_repo: