changeset 47694:1c06ef8f5ea5

dirstate: use `reset_state` in `update_file_p1` Going through the same API is more consistent and allow us to push implementation lower down the call stack. Differential Revision: https://phab.mercurial-scm.org/D11136
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Jul 2021 04:55:57 +0200
parents 46c318b9b9a4
children f98145ce78d7
files mercurial/dirstate.py
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Thu Jul 15 04:34:51 2021 +0200
+++ b/mercurial/dirstate.py	Thu Jul 15 04:55:57 2021 +0200
@@ -521,22 +521,38 @@
             wc_tracked = False
         else:
             wc_tracked = entry.tracked
+        possibly_dirty = False
         if p1_tracked and wc_tracked:
             # the underlying reference might have changed, we will have to
             # check it.
-            self.normallookup(filename)
+            possibly_dirty = True
         elif not (p1_tracked or wc_tracked):
             # the file is no longer relevant to anyone
             self._drop(filename)
         elif (not p1_tracked) and wc_tracked:
-            if not entry.added:
-                self._add(filename)
+            if entry is not None and entry.added:
+                return  # avoid dropping copy information (maybe?)
         elif p1_tracked and not wc_tracked:
-            if entry is None or not entry.removed:
-                self._remove(filename)
+            pass
         else:
             assert False, 'unreachable'
 
+        # this mean we are doing call for file we do not really care about the
+        # data (eg: added or removed), however this should be a minor overhead
+        # compared to the overall update process calling this.
+        parentfiledata = None
+        if wc_tracked:
+            parentfiledata = self._get_filedata(filename)
+
+        self._updatedfiles.add(filename)
+        self._map.reset_state(
+            filename,
+            wc_tracked,
+            p1_tracked,
+            possibly_dirty=possibly_dirty,
+            parentfiledata=parentfiledata,
+        )
+
     @requires_parents_change
     def update_file(
         self,