changeset 50023:e1cff85484e2

dirstate: introduce a `is_changing_any` property This will embrace other cases than changing parents.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 26 Jan 2023 15:50:45 +0100
parents e333cc169c45
children 0dc2fb4b4b11
files hgext/git/dirstate.py mercurial/dirstate.py mercurial/interfaces/dirstate.py mercurial/localrepo.py
diffstat 4 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/dirstate.py	Mon Jan 30 19:21:34 2023 +0100
+++ b/hgext/git/dirstate.py	Thu Jan 26 15:50:45 2023 +0100
@@ -265,6 +265,11 @@
         # correctly stage/revert index edits.
         return False
 
+    def is_changing_any(self):
+        # TODO: we need to implement the context manager bits and
+        # correctly stage/revert index edits.
+        return False
+
     def write(self, tr):
         # TODO: call parent change callbacks
 
--- a/mercurial/dirstate.py	Mon Jan 30 19:21:34 2023 +0100
+++ b/mercurial/dirstate.py	Thu Jan 26 15:50:45 2023 +0100
@@ -202,6 +202,14 @@
         )
         raise error.ProgrammingError(msg)
 
+    @property
+    def is_changing_any(self):
+        """Returns true if the dirstate is in the middle of a set of changes.
+
+        This returns True for any kind of change.
+        """
+        return self._changing_level > 0
+
     def pendingparentchange(self):
         """Returns true if the dirstate is in the middle of a set of changes
         that modify the dirstate parent.
--- a/mercurial/interfaces/dirstate.py	Mon Jan 30 19:21:34 2023 +0100
+++ b/mercurial/interfaces/dirstate.py	Thu Jan 26 15:50:45 2023 +0100
@@ -24,6 +24,9 @@
     # TODO: all these private methods and attributes should be made
     # public or removed from the interface.
     _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
+    is_changing_any = interfaceutil.Attribute(
+        """True if any changes in progress."""
+    )
     is_changing_parents = interfaceutil.Attribute(
         """True if parents changes in progress."""
     )
--- a/mercurial/localrepo.py	Mon Jan 30 19:21:34 2023 +0100
+++ b/mercurial/localrepo.py	Thu Jan 26 15:50:45 2023 +0100
@@ -3070,7 +3070,7 @@
                 self.ui.develwarn(b'"wlock" acquired after "lock"')
 
         def unlock():
-            if self.dirstate.is_changing_parents:
+            if self.dirstate.is_changing_any:
                 msg = b"wlock release in the middle of a changing parents"
                 self.ui.develwarn(msg)
                 self.dirstate.invalidate()