comparison mercurial/pure/parsers.py @ 47895:22c39f8acf78

dirstate-item: feed more information to `__init__` Instead of processing the "rich" value at the `dirstatemap` level, we can now directly pass them to the DirstateItem object. This will make the object free to store whatever its want and to implements it logic whatever its want. For now… we simply process the flag and store the same good old value. However this pave the way for doing things differently once the rest of dirstatemap code is updated. Nobody call this code yet. Differential Revision: https://phab.mercurial-scm.org/D11320
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 16 Jul 2021 16:52:53 +0200
parents 3853e6ee160d
children c0d6a59a7704
comparison
equal deleted inserted replaced
47894:226c7dbeea11 47895:22c39f8acf78
59 _state = attr.ib() 59 _state = attr.ib()
60 _mode = attr.ib() 60 _mode = attr.ib()
61 _size = attr.ib() 61 _size = attr.ib()
62 _mtime = attr.ib() 62 _mtime = attr.ib()
63 63
64 def __init__(self, state, mode, size, mtime): 64 def __init__(
65 self._state = state 65 self,
66 self._mode = mode 66 wc_tracked=False,
67 self._size = size 67 p1_tracked=False,
68 self._mtime = mtime 68 p2_tracked=False,
69 merged=False,
70 clean_p1=False,
71 clean_p2=False,
72 possibly_dirty=False,
73 parentfiledata=None,
74 ):
75 if merged and (clean_p1 or clean_p2):
76 msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`'
77 raise error.ProgrammingError(msg)
78
79 self._state = None
80 self._mode = 0
81 self._size = NONNORMAL
82 self._mtime = AMBIGUOUS_TIME
83 if not (p1_tracked or p2_tracked or wc_tracked):
84 pass # the object has no state to record
85 elif merged:
86 self._state = b'm'
87 self._size = FROM_P2
88 self._mtime = AMBIGUOUS_TIME
89 elif not (p1_tracked or p2_tracked) and wc_tracked:
90 self._state = b'a'
91 self._size = NONNORMAL
92 self._mtime = AMBIGUOUS_TIME
93 elif (p1_tracked or p2_tracked) and not wc_tracked:
94 self._state = b'r'
95 self._size = 0
96 self._mtime = 0
97 elif clean_p2 and wc_tracked:
98 self._state = b'n'
99 self._size = FROM_P2
100 self._mtime = AMBIGUOUS_TIME
101 elif not p1_tracked and p2_tracked and wc_tracked:
102 self._state = b'n'
103 self._size = FROM_P2
104 self._mtime = AMBIGUOUS_TIME
105 elif possibly_dirty:
106 self._state = b'n'
107 self._size = NONNORMAL
108 self._mtime = AMBIGUOUS_TIME
109 elif wc_tracked:
110 # this is a "normal" file
111 if parentfiledata is None:
112 msg = b'failed to pass parentfiledata for a normal file'
113 raise error.ProgrammingError(msg)
114 self._state = b'n'
115 self._mode = parentfiledata[0]
116 self._size = parentfiledata[1]
117 self._mtime = parentfiledata[2]
118 else:
119 assert False, 'unreachable'
69 120
70 @classmethod 121 @classmethod
71 def from_v1_data(cls, state, mode, size, mtime): 122 def from_v1_data(cls, state, mode, size, mtime):
72 """Build a new DirstateItem object from V1 data 123 """Build a new DirstateItem object from V1 data
73 124
74 Since the dirstate-v1 format is frozen, the signature of this function 125 Since the dirstate-v1 format is frozen, the signature of this function
75 is not expected to change, unlike the __init__ one. 126 is not expected to change, unlike the __init__ one.
76 """ 127 """
77 return cls( 128 instance = cls()
78 state=state, 129 instance._state = state
79 mode=mode, 130 instance._mode = mode
80 size=size, 131 instance._size = size
81 mtime=mtime, 132 instance._mtime = mtime
82 ) 133 return instance
83 134
84 def set_possibly_dirty(self): 135 def set_possibly_dirty(self):
85 """Mark a file as "possibly dirty" 136 """Mark a file as "possibly dirty"
86 137
87 This means the next status call will have to actually check its content 138 This means the next status call will have to actually check its content