histedit: handle multiple spaces between action and hash (issue3893)
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 18 Apr 2013 11:52:34 -0400
changeset 19039 41669a18a7d6
parent 19038 36733ab7fa05
child 19040 7eb6bfe0b5a2
histedit: handle multiple spaces between action and hash (issue3893) There is some clue that the previous code intended to handle that but it was actually not the case. As a result action could apply to the empty string '' changeset, leading to the use the current working directory parent in some operations.
hgext/histedit.py
tests/test-histedit-arguments.t
--- a/hgext/histedit.py	Fri Feb 01 15:00:23 2013 -0800
+++ b/hgext/histedit.py	Thu Apr 18 11:52:34 2013 -0400
@@ -722,10 +722,7 @@
         if ' ' not in r:
             raise util.Abort(_('malformed line "%s"') % r)
         action, rest = r.split(' ', 1)
-        if ' ' in rest.strip():
-            ha, rest = rest.split(' ', 1)
-        else:
-            ha = r.strip()
+        ha = rest.strip().split(' ', 1)[0]
         try:
             if repo[ha] not in ctxs:
                 raise util.Abort(
--- a/tests/test-histedit-arguments.t	Fri Feb 01 15:00:23 2013 -0800
+++ b/tests/test-histedit-arguments.t	Thu Apr 18 11:52:34 2013 -0400
@@ -68,3 +68,34 @@
   $ hg histedit -r 4
   abort: 08d98a8350f3 is not an ancestor of working directory
   [255]
+  $ hg up --quiet
+
+Test short version of command
+---------------------------------------
+
+Note: we use varying amounts of white space between command name and changeset
+short hash. This tests issue3893.
+
+  $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
+  > pick eb57da33312f 2 three
+  > p    c8e68270e35a 3 four
+  > f 08d98a8350f3 4 five
+  > EOF
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  reverting alpha
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  four
+  ***
+  five
+  
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: changed alpha
+  1 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/foo/.hg/strip-backup/*-backup.hg (glob)