changeset 4886:51c4d2e74898

compare: simplify handling of compare with null revision
author Mads Kiilerich <madski@unity3d.com>
date Wed, 11 Feb 2015 03:05:00 +0100
parents dea513b7004b
children c5f49ffbd72b
files kallithea/controllers/compare.py
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/compare.py	Fri Mar 06 16:21:24 2015 +0100
+++ b/kallithea/controllers/compare.py	Wed Feb 11 03:05:00 2015 +0100
@@ -70,7 +70,7 @@
         :param other_rev: revision we want out compare to be made on other_repo
         """
         ancestor = None
-        if org_rev == other_rev:
+        if org_rev == other_rev or org_repo.EMPTY_CHANGESET in (org_rev, other_rev):
             org_changesets = []
             other_changesets = []
             ancestor = org_rev
@@ -88,18 +88,14 @@
             else:
                 hgrepo = other_repo._repo
 
-            if org_repo.EMPTY_CHANGESET in (org_rev, other_rev):
-                # work around unexpected Mercurial behaviour
-                ancestor = org_repo.EMPTY_CHANGESET
-            else:
-                ancestors = hgrepo.revs("ancestor(id(%s), id(%s))", org_rev, other_rev)
-                if ancestors:
-                    # FIXME: picks arbitrary ancestor - but there is usually only one
-                    try:
-                        ancestor = hgrepo[ancestors.first()].hex()
-                    except AttributeError:
-                        # removed in hg 3.2
-                        ancestor = hgrepo[ancestors[0]].hex()
+            ancestors = hgrepo.revs("ancestor(id(%s), id(%s))", org_rev, other_rev)
+            if ancestors:
+                # FIXME: picks arbitrary ancestor - but there is usually only one
+                try:
+                    ancestor = hgrepo[ancestors.first()].hex()
+                except AttributeError:
+                    # removed in hg 3.2
+                    ancestor = hgrepo[ancestors[0]].hex()
 
             other_revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)",
                                      other_rev, org_rev, org_rev)