Patchwork [1,of,3] histedit: fix preventing strips during histedit

login
register
mail settings
Submitter Durham Goode
Date April 6, 2015, 2:30 a.m.
Message ID <0a1ead2c3d2c81db0acd.1428287414@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8509/
State Accepted
Headers show

Comments

Durham Goode - April 6, 2015, 2:30 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1428171888 25200
#      Sat Apr 04 11:24:48 2015 -0700
# Node ID 0a1ead2c3d2c81db0acd31a2d36d3fe4153aeb0f
# Parent  4a4018831d2ebc3c9cae9c6613e6a2497b4f0993
histedit: fix preventing strips during histedit

We were trying to prevent strips of important nodes during histedit, but the
check was actually comparing the short hashes in the rules to the exact value
the user typed in, so it only ever worked if the user typed a 12 character hash.
Matt Mackall - April 6, 2015, 9:15 p.m.
On Sun, 2015-04-05 at 19:30 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1428171888 25200
> #      Sat Apr 04 11:24:48 2015 -0700
> # Node ID 0a1ead2c3d2c81db0acd31a2d36d3fe4153aeb0f
> # Parent  4a4018831d2ebc3c9cae9c6613e6a2497b4f0993
> histedit: fix preventing strips during histedit

I've queued this first one for default, thanks.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1030,8 +1030,9 @@  def stripwrapper(orig, ui, repo, nodelis
     if os.path.exists(os.path.join(repo.path, 'histedit-state')):
         state = histeditstate(repo)
         state.read()
-        histedit_nodes = set([ctx for (action, ctx) in state.rules])
-        strip_nodes = set([repo[n].hex() for n in nodelist])
+        histedit_nodes = set([repo[rulehash].node() for (action, rulehash)
+                             in state.rules if rulehash in repo])
+        strip_nodes = set([repo[n].node() for n in nodelist])
         common_nodes = histedit_nodes & strip_nodes
         if common_nodes:
             raise util.Abort(_("histedit in progress, can't strip %s")
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
@@ -87,8 +87,8 @@  Go at a random point and try to continue
   [255]
 
 Try to delete necessary commit
-  $ hg strip -r 652413bf663e
-  abort: histedit in progress, can't strip 363532343133
+  $ hg strip -r 652413b
+  abort: histedit in progress, can't strip 652413bf663e
   [255]
 
 commit, then edit the revision