[PATCH 9 of 9] merge: store cases when a file is absent post merge in commitinfo
Pulkit Goyal
7895pulkit at gmail.com
Wed Sep 23 08:18:24 UTC 2020
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1598263534 -19800
# Mon Aug 24 15:35:34 2020 +0530
# Node ID d017b2b74022778a9de3fbf25d70195b6ddd06a4
# Parent ef85c4b4cc2e005392b121c8aa509b440d52482c
# EXP-Topic merge-newnode
merge: store cases when a file is absent post merge in commitinfo
Some merges can result in file being absent form working directory. This can be
one of file was kept deleted or file was removed by merge code.
User might revert the file back before committing. In such cases we will like to
have better handling and create new filenodes.
We store this info in mergestate as commitinfo so that we can use it while
committing to create new filenode if required.
Differential Revision: https://phab.mercurial-scm.org/D9003
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -919,6 +919,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'
+ )
+
else: # file not in ancestor, not in remote
mresult.addfile(
f,
@@ -1025,6 +1034,12 @@ def manifestmerge(
None,
b'local not present, remote unchanged',
)
+ if branchmerge:
+ # the file must be absent after merging
+ # however 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')
if repo.ui.configbool(b'experimental', b'merge.checkpathconflicts'):
# If we are merging, look for path conflicts.
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
@@ -681,7 +681,9 @@ BROKEN: this should result in conflict
$ ls -1
other-file
$ hg debugmergestate
- no merge state found
+ local (working copy): adfd88e5d7d3d3e22bdd26512991ee64d59c1d8f
+ other (merge rev): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+ extra: the-file (MERGE_REMOVAL_CANDIDATE = yes)
(merging two deletion together → no conflict)
@@ -720,7 +722,9 @@ BROKEN: this should result in conflict
$ ls -1
other-file
$ hg debugmergestate
- no merge state found
+ local (working copy): a4e0e44229dc130be2915b92c957c093f8c7ee3e
+ other (merge rev): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+ extra: the-file (MERGE_REMOVAL_CANDIDATE = yes)
(merging two "keeping" together → no conflict)
@@ -763,7 +767,9 @@ BROKEN: this should result in conflict
other-file
the-file
$ hg debugmergestate
- no merge state found
+ local (working copy): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+ other (merge rev): a4e0e44229dc130be2915b92c957c093f8c7ee3e
+ extra: the-file (MERGE_REMOVAL_CANDIDATE = yes)
(merging two "keeping" together → no conflict)
More information about the Mercurial-devel
mailing list