dirstate: align the dirstatemap's API to the data change
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Oct 2021 01:27:53 +0200
changeset 48140 98b3eb6c1479
parent 48139 ab5a7fdbf75c
child 48141 42ab0bcb6ded
dirstate: align the dirstatemap's API to the data change We are passing different data, so lets simplify the dirstatemap API too. Differential Revision: https://phab.mercurial-scm.org/D11583
mercurial/dirstate.py
mercurial/dirstatemap.py
--- a/mercurial/dirstate.py	Fri Oct 01 18:49:33 2021 +0200
+++ b/mercurial/dirstate.py	Fri Oct 01 01:27:53 2021 +0200
@@ -516,12 +516,7 @@
             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.
-            possibly_dirty = True
-        elif not (p1_tracked or wc_tracked):
+        if not (p1_tracked or wc_tracked):
             # the file is no longer relevant to anyone
             if self._map.get(filename) is not None:
                 self._map.reset_state(filename)
@@ -529,10 +524,6 @@
         elif (not p1_tracked) and wc_tracked:
             if entry is not None and entry.added:
                 return  # avoid dropping copy information (maybe?)
-        elif p1_tracked and not wc_tracked:
-            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
@@ -545,7 +536,9 @@
             filename,
             wc_tracked,
             p1_tracked,
-            possibly_dirty=possibly_dirty,
+            # the underlying reference might have changed, we will have to
+            # check it.
+            has_meaningful_mtime=False,
             parentfiledata=parentfiledata,
         )
         if (
@@ -616,11 +609,8 @@
             filename,
             wc_tracked,
             p1_tracked,
-            p2_tracked=p2_tracked,
-            merged=merged,
-            clean_p1=clean_p1,
-            clean_p2=clean_p2,
-            possibly_dirty=possibly_dirty,
+            p2_info=merged or clean_p2,
+            has_meaningful_mtime=not possibly_dirty,
             parentfiledata=parentfiledata,
         )
         if (
@@ -773,7 +763,6 @@
                     f,
                     wc_tracked=True,
                     p1_tracked=True,
-                    possibly_dirty=True,
                 )
         for f in to_drop:
             self._map.reset_state(f)
--- a/mercurial/dirstatemap.py	Fri Oct 01 18:49:33 2021 +0200
+++ b/mercurial/dirstatemap.py	Fri Oct 01 01:27:53 2021 +0200
@@ -173,11 +173,9 @@
         filename,
         wc_tracked=False,
         p1_tracked=False,
-        p2_tracked=False,
-        merged=False,
-        clean_p1=False,
-        clean_p2=False,
-        possibly_dirty=False,
+        p2_info=False,
+        has_meaningful_mtime=True,
+        has_meaningful_data=True,
         parentfiledata=None,
     ):
         """Set a entry to a given state, diregarding all previous state
@@ -189,25 +187,16 @@
         dirstate map does not see any point at having one for this file
         anymore.
         """
-        if merged and (clean_p1 or clean_p2):
-            msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`'
-            raise error.ProgrammingError(msg)
         # copy information are now outdated
         # (maybe new information should be in directly passed to this function)
         self.copymap.pop(filename, None)
 
-        if not (p1_tracked or p2_tracked or wc_tracked):
+        if not (p1_tracked or p2_info or wc_tracked):
             old_entry = self._map.get(filename)
             self._drop_entry(filename)
             self._dirs_decr(filename, old_entry=old_entry)
             return
 
-        p2_info = merged or clean_p2
-        if merged:
-            assert p1_tracked
-
-        has_meaningful_mtime = not possibly_dirty
-
         old_entry = self._map.get(filename)
         self._dirs_incr(filename, old_entry)
         entry = DirstateItem(