# HG changeset patch # User Mads Kiilerich # Date 1423620300 -3600 # Node ID 51c4d2e74898d67ef2bb8df494f838cda097cd7c # Parent dea513b7004bd1dbef62001d973ac788499c169a compare: simplify handling of compare with null revision diff -r dea513b7004b -r 51c4d2e74898 kallithea/controllers/compare.py --- 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)