changeset 51114:315c74911993 stable

revlog: avoid opening and closing the file for each cloned revision The previous code was flushing files after each new revision, slowing things down. For exemple, with this change, the evolve repository can run `hg debugupgraderepo --run --optimize re-delta-parent` in about 3.4s instead of 4.5 seconds.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 14 Oct 2023 03:24:13 +0200
parents 2dec23658969
children c083d9776cb2
files mercurial/revlog.py
diffstat 1 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Oct 13 23:21:46 2023 +0200
+++ b/mercurial/revlog.py	Sat Oct 14 03:24:13 2023 +0200
@@ -3196,14 +3196,15 @@
 
             destrevlog._deltabothparents = forcedeltabothparents or oldamd
 
-            self._clone(
-                tr,
-                destrevlog,
-                addrevisioncb,
-                deltareuse,
-                forcedeltabothparents,
-                sidedata_helpers,
-            )
+            with self.reading(), destrevlog._writing(tr):
+                self._clone(
+                    tr,
+                    destrevlog,
+                    addrevisioncb,
+                    deltareuse,
+                    forcedeltabothparents,
+                    sidedata_helpers,
+                )
 
         finally:
             destrevlog._lazydelta = oldlazydelta
@@ -3288,19 +3289,18 @@
                     )
                     flags = flags | new_flags[0] & ~new_flags[1]
 
-                with destrevlog._writing(tr):
-                    destrevlog._addrevision(
-                        node,
-                        rawtext,
-                        tr,
-                        linkrev,
-                        p1,
-                        p2,
-                        flags,
-                        cachedelta,
-                        deltacomputer=deltacomputer,
-                        sidedata=sidedata,
-                    )
+                destrevlog._addrevision(
+                    node,
+                    rawtext,
+                    tr,
+                    linkrev,
+                    p1,
+                    p2,
+                    flags,
+                    cachedelta,
+                    deltacomputer=deltacomputer,
+                    sidedata=sidedata,
+                )
 
             if addrevisioncb:
                 addrevisioncb(self, rev, node)