# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1738411472 -3600
#      Sat Feb 01 13:04:32 2025 +0100
# Node ID f071b18e138252daad4709d10a73562f59b2b7bb
# Parent  e465689fa74d111b56208dc47e8b9ce7f46b2267
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.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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,