HomePhabricator

context: check file exists before getting data from _wrappedctx

Authored by pulkit.

Description

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