Patchwork histedit: Check first changeset for verb "roll" or "fold" (issue5498)

login
register
mail settings
Submitter A. Klitzing
Date Aug. 11, 2017, 1:31 p.m.
Message ID <2a7c5338e23b07ddf8f4.1502458291@e6430>
Download mbox | patch
Permalink /patch/22884/
State Accepted
Headers show

Comments

A. Klitzing - Aug. 11, 2017, 1:31 p.m.
# HG changeset patch
# User André Klitzing <aklitzing@gmail.com>
# Date 1502457641 -7200
#      Fri Aug 11 15:20:41 2017 +0200
# Branch stable
# Node ID 2a7c5338e23b07ddf8f478952999193d3eff4441
# Parent  a3ce07e2dde5737644dd719806b1e52fb1cc1004
histedit: Check first changeset for verb "roll" or "fold" (issue5498)

If someone changes "pick" to "roll" or "fold" for the first
changeset in a histedit rule Mercurial could remove a wrong
changeset if the phase is non-public.

roll or fold for the first changeset should be invalid.
Augie Fackler - Aug. 11, 2017, 5:56 p.m.
On Fri, Aug 11, 2017 at 03:31:31PM +0200, A. Klitzing wrote:
> # HG changeset patch
> # User André Klitzing <aklitzing@gmail.com>
> # Date 1502457641 -7200
> #      Fri Aug 11 15:20:41 2017 +0200
> # Branch stable
> # Node ID 2a7c5338e23b07ddf8f478952999193d3eff4441
> # Parent  a3ce07e2dde5737644dd719806b1e52fb1cc1004
> histedit: Check first changeset for verb "roll" or "fold" (issue5498)

queued, thanks

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1417,6 +1417,10 @@  def verifyactions(actions, state, ctxs):
     expected = set(c.node() for c in ctxs)
     seen = set()
     prev = None
+
+    if actions[0].verb in ['roll', 'fold']:
+        raise error.ParseError(_('first changeset cannot use verb "%s"' % actions[0].verb))
+
     for action in actions:
         action.verify(prev, expected, seen)
         prev = action
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -541,3 +541,36 @@  Editor should have run only once
   END
 
   $ cd ..
+
+Test rolling into a commit with multiple children (issue5498)
+
+  $ hg init roll
+  $ cd roll
+  $ echo a > a
+  $ hg commit -qAm aa
+  $ echo b > b
+  $ hg commit -qAm bb
+  $ hg up -q ".^"
+  $ echo c > c
+  $ hg commit -qAm cc
+  $ hg log -G -T '{node|short} {desc}'
+  @  5db65b93a12b cc
+  |
+  | o  301d76bdc3ae bb
+  |/
+  o  8f0162e483d0 aa
+  
+
+  $ hg histedit . --commands - << EOF
+  > r 5db65b93a12b
+  > EOF
+  hg: parse error: first changeset cannot use verb "roll"
+  [255]
+  $ hg log -G -T '{node|short} {desc}'
+  @  5db65b93a12b cc
+  |
+  | o  301d76bdc3ae bb
+  |/
+  o  8f0162e483d0 aa
+  
+