Patchwork [STABLE] graft: do not try to skip rev derived from ancestor more than once (issue6024)

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 15, 2018, 2:08 p.m.
Message ID <b395d9aa849c5776a1a1.1542290926@mimosa>
Download mbox | patch
Permalink /patch/36612/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 15, 2018, 2:08 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1542290378 -32400
#      Thu Nov 15 22:59:38 2018 +0900
# Branch stable
# Node ID b395d9aa849c5776a1a129e5282902b03ab31ab7
# Parent  4790732559ade2c1ab13608ba8d9e0c22d335b9b
graft: do not try to skip rev derived from ancestor more than once (issue6024)

We check 'x in revs' in other cases, so let's do the same.

The test case credits to Tom Prince.
via Mercurial-devel - Nov. 16, 2018, 10:30 p.m.
On Thu, Nov 15, 2018 at 6:12 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1542290378 -32400
> #      Thu Nov 15 22:59:38 2018 +0900
> # Branch stable
> # Node ID b395d9aa849c5776a1a129e5282902b03ab31ab7
> # Parent  4790732559ade2c1ab13608ba8d9e0c22d335b9b
> graft: do not try to skip rev derived from ancestor more than once
> (issue6024)
>

Queued, thanks.
Yuya Nishihara - Nov. 17, 2018, 2:13 a.m.
On Fri, 16 Nov 2018 14:30:15 -0800, Martin von Zweigbergk wrote:
> On Thu, Nov 15, 2018 at 6:12 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1542290378 -32400
> > #      Thu Nov 15 22:59:38 2018 +0900
> > # Branch stable
> > # Node ID b395d9aa849c5776a1a129e5282902b03ab31ab7
> > # Parent  4790732559ade2c1ab13608ba8d9e0c22d335b9b
> > graft: do not try to skip rev derived from ancestor more than once
> > (issue6024)
> 
> Queued, thanks.

Martin, appears that this one got pushed to the wrong branch. It's for stable.
via Mercurial-devel - Nov. 17, 2018, 2:46 a.m.
On Fri, Nov 16, 2018, 18:14 Yuya Nishihara <yuya@tcha.org wrote:

> On Fri, 16 Nov 2018 14:30:15 -0800, Martin von Zweigbergk wrote:
> > On Thu, Nov 15, 2018 at 6:12 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1542290378 -32400
> > > #      Thu Nov 15 22:59:38 2018 +0900
> > > # Branch stable
> > > # Node ID b395d9aa849c5776a1a129e5282902b03ab31ab7
> > > # Parent  4790732559ade2c1ab13608ba8d9e0c22d335b9b
> > > graft: do not try to skip rev derived from ancestor more than once
> > > (issue6024)
> >
> > Queued, thanks.
>
> Martin, appears that this one got pushed to the wrong branch. It's for
> stable.
>

I'm sorry. Feel free to move it yourself. I believe my acceptance will
automatically transfer, but otherwise I'll do it again later.

>
Yuya Nishihara - Nov. 17, 2018, 4:03 a.m.
On Fri, 16 Nov 2018 18:46:03 -0800, Martin von Zweigbergk wrote:
> On Fri, Nov 16, 2018, 18:14 Yuya Nishihara <yuya@tcha.org wrote:
> 
> > On Fri, 16 Nov 2018 14:30:15 -0800, Martin von Zweigbergk wrote:
> > > On Thu, Nov 15, 2018 at 6:12 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > > > # HG changeset patch
> > > > # User Yuya Nishihara <yuya@tcha.org>
> > > > # Date 1542290378 -32400
> > > > #      Thu Nov 15 22:59:38 2018 +0900
> > > > # Branch stable
> > > > # Node ID b395d9aa849c5776a1a129e5282902b03ab31ab7
> > > > # Parent  4790732559ade2c1ab13608ba8d9e0c22d335b9b
> > > > graft: do not try to skip rev derived from ancestor more than once
> > > > (issue6024)
> > >
> > > Queued, thanks.
> >
> > Martin, appears that this one got pushed to the wrong branch. It's for
> > stable.
> >
> 
> I'm sorry. Feel free to move it yourself. I believe my acceptance will
> automatically transfer, but otherwise I'll do it again later.

Rebased onto stable.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2478,10 +2478,11 @@  def _dograft(ui, repo, *revs, **opts):
                     revs.remove(ids[n])
             elif ctx.hex() in ids:
                 r = ids[ctx.hex()]
-                ui.warn(_('skipping already grafted revision %d:%s '
-                          '(was grafted from %d:%s)\n') %
-                        (r, repo[r], rev, ctx))
-                revs.remove(r)
+                if r in revs:
+                    ui.warn(_('skipping already grafted revision %d:%s '
+                              '(was grafted from %d:%s)\n') %
+                            (r, repo[r], rev, ctx))
+                    revs.remove(r)
         if not revs:
             return -1
 
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1390,6 +1390,52 @@  also detecting that both 3 and 5 should 
 
   $ cd ..
 
+Grafted revision should be warned and skipped only once. (issue6024)
+
+  $ mkdir issue6024
+  $ cd issue6024
+
+  $ hg init base
+  $ cd base
+  $ touch x
+  $ hg commit -qAminit
+  $ echo a > x
+  $ hg commit -mchange
+  $ hg update -q 0
+  $ hg graft -r 1
+  grafting 1:a0b923c546aa "change" (tip)
+  $ cd ..
+
+  $ hg clone -qr 2 base clone
+  $ cd clone
+  $ hg pull -q
+  $ hg merge -q 2
+  $ hg commit -mmerge
+  $ hg update -q 0
+  $ hg graft -r 1
+  grafting 1:04fc6d444368 "change"
+  $ hg update -q 3
+  $ hg log -G -T '{rev}:{node|shortest} <- {extras.source|shortest}\n'
+  o  4:4e16 <- a0b9
+  |
+  | @    3:f0ac <-
+  | |\
+  +---o  2:a0b9 <-
+  | |
+  | o  1:04fc <- a0b9
+  |/
+  o  0:7848 <-
+  
+
+ the source of rev 4 is an ancestor of the working parent, and was also
+ grafted as rev 1. it should be stripped from the target revisions only once.
+
+  $ hg graft -r 4
+  skipping already grafted revision 4:4e16bab40c9c (1:04fc6d444368 also has origin 2:a0b923c546aa)
+  [255]
+
+  $ cd ../..
+
 Testing the reading of old format graftstate file with newer mercurial
 
   $ hg init oldgraft