Mercurial > hg
comparison mercurial/changelog.py @ 45570:9a3563b46f52
changelog: add a `changes` property on `changelogrevision`
For the sidedata storage we are moving toward "all in one" block containing the
equivalent of a "ChangingFiles" instance. We do various refactoring beforehand
to prepare the usage of theses new data in the code.
Since the object use slots, the "property cache" tricks cannot be used, and we
cache the value manually.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 15 Sep 2020 15:37:32 +0200 |
parents | 64d18e9e8508 |
children | 7543b5072e84 |
comparison
equal
deleted
inserted
replaced
45569:64d18e9e8508 | 45570:9a3563b46f52 |
---|---|
214 __slots__ = ( | 214 __slots__ = ( |
215 '_offsets', | 215 '_offsets', |
216 '_text', | 216 '_text', |
217 '_sidedata', | 217 '_sidedata', |
218 '_cpsd', | 218 '_cpsd', |
219 '_changes', | |
219 ) | 220 ) |
220 | 221 |
221 def __new__(cls, text, sidedata, cpsd): | 222 def __new__(cls, text, sidedata, cpsd): |
222 if not text: | 223 if not text: |
223 return _changelogrevision(extra=_defaultextra) | 224 return _changelogrevision(extra=_defaultextra) |
250 | 251 |
251 self._offsets = (nl1, nl2, nl3, doublenl) | 252 self._offsets = (nl1, nl2, nl3, doublenl) |
252 self._text = text | 253 self._text = text |
253 self._sidedata = sidedata | 254 self._sidedata = sidedata |
254 self._cpsd = cpsd | 255 self._cpsd = cpsd |
256 self._changes = None | |
255 | 257 |
256 return self | 258 return self |
257 | 259 |
258 @property | 260 @property |
259 def manifest(self): | 261 def manifest(self): |
297 raw = self._rawextra | 299 raw = self._rawextra |
298 if raw is None: | 300 if raw is None: |
299 return _defaultextra | 301 return _defaultextra |
300 | 302 |
301 return decodeextra(raw) | 303 return decodeextra(raw) |
304 | |
305 @property | |
306 def changes(self): | |
307 if self._changes is not None: | |
308 return self._changes | |
309 changes = metadata.ChangingFiles( | |
310 touched=self.files or (), | |
311 added=self.filesadded or (), | |
312 removed=self.filesremoved or (), | |
313 p1_copies=self.p1copies or {}, | |
314 p2_copies=self.p2copies or {}, | |
315 ) | |
316 self._changes = changes | |
317 return changes | |
302 | 318 |
303 @property | 319 @property |
304 def files(self): | 320 def files(self): |
305 off = self._offsets | 321 off = self._offsets |
306 if off[2] == off[3]: | 322 if off[2] == off[3]: |