--- a/hgext/histedit.py Wed Dec 12 13:09:37 2012 -0800
+++ b/hgext/histedit.py Wed Jan 16 19:11:06 2013 +0100
@@ -176,6 +176,22 @@
#
""")
+def commitfuncfor(repo, src):
+ """Build a commit function for the replacement of <src>
+
+ This function ensure we apply the same treatement to all changesets.
+
+ No such treatment is done yet.
+
+ Note that fold have its own separated logic because its handling is a bit
+ different and not easily factored out of the fold method.
+ """
+ def commitfunc(**kwargs):
+ return repo.commit(**kwargs)
+ return commitfunc
+
+
+
def applychanges(ui, repo, ctx, opts):
"""Merge changeset from ctx (only) in the current working directory"""
wcpar = repo.dirstate.parents()[0]
@@ -279,8 +295,9 @@
raise util.Abort(_('Fix up the change and run '
'hg histedit --continue'))
# drop the second merge parent
- n = repo.commit(text=oldctx.description(), user=oldctx.user(),
- date=oldctx.date(), extra=oldctx.extra())
+ commit = commitfuncfor(repo, oldctx)
+ n = commit(text=oldctx.description(), user=oldctx.user(),
+ date=oldctx.date(), extra=oldctx.extra())
if n is None:
ui.warn(_('%s: empty changeset\n')
% node.hex(ha))
@@ -356,8 +373,9 @@
'hg histedit --continue'))
message = oldctx.description() + '\n'
message = ui.edit(message, ui.username())
- new = repo.commit(text=message, user=oldctx.user(), date=oldctx.date(),
- extra=oldctx.extra())
+ commit = commitfuncfor(repo, oldctx)
+ new = commit(text=message, user=oldctx.user(), date=oldctx.date(),
+ extra=oldctx.extra())
newctx = repo[new]
if oldctx.node() != newctx.node():
return newctx, [(oldctx.node(), (new,))]
@@ -558,9 +576,10 @@
editor = cmdutil.commitforceeditor
else:
editor = False
- new = repo.commit(text=message, user=ctx.user(),
- date=ctx.date(), extra=ctx.extra(),
- editor=editor)
+ commit = commitfuncfor(repo, ctx)
+ new = commit(text=message, user=ctx.user(),
+ date=ctx.date(), extra=ctx.extra(),
+ editor=editor)
if new is not None:
newchildren.append(new)
@@ -722,7 +741,7 @@
moves = []
for bk, old in sorted(repo._bookmarks.iteritems()):
if old == oldtopmost:
- # special case ensure bookmark stay on tip.
+ # special case ensure bookmark stay on tip.
#
# This is arguably a feature and we may only want that for the
# active bookmark. But the behavior is kept compatible with the old