diff hgext/histedit.py @ 21233:213fd1a99cd9

histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()" Before this patch, "message" action of "hg histedit" uses "ui.edit()" explicitly to get commit message edited manually. This requires explicit "localrepository.savecommitmessage()" invocation to save edited commit message into ".hg/last-message.txt", because unexpected exception raising may abort command execution before saving it in "localrepository.commit()". This patch uses "editor" argument of "localrepository.commit()" instead of explicit "ui.edit()" invocation for "message" action of "hg histedit" "localrepository.commit()" will invoke "editor()" function newly added in this patch, and save edited commit message into ".hg/last-message.txt" automatically.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 05 May 2014 21:26:40 +0900
parents dae36d3e1c60
children 19d98da5c018
line wrap: on
line diff
--- a/hgext/histedit.py	Tue Apr 29 12:54:01 2014 +0900
+++ b/hgext/histedit.py	Mon May 05 21:26:40 2014 +0900
@@ -402,12 +402,12 @@
     if stats and stats[3] > 0:
         raise error.InterventionRequired(
             _('Fix up the change and run hg histedit --continue'))
-    message = oldctx.description() + '\n'
-    message = ui.edit(message, ui.username())
-    repo.savecommitmessage(message)
+    message = oldctx.description()
+    def editor(repo, ctx, subs):
+        return ui.edit(ctx.description() + "\n", ctx.user())
     commit = commitfuncfor(repo, oldctx)
     new = commit(text=message, user=oldctx.user(), date=oldctx.date(),
-                 extra=oldctx.extra())
+                 extra=oldctx.extra(), editor=editor)
     newctx = repo[new]
     if oldctx.node() != newctx.node():
         return newctx, [(oldctx.node(), (new,))]