pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.
  
  This also adds some `hg debugmergestate` calls to show that extras are stored 
in
  mergestate.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9003

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge-criss-cross.t

CHANGE DETAILS

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
@@ -661,6 +661,8 @@
   (branch merge, don't forget to commit)
   $ ls -1
   other-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -673,6 +675,8 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -684,6 +688,10 @@
   (branch merge, don't forget to commit)
   $ ls -1
   other-file
+  $ hg debugmergestate
+  local (working copy): adfd88e5d7d3d3e22bdd26512991ee64d59c1d8f
+  other (merge rev): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+  extra: the-file (FORCE_NEW_FILENODE = yes)
 
 (merging two deletion together → no conflict)
 
@@ -694,6 +702,8 @@
   (branch merge, don't forget to commit)
   $ ls -1
   other-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -706,6 +716,8 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -717,6 +729,10 @@
   (branch merge, don't forget to commit)
   $ ls -1
   other-file
+  $ hg debugmergestate
+  local (working copy): a4e0e44229dc130be2915b92c957c093f8c7ee3e
+  other (merge rev): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+  extra: the-file (FORCE_NEW_FILENODE = yes)
 
 (merging two "keeping" together → no conflict)
 
@@ -728,6 +744,10 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  local (working copy): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+  other (merge rev): 38a4c3e7cac8c294ecb0a7a85a05464e9836ca78
+  extra: the-file (filenode-source = other)
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -740,6 +760,8 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -752,6 +774,10 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  local (working copy): 5e3eccec60d88f94a7ba57c351f32cb24c15fe0c
+  other (merge rev): a4e0e44229dc130be2915b92c957c093f8c7ee3e
+  extra: the-file (FORCE_NEW_FILENODE = yes)
 
 (merging two "keeping" together → no conflict)
 
@@ -763,6 +789,8 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -775,6 +803,8 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
 
 (merging a deletion with keeping → conflict)
 BROKEN: this should result in conflict
@@ -787,3 +817,5 @@
   $ ls -1
   other-file
   the-file
+  $ hg debugmergestate
+  no merge state found
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -949,6 +949,13 @@
                     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'FORCE_NEW_FILENODE', b'yes')
+
             else:  # file not in ancestor, not in remote
                 rename_found = False
                 for source, dest in branch_copies1.dirmove.items():
@@ -1088,6 +1095,12 @@
                     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'FORCE_NEW_FILENODE', b'yes')
 
     if repo.ui.configbool(b'experimental', b'merge.checkpathconflicts'):
         # If we are merging, look for path conflicts.



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to