diff mercurial/interfaces/repository.py @ 51812:421c9b3f2f4e

commit: set whole manifest entries at once (node with its associated flags) Add a new function manifest.set that sets whole manifest entries at once, so the caller doesn't have to do two separate operations: m[p] = n m.set_flags(f) becomes: m.set(p, n, f) This obviously saves an extra lookup by path, and it also lets the underlying manifest implementation to be more efficient as it doesn't have to deal with partially-specified entries. It makes the interaction conceptually simpler, as well, since we don't have to go through an intermediate state of incorrect partially-written entry. (the real motivation for this change is an alternative manifest implementation where we batch pending writes, and dealing with fully defined entries makes the batching logic muchsimpler while avoiding slowdown due to alternating writes and reads)
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 01 Aug 2024 13:38:31 +0100
parents 4a8bb136ee77
children ca4208713875
line wrap: on
line diff
--- a/mercurial/interfaces/repository.py	Thu Aug 01 11:43:10 2024 -0400
+++ b/mercurial/interfaces/repository.py	Thu Aug 01 13:38:31 2024 +0100
@@ -1021,6 +1021,12 @@
 
     __bool__ = __nonzero__
 
+    def set(path, node, flags):
+        """Define the node value and flags for a path in the manifest.
+
+        Equivalent to __setitem__ followed by setflag, but can be more efficient.
+        """
+
     def __setitem__(path, node):
         """Define the node value for a path in the manifest.