dirstate: add a `get_entry` method to the dirstate
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 29 Sep 2021 02:37:24 +0200
changeset 48097 6a78715e56c8
parent 48096 596510cd2b12
child 48098 80783e553bd5
dirstate: add a `get_entry` method to the dirstate This method give access to the underlying `DirstateEntry` object (or an empty one if None was there). It should allow us to use the more semantic property of the entry instead of the state where we needs it. Differential Revision: https://phab.mercurial-scm.org/D11522
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Sep 30 18:06:34 2021 +0200
+++ b/mercurial/dirstate.py	Wed Sep 29 02:37:24 2021 +0200
@@ -332,6 +332,13 @@
             return entry.state
         return b'?'
 
+    def get_entry(self, path):
+        """return a DirstateItem for the associated path"""
+        entry = self._map.get(path)
+        if entry is None:
+            return DirstateItem()
+        return entry
+
     def __contains__(self, key):
         return key in self._map