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.
--- a/mercurial/changelog.py Tue Sep 22 10:27:35 2020 +0200
+++ b/mercurial/changelog.py Tue Sep 15 15:37:32 2020 +0200
@@ -216,6 +216,7 @@
'_text',
'_sidedata',
'_cpsd',
+ '_changes',
)
def __new__(cls, text, sidedata, cpsd):
@@ -252,6 +253,7 @@
self._text = text
self._sidedata = sidedata
self._cpsd = cpsd
+ self._changes = None
return self
@@ -301,6 +303,20 @@
return decodeextra(raw)
@property
+ def changes(self):
+ if self._changes is not None:
+ return self._changes
+ changes = metadata.ChangingFiles(
+ touched=self.files or (),
+ added=self.filesadded or (),
+ removed=self.filesremoved or (),
+ p1_copies=self.p1copies or {},
+ p2_copies=self.p2copies or {},
+ )
+ self._changes = changes
+ return changes
+
+ @property
def files(self):
off = self._offsets
if off[2] == off[3]: