changelog: add a `changes` property on `changelogrevision`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 15 Sep 2020 15:37:32 +0200
changeset 45570 9a3563b46f52
parent 45569 64d18e9e8508
child 45571 7543b5072e84
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.
mercurial/changelog.py
--- 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]: