[PATCH memctx-cache] memctx: always use cache for filectxfn

Sean Farley sean at farley.io
Sat Jun 10 23:01:23 UTC 2017


# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1497135618 25200
#      Sat Jun 10 16:00:18 2017 -0700
# Branch memctx-cache
# Node ID 12f2faa6019f497ba08960564cfceff80250e75a
# Parent  7e9d0d8ff938dcf8ca193c17db5321a05a48e718
memctx: always use cache for filectxfn

I don't see a downside to doing this unless I'm missing something.

diff --git a/mercurial/context.py b/mercurial/context.py
index 7ce34af..348c13c 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2103,18 +2103,19 @@ class memctx(committablectx):
         self._files = files
         if branch is not None:
             self._extra['branch'] = encoding.fromlocal(branch)
         self.substate = {}
 
+        self._filectxfn = filectxfn
         if isinstance(filectxfn, patch.filestore):
             self._filectxfn = memfilefrompatch(filectxfn)
         elif not callable(filectxfn):
             # if store is not callable, wrap it in a function
             self._filectxfn = memfilefromctx(filectxfn)
-        else:
-            # memoizing increases performance for e.g. vcs convert scenarios.
-            self._filectxfn = makecachingfilectxfn(filectxfn)
+
+        # memoizing increases performance for e.g. vcs convert scenarios.
+        self._filectxfn = makecachingfilectxfn(filectxfn)
 
         if editor:
             self._text = editor(self._repo, self, [])
             self._repo.savecommitmessage(self._text)
 


More information about the Mercurial-devel mailing list