Changeset - f32c68450266
[Not reviewed]
default
0 1 0
Mads Kiilerich - 10 years ago 2015-06-19 18:06:24
madski@unity3d.com
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.
1 file changed with 13 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -67,13 +67,13 @@ class CompareController(BaseRepoControll
 
        :param org_rev: the revision we want our compare to be made
 
        :param other_repo: repo object, most likely the fork of org_repo. It has
 
            all changesets that we need to obtain
 
        :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
 

	
 
        elif alias == 'hg':
 
            #case two independent repos
 
@@ -85,20 +85,24 @@ class CompareController(BaseRepoControll
 
                # rev numbers from hgrepo can be used in other_repo - org_rev ancestors cannot
 

	
 
            #no remote compare do it on the same repository
 
            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)
 
            other_changesets = [other_repo.get_changeset(rev) for rev in other_revs]
 
            org_revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)",
 
                                   org_rev, other_rev, other_rev)
0 comments (0 inline, 0 general)