Patchwork fsmonitor: do not nuke dirstate filecache

login
register
mail settings
Submitter Jun Wu
Date May 6, 2017, 11:36 p.m.
Message ID <7e038d1911a6472647d2.1494113807@x1c>
Download mbox | patch
Permalink /patch/20494/
State Accepted
Headers show

Comments

Jun Wu - May 6, 2017, 11:36 p.m.
# HG changeset patch
# User Jun Wu <quark@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.
Augie Fackler - May 8, 2017, 7:29 p.m.
On Sat, May 06, 2017 at 04:36:47PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@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

queued, thanks

Patch

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__):