Patchwork [4,of,6,V2] fsmonitor: avoid needless instantiation of dirstate

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 10, 2017, 2:18 p.m.
Message ID <65cdc2a0e356d131cd66.1499696297@speaknoevil>
Download mbox | patch
Permalink /patch/22203/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - July 10, 2017, 2:18 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1499695792 -32400
#      Mon Jul 10 23:09:52 2017 +0900
# Node ID 65cdc2a0e356d131cd6675316adbb9d4b9a06845
# Parent  826ccec0e5c33bedeb95f6f60b397e3565b209ec
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.

Patch

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -677,16 +677,12 @@  def reposetup(ui, repo):
                       '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)