[PATCH] fsmonitor: do not nuke dirstate filecache

Jun Wu quark at fb.com
Sat May 6 23:36:47 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1494113784 25200
#      Sat May 06 16:36:24 2017 -0700
# Node ID 7e038d1911a6472647d27d73f9de30923f51c3d3
# Parent  31f42e683321f225eb9c306f8d4b3a9e8d82a1da
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 7e038d1911a6
fsmonitor: do not nuke dirstate filecache

In the future, chg may prefill repo's dirstate filecache so it's valuable
and should be kept. Previously we drop both filecache and property cache for
dirstate during fsmonitor reposetup, this patch changes it to only drop
property cache but keep the filecache.

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -693,9 +693,11 @@ def reposetup(ui, repo):
         # at this point since fsmonitorstate wasn't present, repo.dirstate is
         # not a fsmonitordirstate
-        repo.dirstate.__class__ = makedirstate(repo.dirstate.__class__)
-        # nuke the dirstate so that _fsmonitorinit and subsequent configuration
-        # changes take effect on it
-        del repo._filecache['dirstate']
-        delattr(repo.unfiltered(), 'dirstate')
+        dirstate = repo.dirstate
+        dirstate.__class__ = makedirstate(dirstate.__class__)
+        dirstate._fsmonitorinit(fsmonitorstate, client)
+        # invalidate property cache, but keep filecache which contains the
+        # wrapped dirstate object
+        del repo.unfiltered().__dict__['dirstate']
+        assert dirstate is repo._filecache['dirstate'].obj
 
         class fsmonitorrepo(repo.__class__):


More information about the Mercurial-devel mailing list