fsmonitor: avoid needless instantiation of dirstate
Using repo.local() instead of util.safehasattr(repo, 'dirstate') also
avoids executing setup procedures for remote repository (including
statichttprepo).
This is reason why this patch also removes a part of subsequent
comment, and try/except for AttributeError at accessing to repo.wvfs.
--- a/hgext/fsmonitor/__init__.py Mon Jul 10 23:09:51 2017 +0900
+++ b/hgext/fsmonitor/__init__.py Mon Jul 10 23:09:52 2017 +0900
@@ -677,16 +677,12 @@
'extension and has been disabled.\n') % ext)
return
- if util.safehasattr(repo, 'dirstate'):
- # We don't work with subrepos either. Note that we can get passed in
- # e.g. a statichttprepo, which throws on trying to access the substate.
- # XXX This sucks.
- try:
- # if repo[None].substate can cause a dirstate parse, which is too
- # slow. Instead, look for a file called hgsubstate,
- if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'):
- return
- except AttributeError:
+ if repo.local():
+ # We don't work with subrepos either.
+ #
+ # if repo[None].substate can cause a dirstate parse, which is too
+ # slow. Instead, look for a file called hgsubstate,
+ if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'):
return
fsmonitorstate = state.state(repo)