diff --git a/mercurial/context.py b/mercurial/context.py
index e465689fa74d111b56208dc47e8b9ce7f46b2267_bWVyY3VyaWFsL2NvbnRleHQucHk=..f071b18e138252daad4709d10a73562f59b2b7bb_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644
--- 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,