revlog: decouple caching from addrevision callback for addgroup
authorJoerg Sonnenberger <joerg@bec.de>
Wed, 20 Jan 2021 14:47:13 +0100
changeset 46373 711ba0f1057e
parent 46372 3e91d9978bec
child 46374 e92ca942ddca
revlog: decouple caching from addrevision callback for addgroup For changesets, it is useful to cache the content as it will almost always be processed afterwards. For manifests on the other hand, the content is often not used directly as there is a fast path for deltas. Explicitly disable the cache in exchangev2's manifest handling for that reason. Differential Revision: https://phab.mercurial-scm.org/D9847
mercurial/changegroup.py
mercurial/exchangev2.py
mercurial/interfaces/repository.py
mercurial/manifest.py
mercurial/revlog.py
mercurial/unionrepo.py
--- a/mercurial/changegroup.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/changegroup.py	Wed Jan 20 14:47:13 2021 +0100
@@ -334,6 +334,7 @@
                 deltas,
                 csmap,
                 trp,
+                alwayscache=True,
                 addrevisioncb=onchangelog,
                 duplicaterevisioncb=ondupchangelog,
             ):
--- a/mercurial/exchangev2.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/exchangev2.py	Wed Jan 20 14:47:13 2021 +0100
@@ -423,6 +423,7 @@
         iterrevisions(),
         linkrev,
         weakref.proxy(tr),
+        alwayscache=True,
         addrevisioncb=onchangeset,
         duplicaterevisioncb=ondupchangeset,
     )
--- a/mercurial/interfaces/repository.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/interfaces/repository.py	Wed Jan 20 14:47:13 2021 +0100
@@ -769,7 +769,13 @@
         ``nullid``, in which case the header from the delta can be ignored
         and the delta used as the fulltext.
 
+        ``alwayscache`` instructs the lower layers to cache the content of the
+        newly added revision, even if it needs to be explicitly computed.
+        This used to be the default when ``addrevisioncb`` was provided up to
+        Mercurial 5.8.
+
         ``addrevisioncb`` should be called for each node as it is committed.
+        ``duplicaterevisioncb`` should be called for each pre-existing node.
 
         ``maybemissingparents`` is a bool indicating whether the incoming
         data may reference parents/ancestor revisions that aren't present.
--- a/mercurial/manifest.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/manifest.py	Wed Jan 20 14:47:13 2021 +0100
@@ -1836,6 +1836,7 @@
         deltas,
         linkmapper,
         transaction,
+        alwayscache=False,
         addrevisioncb=None,
         duplicaterevisioncb=None,
     ):
@@ -1843,6 +1844,7 @@
             deltas,
             linkmapper,
             transaction,
+            alwayscache=alwayscache,
             addrevisioncb=addrevisioncb,
             duplicaterevisioncb=duplicaterevisioncb,
         )
--- a/mercurial/revlog.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/revlog.py	Wed Jan 20 14:47:13 2021 +0100
@@ -2375,6 +2375,7 @@
         deltas,
         linkmapper,
         transaction,
+        alwayscache=False,
         addrevisioncb=None,
         duplicaterevisioncb=None,
     ):
@@ -2475,7 +2476,7 @@
                     (baserev, delta),
                     ifh,
                     dfh,
-                    alwayscache=bool(addrevisioncb),
+                    alwayscache=alwayscache,
                     deltacomputer=deltacomputer,
                 )
 
--- a/mercurial/unionrepo.py	Fri Jan 15 01:58:59 2021 +0100
+++ b/mercurial/unionrepo.py	Wed Jan 20 14:47:13 2021 +0100
@@ -128,6 +128,7 @@
         deltas,
         linkmapper,
         transaction,
+        alwayscache=False,
         addrevisioncb=None,
         duplicaterevisioncb=None,
         maybemissingparents=False,