[PATCH 3 of 8] histedit: move `between function` outside the action logic
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Fri Sep 21 12:28:26 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1348247644 -7200
# Node ID 10114dd8b02a1cc253e7101acbdeaa092ceab311
# Parent 97ee214c11df224bbb9775af4b57e4e7ad83aebd
histedit: move `between function` outside the action logic
Having this function in the middle of action and patching logic did not make
sense
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -193,32 +193,10 @@ def foldchanges(ui, repo, node1, node2,
patch.patch(ui, repo, patchfile, files=files, eolmode=None)
finally:
os.unlink(patchfile)
return files
-def between(repo, old, new, keep):
- """select and validate the set of revision to edit
-
- When keep is false, the specified set can't have children."""
- revs = [old]
- current = old
- while current != new:
- ctx = repo[current]
- if not keep and len(ctx.children()) > 1:
- raise util.Abort(_('cannot edit history that would orphan nodes'))
- if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid:
- raise util.Abort(_("can't edit history with merges"))
- if not ctx.children():
- current = new
- else:
- current = ctx.children()[0].node()
- revs.append(current)
- if len(repo[current].children()) and not keep:
- raise util.Abort(_('cannot edit history that would orphan nodes'))
- return revs
-
-
def pick(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
if oldctx.parents()[0] == ctx:
ui.debug('node %s unchanged\n' % ha)
return oldctx, [], [], []
@@ -623,10 +601,32 @@ def histedit(ui, repo, *parent, **opts):
os.unlink(os.path.join(repo.path, 'histedit-state'))
if os.path.exists(repo.sjoin('undo')):
os.unlink(repo.sjoin('undo'))
+def between(repo, old, new, keep):
+ """select and validate the set of revision to edit
+
+ When keep is false, the specified set can't have children."""
+ revs = [old]
+ current = old
+ while current != new:
+ ctx = repo[current]
+ if not keep and len(ctx.children()) > 1:
+ raise util.Abort(_('cannot edit history that would orphan nodes'))
+ if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid:
+ raise util.Abort(_("can't edit history with merges"))
+ if not ctx.children():
+ current = new
+ else:
+ current = ctx.children()[0].node()
+ revs.append(current)
+ if len(repo[current].children()) and not keep:
+ raise util.Abort(_('cannot edit history that would orphan nodes'))
+ return revs
+
+
def writestate(repo, parentctxnode, created, replaced,
tmpnodes, existing, rules, keep, oldtip, replacemap):
fp = open(os.path.join(repo.path, 'histedit-state'), 'w')
pickle.dump((parentctxnode, created, replaced,
tmpnodes, existing, rules, keep, oldtip, replacemap),
More information about the Mercurial-devel
mailing list