Mercurial > hg
diff hgext/fsmonitor/__init__.py @ 33386:5a9b4370bb3b
fsmonitor: centralize setup procedures for dirstate
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 10 Jul 2017 23:09:52 +0900 |
parents | 8bb4c69c4000 |
children | 68e9762a357b |
line wrap: on
line diff
--- a/hgext/fsmonitor/__init__.py Mon Jul 10 23:09:52 2017 +0900 +++ b/hgext/fsmonitor/__init__.py Mon Jul 10 23:09:52 2017 +0900 @@ -536,8 +536,8 @@ status.deleted + status.unknown) wctx.repo()._fsmonitorstate.set(clock, hashignore, notefiles) -def makedirstate(cls): - class fsmonitordirstate(cls): +def makedirstate(repo, dirstate): + class fsmonitordirstate(dirstate.__class__): def _fsmonitorinit(self, fsmonitorstate, watchmanclient): # _fsmonitordisable is used in paranoid mode self._fsmonitordisable = False @@ -558,14 +558,14 @@ self._fsmonitorstate.invalidate() return super(fsmonitordirstate, self).invalidate(*args, **kwargs) - return fsmonitordirstate + dirstate.__class__ = fsmonitordirstate + dirstate._fsmonitorinit(repo._fsmonitorstate, repo._watchmanclient) def wrapdirstate(orig, self): ds = orig(self) # only override the dirstate when Watchman is available for the repo if util.safehasattr(self, '_fsmonitorstate'): - ds.__class__ = makedirstate(ds.__class__) - ds._fsmonitorinit(self._fsmonitorstate, self._watchmanclient) + makedirstate(self, ds) return ds def extsetup(ui): @@ -701,8 +701,8 @@ # at this point since fsmonitorstate wasn't present, repo.dirstate is # not a fsmonitordirstate dirstate = repo.dirstate - dirstate.__class__ = makedirstate(dirstate.__class__) - dirstate._fsmonitorinit(fsmonitorstate, client) + makedirstate(repo, dirstate) + # invalidate property cache, but keep filecache which contains the # wrapped dirstate object del repo.unfiltered().__dict__['dirstate']