changeset 50022:e333cc169c45

dirstate: rename `pendingparentchange` to `is_changing_parents` This is clearer and more inline witht he other change we did.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 Jan 2023 19:21:34 +0100
parents 4e955a7a6a55
children e1cff85484e2
files hgext/git/dirstate.py mercurial/context.py mercurial/dirstate.py mercurial/interfaces/dirstate.py mercurial/localrepo.py
diffstat 5 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/dirstate.py	Thu Jan 26 15:50:36 2023 +0100
+++ b/hgext/git/dirstate.py	Mon Jan 30 19:21:34 2023 +0100
@@ -260,7 +260,7 @@
     # # TODO what the heck is this
     _filecache = set()
 
-    def pendingparentchange(self):
+    def is_changing_parents(self):
         # TODO: we need to implement the context manager bits and
         # correctly stage/revert index edits.
         return False
--- a/mercurial/context.py	Thu Jan 26 15:50:36 2023 +0100
+++ b/mercurial/context.py	Mon Jan 30 19:21:34 2023 +0100
@@ -1867,7 +1867,7 @@
                     dirstate = self._repo.dirstate
                     if dirstate.identity() == oldid:
                         if fixup:
-                            if dirstate.pendingparentchange():
+                            if dirstate.is_changing_parents:
                                 normal = lambda f, pfd: dirstate.update_file(
                                     f, p1_tracked=True, wc_tracked=True
                                 )
--- a/mercurial/dirstate.py	Thu Jan 26 15:50:36 2023 +0100
+++ b/mercurial/dirstate.py	Mon Jan 30 19:21:34 2023 +0100
@@ -68,7 +68,7 @@
 
 def requires_changing_parents(func):
     def wrap(self, *args, **kwargs):
-        if not self.pendingparentchange():
+        if not self.is_changing_parents:
             msg = 'calling `%s` outside of a changing_parents context'
             msg %= func.__name__
             raise error.ProgrammingError(msg)
@@ -82,7 +82,7 @@
 
 def requires_not_changing_parents(func):
     def wrap(self, *args, **kwargs):
-        if self.pendingparentchange():
+        if self.is_changing_parents:
             msg = 'calling `%s` inside of a changing_parents context'
             msg %= func.__name__
             raise error.ProgrammingError(msg)
@@ -206,6 +206,14 @@
         """Returns true if the dirstate is in the middle of a set of changes
         that modify the dirstate parent.
         """
+        self._ui.deprecwarn(b"dirstate.is_changing_parents", b"6.5")
+        return self.is_changing_parents
+
+    @property
+    def is_changing_parents(self):
+        """Returns true if the dirstate is in the middle of a set of changes
+        that modify the dirstate parent.
+        """
         return self._changing_level > 0
 
     @propertycache
--- a/mercurial/interfaces/dirstate.py	Thu Jan 26 15:50:36 2023 +0100
+++ b/mercurial/interfaces/dirstate.py	Mon Jan 30 19:21:34 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_parents = interfaceutil.Attribute(
+        """True if parents changes in progress."""
+    )
 
     def _ignorefiles():
         """Return a list of files containing patterns to ignore."""
@@ -43,11 +46,6 @@
         released.
         """
 
-    def pendingparentchange():
-        """Returns true if the dirstate is in the middle of a set of changes
-        that modify the dirstate parent.
-        """
-
     def hasdir(d):
         pass
 
--- a/mercurial/localrepo.py	Thu Jan 26 15:50:36 2023 +0100
+++ b/mercurial/localrepo.py	Mon Jan 30 19:21:34 2023 +0100
@@ -612,7 +612,6 @@
     # to be reshared
     hint = _(b"see `hg help config.format.use-share-safe` for more information")
     if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
-
         if (
             shared
             and requirementsmod.SHARESAFE_REQUIREMENT
@@ -2121,7 +2120,7 @@
         # writing to the cache), but the rest of Mercurial wants them in
         # local encoding.
         tags = {}
-        for (name, (node, hist)) in alltags.items():
+        for name, (node, hist) in alltags.items():
             if node != self.nullid:
                 tags[encoding.tolocal(name)] = node
         tags[b'tip'] = self.changelog.tip()
@@ -2900,7 +2899,6 @@
                 filtered.branchmap().write(filtered)
 
     def invalidatecaches(self):
-
         if '_tagscache' in vars(self):
             # can't use delattr on proxy
             del self.__dict__['_tagscache']
@@ -3072,7 +3070,7 @@
                 self.ui.develwarn(b'"wlock" acquired after "lock"')
 
         def unlock():
-            if self.dirstate.pendingparentchange():
+            if self.dirstate.is_changing_parents:
                 msg = b"wlock release in the middle of a changing parents"
                 self.ui.develwarn(msg)
                 self.dirstate.invalidate()
@@ -3549,7 +3547,6 @@
 
 
 def instance(ui, path: bytes, create, intents=None, createopts=None):
-
     # prevent cyclic import localrepo -> upgrade -> localrepo
     from . import upgrade