mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
sparse: don't crash in non-sparse repositories
Summary: Update the workingfilectxdata() to check that this is actually a sparse repository before trying to call repo.sparsematch() Test Plan: Update the test to confirm that "hg diff" works instead of crashes now. Reviewers: #fbhgext, mbthomas Reviewed By: #fbhgext, mbthomas Differential Revision: https://phab.mercurial-scm.org/D1023
This commit is contained in:
parent
04525b995f
commit
db0d906e58
@ -348,6 +348,8 @@ def _setupdiff(ui):
|
||||
# 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)
|
||||
|
@ -32,6 +32,10 @@ Now create a shared working copy that is not sparse.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user