overlayctx: build a memctx that can access non touched files
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 01 Feb 2025 13:04:32 +0100
changeset 52721 f071b18e1382
parent 52716 e465689fa74d
child 52722 0cf5f9312b33
overlayctx: build a memctx that can access non touched files So far, the memctx was very optimized for being committed: so it did not need to access any untouched files. However the way we uses it in evolve to diff against more arbitrary changes requires to be able to access to any file content as any other ctx. This is now the case.
mercurial/context.py
--- a/mercurial/context.py	Sat Jan 25 23:49:24 2025 +0100
+++ b/mercurial/context.py	Sat Feb 01 13:04:32 2025 +0100
@@ -2542,7 +2542,9 @@
         files = self.files()
 
         def getfile(repo, memctx, path):
-            if self._cache[path][b'exists']:
+            if path not in self._cache:
+                return self.filectx(path)
+            elif self._cache[path][b'exists']:
                 return memfilectx(
                     repo,
                     memctx,