Patchwork D11583: dirstate: align the dirstatemap's API to the data change

login
register
mail settings
Submitter phabricator
Date Oct. 3, 2021, 12:26 a.m.
Message ID <differential-rev-PHID-DREV-uiqfexxhxrl7e7tt337l-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49907/
State Superseded
Headers show

Comments

phabricator - Oct. 3, 2021, 12:26 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are passing different data, so lets simplify the dirstatemap API too.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py
  mercurial/dirstatemap.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -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(
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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)