Patchwork D11522: dirstate: add a `get_entry` method to the dirstate

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2021, 9:38 a.m.
Message ID <differential-rev-PHID-DREV-vjtf66ompxstwiwjx3ej-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49846/
State Superseded
Headers show

Comments

phabricator - Oct. 1, 2021, 9:38 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




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

Patch

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