Patchwork [STABLE] merge: do not fill manifest of committed revision with pseudo node (issue5526)

login
register
mail settings
Submitter Yuya Nishihara
Date June 19, 2018, 2:02 p.m.
Message ID <128900c6df73ddfbe6a3.1529416955@mimosa>
Download mbox | patch
Permalink /patch/32332/
State Accepted
Headers show

Comments

Yuya Nishihara - June 19, 2018, 2:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1529415952 -32400
#      Tue Jun 19 22:45:52 2018 +0900
# Branch stable
# Node ID 128900c6df73ddfbe6a3a8a5adcc308b5fbb35d7
# Parent  ae7f27867c2acb0345f3d2101185b807ced07aab
merge: do not fill manifest of committed revision with pseudo node (issue5526)

Since a75d24539aba "convert: fix convert dropping p2 contents during filemap
merge", wctx is not always a committablectx because the convert extension
passes in repo[n] as wctx. If wctx is a committed changeset, its manifest
dict shouldn't be mutated reflecting to the working directory.
via Mercurial-devel - June 21, 2018, 4:31 p.m.
On Tue, Jun 19, 2018 at 7:02 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1529415952 -32400
> #      Tue Jun 19 22:45:52 2018 +0900
> # Branch stable
> # Node ID 128900c6df73ddfbe6a3a8a5adcc308b5fbb35d7
> # Parent  ae7f27867c2acb0345f3d2101185b807ced07aab
> merge: do not fill manifest of committed revision with pseudo node
> (issue5526)
>

Queued, thanks!

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1106,8 +1106,10 @@  def manifestmerge(repo, wctx, p2, pa, br
     copied = set(copy.values())
     copied.update(movewithdir.values())
 
-    if '.hgsubstate' in m1:
-        # check whether sub state is modified
+    if '.hgsubstate' in m1 and wctx.rev() is None:
+        # Check whether sub state is modified, and overwrite the manifest
+        # to flag the change. If wctx is a committed revision, we shouldn't
+        # care for the dirty state of the working directory.
         if any(wctx.sub(s).dirty() for s in wctx.substate):
             m1['.hgsubstate'] = modifiednodeid
 
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1941,3 +1941,43 @@  and bad usernames:
   updating to branch default
   abort: potentially unsafe url: 'ssh://-oProxyCommand=touch owned@example.com/path' (in subrepository "s")
   [255]
+
+Test convert subrepositories including merge (issue5526):
+
+  $ hg init tconv
+  $ hg convert --config extensions.convert= -q t/s tconv/s
+  $ hg convert --config extensions.convert= -q t/s/ss tconv/s/ss
+  $ hg convert --config extensions.convert= -q t/t tconv/t
+
+ convert shouldn't fail because of pseudo filenode:
+
+  $ hg convert --config extensions.convert= t tconv
+  scanning source...
+  sorting...
+  converting...
+  17 0
+  16 1
+  15 2
+  14 3
+  13 4
+  12 5
+  11 6
+  10 7
+  9 8
+  8 9
+  7 10
+  6 11
+  5 12
+  4 13
+  3 rm2
+  2 phasecheck4
+  1 16
+  0 branch before subrepo add
+
+ converted .hgsubstate should point to valid nodes:
+
+  $ hg up -R tconv 9
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat tconv/.hgsubstate
+  fc627a69481fcbe5f1135069e8a3881c023e4cf5 s
+  60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t