comparison mercurial/context.py @ 42193:14589f1989e9 stable

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
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 24 Apr 2019 19:42:43 +0300
parents 5382d8f8530b
children cdcebc897529
comparison
equal deleted inserted replaced
42192:818051048c2e 42193:14589f1989e9
1822 util.clearcachedproperty(self, '_manifest') 1822 util.clearcachedproperty(self, '_manifest')
1823 1823
1824 def data(self, path): 1824 def data(self, path):
1825 if self.isdirty(path): 1825 if self.isdirty(path):
1826 if self._cache[path]['exists']: 1826 if self._cache[path]['exists']:
1827 if self._cache[path]['data']: 1827 if self._cache[path]['data'] is not None:
1828 return self._cache[path]['data'] 1828 return self._cache[path]['data']
1829 else: 1829 else:
1830 # Must fallback here, too, because we only set flags. 1830 # Must fallback here, too, because we only set flags.
1831 return self._wrappedctx[path].data() 1831 return self._wrappedctx[path].data()
1832 else: 1832 else: