D6308: context: check file exists before getting data from _wrappedctx
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Apr 24 13:09:57 EDT 2019
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
overlayworkingctx class is used to do in-memory merging. The data() function of
that class has logic to look for data() in the wrappedctx if the file data in
cache is empty and if the file is dirty. This assumes that if a file is dirty
and cache has empty data for it, it will exists in the _wrappedctx.
However this assumption can be False in case when we are merging a file which is
empty in destination. In these cases, the backup file 'foo.orig' created by our
internal merge algorithms will be empty, however it won't be present in
_wrappedctx. This case will lead us to error like the one this patch is fixing.
Let's check whether the file exists or not in the wrappedctx before getting data
from that. If it does not exists in wrappedctx, we will return whatever data the
cache of overlayworkingctx has.
diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
@@ -797,5 +797,9 @@
$ hg rebase -r . -d 1 --config ui.merge=internal:merge3
rebasing 2:376089bb8d86 "remove the whitespace again" (tip)
- abort: foo.orig at bb96b8f33f2a: not found in manifest!
+ hit merge conflicts; re-running rebase without in-memory merge
+ rebasing 2:376089bb8d86 "remove the whitespace again" (tip)
+ merging foo
+ warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+ unresolved conflicts (see hg resolve, then hg rebase --continue)
diff --git a/mercurial/context.py b/mercurial/context.py
@@ -1826,9 +1826,14 @@
+ elif path in self._wrappedctx:
# Must fallback here, too, because we only set flags.
+ # the file was not present in parent, this can be an empty
+ # backupfile created during merge. Let's return what we have
+ # in cache
+ return self._cache[path]['data']
raise error.ProgrammingError("No such file or directory: %s" %
To: pulkit, #hg-reviewers
More information about the Mercurial-devel