changeset 51080:09d60aed5f5d

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 15a50bfaeb79
children 5ffee3cff8de
files mercurial/revlog.py
diffstat 1 files changed, 13 insertions(+), 14 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
@@ -3461,7 +3461,7 @@
             )
             destrevlog.delta_config.delta_both_parents = delta_both_parents
 
-            with self.reading():
+            with self.reading(), destrevlog._writing(tr):
                 self._clone(
                     tr,
                     destrevlog,
@@ -3552,19 +3552,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)