[PATCH] [PATCH 04 of 11 RFC] histedit: add execute function (issue4036)
Olle Lundberg
olle.lundberg at gmail.com
Wed Mar 5 16:21:50 UTC 2014
# HG changeset patch
# User Olle Lundberg <geek at nerd.sh>
# Date 1393978358 -3600
# Wed Mar 05 01:12:38 2014 +0100
# Node ID 1856c7395b2b4e748719c0e97ac0b181253c376b
# Parent 125d473d0d3982c8a01c94acbcec350522d9555e
histedit: add execute function (issue4036)
The basic contract is that it receives a clean working copy and
is expected to leave a clean working copy if it exits 0.
If either the command leaves the working copy dirty, or it exits non-0,
histedit aborts.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -333,10 +333,23 @@
applychanges(ui, repo, oldctx, opts)
raise error.InterventionRequired(
_('Make changes as needed, you may commit or record as needed now.\n'
'When you are finished, run hg histedit --continue to resume.'))
+def execute(ui, repo, ctx, cmd, opts):
+ hg.update(repo, ctx.node())
+ rc = util.system(cmd)
+ if rc != 0:
+ raise error.InterventionRequired(
+ _('Command exited with %i. Fix up the change and run '
+ 'hg histedit --continue') % rc)
+ if util.any(repo.status()[:4]):
+ raise error.InterventionRequired(
+ _('Working copy dirty, please check the files listed above.\n'
+ 'When you are finished, run hg histedit --continue to resume.'))
+ return ctx, []
+
def fold(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
hg.update(repo, ctx.node())
stats = applychanges(ui, repo, oldctx, opts)
if stats and stats[3] > 0:
More information about the Mercurial-devel
mailing list