[PATCH 6 of 7] histedit: simplify computation of edited set
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 27 18:07:50 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1348786949 -7200
# Node ID 151cbb0322dbdaff630f094a0ed11ae66a8fcf7f
# Parent 719a3f3e0d0d7cbb683e93e8d0484a2d2d30e4e8
histedit: simplify computation of edited set
This complex code can be replaced by two simple revset calls.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -586,22 +586,10 @@
"""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:
+ revs = list(repo.set('%n::%n', old, new))
+ if not keep and repo.revs('(%ld::) - %ld', revs, revs):
raise util.Abort(_('cannot edit history that would orphan nodes'))
- return revs
+ return [c.node() for c in revs]
def writestate(repo, parentnode, rules, keep, topmost, replacements):
More information about the Mercurial-devel
mailing list