diff --git a/hgext3rd/fbsparse.py b/hgext3rd/fbsparse.py --- a/hgext3rd/fbsparse.py +++ b/hgext3rd/fbsparse.py @@ -348,17 +348,20 @@ entry = commands.table['^diff'] entry[1].append(('s', 'sparse', None, 'only show changes in files in the sparse config')) - # wrap workingfilectx's data function to return the data for files - # outside the sparse checkout by fetching from the working copy parent. + def workingfilectxdata(orig, self): - if not util.safehasattr(self.repo(), 'sparsematch'): + try: + # Try lookup working copy first. return orig(self) - sparsematch = self.repo().sparsematch() - if sparsematch(self._path): - return orig(self) - else: - basectx = self._changectx._parents[0] - return basectx[self._path].data() + except IOError: + # Then try working copy parent if the file is outside sparse. + if util.safehasattr(self._repo, 'sparsematch'): + sparsematch = self._repo.sparsematch() + if not sparsematch(self._path): + basectx = self._changectx._parents[0] + return basectx[self._path].data() + raise + extensions.wrapfunction(context.workingfilectx, 'data', workingfilectxdata) # wrap trydiff to filter diffs if '--sparse' is set diff --git a/tests/test-sparse-rebase.t b/tests/test-sparse-rebase.t --- a/tests/test-sparse-rebase.t +++ b/tests/test-sparse-rebase.t @@ -24,5 +24,6 @@ temporarily included 1 file(s) in the sparse checkout for merging cleaned up 1 temporarily added file(s) from the sparse checkout rebasing 3:e7b3f00ed42e "D" (D tip) - abort: D@bbfdd6cb49aa: not found in manifest! - [255] + temporarily included 1 file(s) in the sparse checkout for merging + cleaned up 1 temporarily added file(s) from the sparse checkout + saved backup bundle to $TESTTMP/repo/.hg/strip-backup/dc0947a82db8-b8481714-rebase.hg (glob)