diff --git a/hgext3rd/sparse.py b/hgext3rd/sparse.py --- a/hgext3rd/sparse.py +++ b/hgext3rd/sparse.py @@ -348,6 +348,8 @@ # 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'): + return orig(self) sparsematch = self.repo().sparsematch() if sparsematch(self._path): return orig(self) diff --git a/tests/test-sparse-notsparse.t b/tests/test-sparse-notsparse.t --- a/tests/test-sparse-notsparse.t +++ b/tests/test-sparse-notsparse.t @@ -32,6 +32,10 @@ Make sure "hg diff" works in the non-sparse working directory. $ echo z >> file1 - $ hg diff |& grep -E 'Unknown exception|AttributeError' - ** Unknown exception encountered with possibly-broken third-party extension sparse - AttributeError: 'localrepository' object has no attribute 'sparsematch' + $ hg diff + diff -r 1f02e070b36e file1 + --- a/file1 Thu Jan 01 00:00:00 1970 +0000 + +++ b/file1 Thu Jan 01 00:00:00 1970 +0000 + @@ -1,1 +1,2 @@ + a + +z