Mercurial > hg-stable
changeset 34021:ba9d5d48bf95
rebase: rewrite _computeobsoletenotrebased
The old code stores successors of all related nodes together, which works
fine if destination is unique. A future patch would make destination
non-unique so let's change the implementation to test successors for
rebaseset separately.
Differential Revision: https://phab.mercurial-scm.org/D347
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 11 Aug 2017 00:31:52 -0700 |
parents | 2ad028635ccd |
children | af609bb3487f |
files | hgext/rebase.py |
diffstat | 1 files changed, 18 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Tue Aug 22 00:38:38 2017 +0000 +++ b/hgext/rebase.py Fri Aug 11 00:31:52 2017 -0700 @@ -1484,31 +1484,24 @@ obsolete => None entries in the mapping indicate nodes with no successor""" obsoletenotrebased = {} - # Build a mapping successor => obsolete nodes for the obsolete - # nodes to be rebased - allsuccessors = {} - cl = repo.changelog - for r in rebaseobsrevs: - node = cl.node(r) - for s in obsutil.allsuccessors(repo.obsstore, [node]): - try: - allsuccessors[cl.rev(s)] = cl.rev(node) - except LookupError: - pass - - if allsuccessors: - # Look for successors of obsolete nodes to be rebased among - # the ancestors of dest - ancs = cl.ancestors([dest], - stoprev=min(allsuccessors), - inclusive=True) - for s in allsuccessors: - if s in ancs: - obsoletenotrebased[allsuccessors[s]] = s - elif (s == allsuccessors[s] and - allsuccessors.values().count(s) == 1): - # plain prune - obsoletenotrebased[s] = None + cl = repo.unfiltered().changelog + nodemap = cl.nodemap + destnode = cl.node(dest) + for srcrev in rebaseobsrevs: + srcnode = cl.node(srcrev) + # XXX: more advanced APIs are required to handle split correctly + successors = list(obsutil.allsuccessors(repo.obsstore, [srcnode])) + if len(successors) == 1: + # obsutil.allsuccessors includes node itself. When the list only + # contains one element, it means there are no successors. + obsoletenotrebased[srcrev] = None + else: + for succnode in successors: + if succnode == srcnode or succnode not in nodemap: + continue + if cl.isancestor(succnode, destnode): + obsoletenotrebased[srcrev] = nodemap[succnode] + break return obsoletenotrebased