Patchwork D11550: dirstate: remove a update_file's special case for tracked file with p2 data

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2021, 6:40 p.m.
Message ID <differential-rev-PHID-DREV-67avra6a4b544s4wpcv6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49874/
State Superseded
Headers show

Comments

phabricator - Oct. 1, 2021, 6:40 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This case was fishy and can be dealt with by passing more accurate data a higher
  level.
  
  This clarify the API and prepare for a larger rework of the data we feeds to
  the dirstate.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py
  mercurial/mergestate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -796,12 +796,15 @@ 
     for f, args, msg in actions.get(ACTION_GET, []):
         if branchmerge:
             # tracked in p1 can be True also but update_file should not care
+            old_entry = repo.dirstate.get_entry(f)
+            p1_tracked = old_entry.any_tracked and not old_entry.added
             repo.dirstate.update_file(
                 f,
-                p1_tracked=False,
+                p1_tracked=p1_tracked,
                 p2_tracked=True,
                 wc_tracked=True,
-                clean_p2=True,
+                clean_p2=not p1_tracked,
+                merged=p1_tracked,
             )
         else:
             parentfiledata = getfiledata[f] if getfiledata else None
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -226,16 +226,7 @@ 
         elif (p1_tracked or p2_tracked) and not wc_tracked:
             pass
         elif clean_p2 and wc_tracked:
-            if p1_tracked or self.get(filename) is not None:
-                # XXX the `self.get` call is catching some case in
-                # `test-merge-remove.t` where the file is tracked in p1, the
-                # p1_tracked argument is False.
-                #
-                # In addition, this seems to be a case where the file is marked
-                # as merged without actually being the result of a merge
-                # action. So thing are not ideal here.
-                merged = True
-                clean_p2 = False
+            pass
         elif not p1_tracked and p2_tracked and wc_tracked:
             clean_p2 = True
         elif possibly_dirty: