Mercurial > hg
diff mercurial/pure/parsers.py @ 47516:b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Lets start to define and use more semantic property. These two might be a bit
too low level and could be shaved off later, however this seems an improvement
for now.
Differential Revision: https://phab.mercurial-scm.org/D10958
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 03 Jul 2021 20:34:09 +0200 |
parents | c94d3ff46fd5 |
children | 28632eb3ca3e |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Sat Jul 03 04:18:54 2021 +0200 +++ b/mercurial/pure/parsers.py Sat Jul 03 20:34:09 2021 +0200 @@ -36,6 +36,9 @@ # a special value used internally for `size` if the file come from the other parent FROM_P2 = -2 +# a special value used internally for `size` if the file is modified/merged/added +NONNORMAL = -1 + class dirstatetuple(object): """represent a dirstate entry @@ -100,10 +103,28 @@ return self._size == FROM_P2 @property + def from_p2_removed(self): + """True if the file has been removed, but was "from_p2" initially + + This property seems like an abstraction leakage and should probably be + dealt in this class (or maybe the dirstatemap) directly. + """ + return self._state == b'r' and self._size == FROM_P2 + + @property def removed(self): """True if the file has been removed""" return self._state == b'r' + @property + def merged_removed(self): + """True if the file has been removed, but was "merged" initially + + This property seems like an abstraction leakage and should probably be + dealt in this class (or maybe the dirstatemap) directly. + """ + return self._state == b'r' and self._size == NONNORMAL + def v1_state(self): """return a "state" suitable for v1 serialization""" return self._state