Patchwork [1,of,9,V2] configitems: add a new config option to control new filenode functionality

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 25, 2020, 9:16 a.m.
Message ID <2459a55b887107613818.1601025410@workspace>
Download mbox | patch
Permalink /patch/47279/
State Accepted
Headers show

Comments

Pulkit Goyal - Sept. 25, 2020, 9:16 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1600074083 -19800
#      Mon Sep 14 14:31:23 2020 +0530
# Node ID 2459a55b887107613818e0d968ef80748dafaadb
# Parent  abad925af2ef488ecbe43d2d1e2d341ddcf2096a
# EXP-Topic merge-newnode
configitems: add a new config option to control new filenode functionality

This series is adding functionality where we can force create a new filenode for
some files on a merge-commit. This is meant to represent an explicit choice made
by user and hence distingusing the file in the merged commit with the file in
parent by creating a new filenode instead of using the parent one.

This introduces a experimental config option under which this functionality
will be hidden.

A new testcase is added in tests/test-merge-criss-cross.t to test the new
functionality while making the option does not break other scenarios.

Differential Revision: https://phab.mercurial-scm.org/D9026
Yuya Nishihara - Sept. 25, 2020, 11:05 a.m.
On Fri, 25 Sep 2020 14:46:50 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1600074083 -19800
> #      Mon Sep 14 14:31:23 2020 +0530
> # Node ID 2459a55b887107613818e0d968ef80748dafaadb
> # Parent  abad925af2ef488ecbe43d2d1e2d341ddcf2096a
> # EXP-Topic merge-newnode
> configitems: add a new config option to control new filenode functionality

Queued, thanks.
Yuya Nishihara - Sept. 25, 2020, 11:11 a.m.
On Fri, 25 Sep 2020 14:46:58 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1598263534 -19800
> #      Mon Aug 24 15:35:34 2020 +0530
> # Node ID 7331100f93338574bf3e289fef3e622fd16859a5
> # Parent  2194dc931f08e7682f75054c7bb1754ea43d504a
> # EXP-Topic merge-newnode
> merge: store cases when a file is absent post merge in commitinfo

> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -923,6 +923,15 @@ def manifestmerge(
>                      mresult.addfile(
>                          f, mergestatemod.ACTION_REMOVE, None, b'other deleted',
>                      )
> +                    if branchmerge:
> +                        # the file must be absent after merging,
> +                        # howeber the user might make
> +                        # the file reappear using revert and if they does,
> +                        # we force create a new node
> +                        mresult.addcommitinfo(
> +                            f, b'MERGE_REMOVAL_CANDIDATE', b'yes'

As I said, the other extra keys have names like "merge-removal-candidate"
or "mergeremovalcandidate". Can you send a follow up?

>    $ hg debugmergestate
> -  no merge state found
> +  local (working copy): adfd88e5d7d3d3e22bdd26512991ee64d59c1d8f
> +  other (merge rev): e9b7081317232edce73f7ad5ae0b7807ff5c326a
> +  extra: the-file (MERGE_REMOVAL_CANDIDATE = yes)
>  #endif

I expect we'll see some real behavior changes in subsequent patches.
Pulkit Goyal - Sept. 25, 2020, 11:57 a.m.
On Fri, Sep 25, 2020 at 4:41 PM Yuya Nishihara <yuya@tcha.org> wrote:
>
> On Fri, 25 Sep 2020 14:46:58 +0530, Pulkit Goyal wrote:
> > # HG changeset patch
> > # User Pulkit Goyal <7895pulkit@gmail.com>
> > # Date 1598263534 -19800
> > #      Mon Aug 24 15:35:34 2020 +0530
> > # Node ID 7331100f93338574bf3e289fef3e622fd16859a5
> > # Parent  2194dc931f08e7682f75054c7bb1754ea43d504a
> > # EXP-Topic merge-newnode
> > merge: store cases when a file is absent post merge in commitinfo
>
> > diff --git a/mercurial/merge.py b/mercurial/merge.py
> > --- a/mercurial/merge.py
> > +++ b/mercurial/merge.py
> > @@ -923,6 +923,15 @@ def manifestmerge(
> >                      mresult.addfile(
> >                          f, mergestatemod.ACTION_REMOVE, None, b'other deleted',
> >                      )
> > +                    if branchmerge:
> > +                        # the file must be absent after merging,
> > +                        # howeber the user might make
> > +                        # the file reappear using revert and if they does,
> > +                        # we force create a new node
> > +                        mresult.addcommitinfo(
> > +                            f, b'MERGE_REMOVAL_CANDIDATE', b'yes'
>
> As I said, the other extra keys have names like "merge-removal-candidate"
> or "mergeremovalcandidate". Can you send a follow up?

Will fix this in V3. Forgot to mention, I am quite young to understand
what Lisp case means, and googling just does not give any good result.
>
> >    $ hg debugmergestate
> > -  no merge state found
> > +  local (working copy): adfd88e5d7d3d3e22bdd26512991ee64d59c1d8f
> > +  other (merge rev): e9b7081317232edce73f7ad5ae0b7807ff5c326a
> > +  extra: the-file (MERGE_REMOVAL_CANDIDATE = yes)
> >  #endif
>
> I expect we'll see some real behavior changes in subsequent patches.

Yes, we are mostly there. We do have a new filenode now in one of the
two cases. Bid-merge needs fixes now.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -590,6 +590,11 @@  coreconfigitem(
 coreconfigitem(
     b'experimental', b'maxdeltachainspan', default=-1,
 )
+# tracks files which were undeleted (merge might delete them but we explicitly
+# kept/undeleted them) and creates new filenodes for them
+coreconfigitem(
+    b'experimental', b'merge-track-salvaged', default=False,
+)
 coreconfigitem(
     b'experimental', b'mergetempdirprefix', default=None,
 )
diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -1,3 +1,15 @@ 
+#testcases old newfilenode
+
+#if newfilenode
+Enable the config option
+------------------------
+
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > merge-track-salvaged = True
+  > EOF
+#endif
+
 Criss cross merging
 
   $ hg init criss-cross