Changeset - f4c60fafac54
[Not reviewed]
default
0 1 0
Mads Kiilerich - 11 years ago 2014-10-03 00:20:36
madski@unity3d.com
compare: workaround unexpected Mercurial behaviour when finding ancestor of null rev

ancestor(id(0000000000000000000000000000000000000000),7) == 7
- that caused weird pull request diffs and lots of grief when (accidentally)
creating a pull request from the null revision.

Add special handling for the case of null revisions.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -88,9 +88,13 @@ class CompareController(BaseRepoControll
 
            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:
 
                # pick arbitrary ancestor - but there is usually only one
 
                    # FIXME: picks arbitrary ancestor - but there is usually only one
 
                ancestor = hgrepo[ancestors[0]].hex()
 

	
 
            other_revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)",
0 comments (0 inline, 0 general)