# HG changeset patch # User Mads Kiilerich # Date 2015-06-19 18:06:24 # Node ID f32c68450266ce81dc9a5c70107aa53d6054858a # Parent 273860c8fd857c1871fd72e8d730d5fde8ddbe2a compare: backout 51c4d2e74898 to fix ancestor calculation to empty repository This case can not just be simplified as I thought it could. Mercurial 3.4 has d2de20e1451f 'revset: extend fullreposet to make "null" revision magically appears in set' Which makes ancestor(id(0000000000),1) 'correctly' return the null revision as ancestor. We can however not rely on that when supporting Mercurial 3.3. diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -70,7 +70,7 @@ class CompareController(BaseRepoControll :param other_rev: revision we want out compare to be made on other_repo """ ancestor = None - if org_rev == other_rev or org_repo.EMPTY_CHANGESET in (org_rev, other_rev): + if org_rev == other_rev: org_changesets = [] other_changesets = [] ancestor = org_rev @@ -88,14 +88,18 @@ class CompareController(BaseRepoControll else: hgrepo = other_repo._repo - 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() + if org_repo.EMPTY_CHANGESET in (org_rev, other_rev): + # work around unexpected behaviour in Mercurial < 3.4 + 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() other_revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)", other_rev, org_rev, org_rev)