Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
47515:c94d3ff46fd5 | 47516:b8ffe85e399b |
---|---|
33 _decompress = zlib.decompress | 33 _decompress = zlib.decompress |
34 | 34 |
35 | 35 |
36 # a special value used internally for `size` if the file come from the other parent | 36 # a special value used internally for `size` if the file come from the other parent |
37 FROM_P2 = -2 | 37 FROM_P2 = -2 |
38 | |
39 # a special value used internally for `size` if the file is modified/merged/added | |
40 NONNORMAL = -1 | |
38 | 41 |
39 | 42 |
40 class dirstatetuple(object): | 43 class dirstatetuple(object): |
41 """represent a dirstate entry | 44 """represent a dirstate entry |
42 | 45 |
98 Should only be set if a merge is in progress in the dirstate | 101 Should only be set if a merge is in progress in the dirstate |
99 """ | 102 """ |
100 return self._size == FROM_P2 | 103 return self._size == FROM_P2 |
101 | 104 |
102 @property | 105 @property |
106 def from_p2_removed(self): | |
107 """True if the file has been removed, but was "from_p2" initially | |
108 | |
109 This property seems like an abstraction leakage and should probably be | |
110 dealt in this class (or maybe the dirstatemap) directly. | |
111 """ | |
112 return self._state == b'r' and self._size == FROM_P2 | |
113 | |
114 @property | |
103 def removed(self): | 115 def removed(self): |
104 """True if the file has been removed""" | 116 """True if the file has been removed""" |
105 return self._state == b'r' | 117 return self._state == b'r' |
118 | |
119 @property | |
120 def merged_removed(self): | |
121 """True if the file has been removed, but was "merged" initially | |
122 | |
123 This property seems like an abstraction leakage and should probably be | |
124 dealt in this class (or maybe the dirstatemap) directly. | |
125 """ | |
126 return self._state == b'r' and self._size == NONNORMAL | |
106 | 127 |
107 def v1_state(self): | 128 def v1_state(self): |
108 """return a "state" suitable for v1 serialization""" | 129 """return a "state" suitable for v1 serialization""" |
109 return self._state | 130 return self._state |
110 | 131 |