histedit: abort rather than edit a public changeset (issue4704)
authorAugie Fackler <augie@google.com>
Fri, 05 Jun 2015 15:20:33 -0400
changeset 25452 43906060a3f4
parent 25451 f0acc3e0bd32
child 25453 d3a00fc3680f
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.
hgext/histedit.py
tests/test-histedit-edit.t
--- a/hgext/histedit.py	Fri Jun 05 15:06:58 2015 -0400
+++ b/hgext/histedit.py	Fri Jun 05 15:20:33 2015 -0400
@@ -433,6 +433,10 @@
     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
--- a/tests/test-histedit-edit.t	Fri Jun 05 15:06:58 2015 -0400
+++ b/tests/test-histedit-edit.t	Fri Jun 05 15:20:33 2015 -0400
@@ -456,12 +456,12 @@
   > 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