[PATCH 3 of 3 issue4704] histedit: abort rather than edit a public changeset (issue4704)
Augie Fackler
raf at durin42.com
Fri Jun 5 14:29:52 CDT 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1433532033 14400
# Fri Jun 05 15:20:33 2015 -0400
# Node ID b0e54fee4f7e69a05909786943fabc3393c49c8a
# Parent fd20f9a4469a6b2a40ecb81aed02dbdbabed4a1a
histedit: abort rather than edit a public changeset (issue4704)
This is suboptimal as the user still has to explicitly cancel the
histedit afterwards, but it prevents the immediate problem.
histedit should probably implicitly do 'hg histedit --abort' if a
util.Abort is raised internally.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -433,6 +433,10 @@ def collapse(repo, first, last, commitop
ctxs = list(repo.set('%d::%d', first, last))
if not ctxs:
return None
+ for c in ctxs:
+ if not c.mutable():
+ raise util.Abort(
+ _("cannot fold into public change %s") % node.short(c.node()))
base = first.parents()[0]
# commit a new version of the old changeset, including the update
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -456,12 +456,12 @@ Attempting to fold a change into a publi
> cat "\$1" | sed s/pick/fold/ > tmp
> mv tmp "\$1"
> EOF
-(BROKEN)
$ HGEDITOR="sh ../edit.sh" hg histedit 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
reverting a
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
- 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
- 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
- saved backup bundle to $TESTTMP/r0/.hg/strip-backup/18aa70c8ad22-3aea8ae3-backup.hg (glob)
-(BROKEN)
+ abort: cannot fold into public change 18aa70c8ad22
+ [255]
+TODO: this abort shouldn't be required, but it is for now to leave the repo in
+a clean state.
+ $ hg histedit --abort
More information about the Mercurial-devel
mailing list