# HG changeset patch # User Pierre-Yves David # Date 2021-09-29 00:37:24 # Node ID 6a78715e56c85c12ba8423de95c2639c0d7df7f3 # Parent 596510cd2b1200adbc5843f6caee2bb8a32fb8cf 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 diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -332,6 +332,13 @@ class dirstate(object): 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