Mercurial > hg
changeset 19955:2160c2e0d7d1 stable
rebase: refactor and rename checkexternal - it is a getter more than a setter
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 24 Oct 2013 12:05:22 +0800 |
parents | 427ce5633c1c |
children | 78ab0f85e249 |
files | hgext/rebase.py |
diffstat | 1 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Fri Oct 25 02:33:59 2013 +0800 +++ b/hgext/rebase.py Thu Oct 24 12:05:22 2013 +0800 @@ -259,7 +259,7 @@ if collapsef: targetancestors = repo.changelog.ancestors([target], inclusive=True) - external = checkexternal(repo, state, targetancestors) + external = externalparent(repo, state, targetancestors) if keepbranchesf: # insert _savebranch at the start of extrafns so if @@ -388,24 +388,26 @@ finally: release(lock, wlock) -def checkexternal(repo, state, targetancestors): - """Check whether one or more external revisions need to be taken in - consideration. In the latter case, abort. +def externalparent(repo, state, targetancestors): + """Return the revision that should be used as the second parent + when the revisions in state is collapsed on top of targetancestors. + Abort if there is more than one parent. """ - external = nullrev + parents = set() source = min(state) for rev in state: if rev == source: continue - # Check externals and fail if there are more than one for p in repo[rev].parents(): if (p.rev() not in state and p.rev() not in targetancestors): - if external != nullrev: - raise util.Abort(_('unable to collapse, there is more ' - 'than one external parent')) - external = p.rev() - return external + parents.add(p.rev()) + if not parents: + return nullrev + if len(parents) == 1: + return parents.pop() + raise util.Abort(_('unable to collapse, there is more ' + 'than one external parent')) def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None): 'Commit the changes and store useful information in extra'