Patchwork D11429: dirstate: fix restoration of "merged" state after a remove

login
register
mail settings
Submitter phabricator
Date Sept. 16, 2021, 2:43 p.m.
Message ID <differential-rev-PHID-DREV-bjfmha5jyyyax7olwdsj-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49745/
State Superseded
Headers show

Comments

phabricator - Sept. 16, 2021, 2:43 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Before this change, "merged" file that get removed and re-added later were
  recorded as "from_p2" instead.
  
  This came from 8fe74328f700 <https://phab.mercurial-scm.org/rHG8fe74328f700907f8a9a9ad98ee5fff92864cf45>, a 2014 changeset that start explicitly doing so
  for reason I have not been able to fully grasp.  The graft test mentioned in
  the description are still happy after this changeset.
  
  So this changeset restore what seems to be the intended behavior. Restoring
  information as it was before the removal.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py
  tests/test-merge-remove.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-merge-remove.t b/tests/test-merge-remove.t
--- a/tests/test-merge-remove.t
+++ b/tests/test-merge-remove.t
@@ -55,8 +55,8 @@ 
   adding foo1
 
   $ hg debugstate --no-dates
-  n   0         -2 unset               bar
-  n   0         -2 unset               foo1
+  m   0         -2 unset               bar
+  m   0         -2 unset               foo1
   copy: foo -> foo1
 
   $ hg st -qC
@@ -74,8 +74,8 @@ 
   reverting foo1
 
   $ hg debugstate --no-dates
-  n   0         -2 unset               bar
-  n   0         -2 unset               foo1
+  m   0         -2 unset               bar
+  m   0         -2 unset               foo1
   copy: foo -> foo1
 
   $ hg st -qC
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -734,7 +734,10 @@ 
                 # (see `merged_removed` and `from_p2_removed`)
                 if entry.merged_removed or entry.from_p2_removed:
                     source = self._map.copymap.get(f)
-                    self._addpath(f, from_p2=True)
+                    if entry.merged_removed:
+                        self._addpath(f, merged=True)
+                    else:
+                        self._addpath(f, from_p2=True)
                     self._map.copymap.pop(f, None)
                     if source is not None:
                         self.copy(source, f)