# HG changeset patch # User Pulkit Goyal # Date 2019-04-24 16:42:43 # Node ID 14589f1989e91a455597cee754ae8587f3725394 # Parent 818051048c2e59bfe4300d91945d253a9ef22af6 context: check file exists before getting data from _wrappedctx 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 only fallback to getting data from wrappedctx if cache has 'None' as data. Differential Revision: https://phab.mercurial-scm.org/D6308 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1824,7 +1824,7 @@ class overlayworkingctx(committablectx): def data(self, path): if self.isdirty(path): if self._cache[path]['exists']: - if self._cache[path]['data']: + if self._cache[path]['data'] is not None: return self._cache[path]['data'] else: # Must fallback here, too, because we only set flags. diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t --- a/tests/test-rebase-inmemory.t +++ b/tests/test-rebase-inmemory.t @@ -797,5 +797,9 @@ Test rebasing when the file we are mergi $ hg rebase -r . -d 1 --config ui.merge=internal:merge3 rebasing 2:fb62b706688e "add b to foo" (tip) merging foo - abort: foo.orig@e780cf6f9041: not found in manifest! - [255] + hit merge conflicts; re-running rebase without in-memory merge + rebasing 2:fb62b706688e "add b to foo" (tip) + merging foo + warning: conflicts while merging foo! (edit, then use 'hg resolve --mark') + unresolved conflicts (see hg resolve, then hg rebase --continue) + [1]