Mercurial > kallithea
changeset 5197:f32c68450266
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.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 19 Jun 2015 18:06:24 +0200 |
parents | 273860c8fd85 |
children | 93e055489e68 |
files | kallithea/controllers/compare.py |
diffstat | 1 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/compare.py Mon Jun 15 17:22:17 2015 +0200 +++ b/kallithea/controllers/compare.py Fri Jun 19 18:06:24 2015 +0200 @@ -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 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 @@ 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)