Patchwork D11162: dirstate: add a `set_possibly_dirty` method

login
register
mail settings
Submitter phabricator
Date July 19, 2021, 2:09 p.m.
Message ID <differential-rev-PHID-DREV-5jc6zeplke5wy6wzue7v-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49477/
State Superseded
Headers show

Comments

phabricator - July 19, 2021, 2:09 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This method will be able to replace some usage of `normallookup` in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -166,6 +166,10 @@ 
             normed = util.normcase(filename)
             self.filefoldmap.pop(normed, None)
 
+    def set_possibly_dirty(self, filename):
+        """record that the current state of the file on disk is unknown"""
+        self[filename].set_possibly_dirty()
+
     def addfile(
         self,
         f,
@@ -842,6 +846,12 @@ 
                 f[normcase(name)] = name
             return f
 
+        def set_possibly_dirty(self, filename):
+            """record that the current state of the file on disk is unknown"""
+            entry = self[filename]
+            entry.set_possibly_dirty()
+            self._rustmap.set_v1(filename, entry)
+
         def __setitem__(self, key, value):
             assert isinstance(value, DirstateItem)
             self._rustmap.set_v1(key, value)
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -506,6 +506,13 @@ 
         self._updatedfiles.add(filename)
         self._normal(filename, parentfiledata=parentfiledata)
 
+    @requires_no_parents_change
+    def set_possibly_dirty(self, filename):
+        """record that the current state of the file on disk is unknown"""
+        self._dirty = True
+        self._updatedfiles.add(filename)
+        self._map.set_possibly_dirty(filename)
+
     @requires_parents_change
     def update_file_p1(
         self,