[PATCH 1 of 2 v2] rebase: refactor and rename checkexternal - it is a getter more than a setter
Mads Kiilerich
mads at kiilerich.com
Wed Oct 23 23:12:28 CDT 2013
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1382587522 -28800
# Thu Oct 24 12:05:22 2013 +0800
# Branch stable
# Node ID 6e6a1ee0ab34df6dae577832dc229054d42c58ed
# Parent d51c4d85ec23a67292f07b3121a9353452364f6d
rebase: refactor and rename checkexternal - it is a getter more than a setter
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -259,7 +259,7 @@ def rebase(ui, repo, **opts):
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 @@ def rebase(ui, repo, **opts):
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'
More information about the Mercurial-devel
mailing list