Patchwork [3,of,3,issue4704] histedit: abort rather than edit a public changeset (issue4704)

login
register
mail settings
Submitter Augie Fackler
Date June 5, 2015, 7:29 p.m.
Message ID <b0e54fee4f7e69a05909.1433532592@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/9529/
State Accepted
Headers show

Comments

Augie Fackler - June 5, 2015, 7:29 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.
Matt Mackall - June 5, 2015, 7:42 p.m.
On Fri, 2015-06-05 at 15:29 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@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)

These are queued for default, thanks.
Augie Fackler - June 5, 2015, 7:42 p.m.
On Fri, Jun 5, 2015 at 3:42 PM, Matt Mackall <mpm@selenic.com> wrote:
>> histedit: abort rather than edit a public changeset (issue4704)
>
> These are queued for default, thanks.


I assume a later followup to automatically perform the 'histedit
--abort' steps would be okay?

(Just want to make sure my intuition around BC is correct.)
Matt Mackall - June 5, 2015, 8:18 p.m.
On Fri, 2015-06-05 at 15:42 -0400, Augie Fackler wrote:
> On Fri, Jun 5, 2015 at 3:42 PM, Matt Mackall <mpm@selenic.com> wrote:
> >> histedit: abort rather than edit a public changeset (issue4704)
> >
> > These are queued for default, thanks.
> 
> 
> I assume a later followup to automatically perform the 'histedit
> --abort' steps would be okay?
> 
> (Just want to make sure my intuition around BC is correct.)

Yep.

Patch

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