From c3ea6021e1953d37326bf051954cdcd368d51c97 Mon Sep 17 00:00:00 2001 From: Tony Tung Date: Fri, 22 Apr 2016 09:51:07 -0700 Subject: [PATCH] [manifestdiskcache] set up manifestdiskcache without subclassing repo Summary: It seems subclassing repo can cause problems when a repo is created before the extension is loaded. This circumvents the issue by directly modifying the data structures in the repo object as needed. Test Plan: passed test-manifestdiskcache.t Reviewers: #sourcecontrol, mjpieters Reviewed By: mjpieters Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.fb.com/D3208899 Tasks: 10836392 Signature: t1:3208899:1461336232:617f8b9258f23ba0b34627785dc2cb4bddcee313 --- manifestdiskcache.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manifestdiskcache.py b/manifestdiskcache.py index 9e67c1c8c2..3b2e61e665 100644 --- a/manifestdiskcache.py +++ b/manifestdiskcache.py @@ -311,13 +311,11 @@ class manifestwithdc(manifest.manifest): "prunemanifestdiskcache"]) subprocess.Popen(cmd, close_fds=True) -@replaceclass(localrepo, 'localrepository') -class repowithmdc(localrepo.localrepository): - def _applyopenerreqs(self): - super(repowithmdc, self)._applyopenerreqs() - self.svfs.options[CONFIG_KEY] = self.ui.configbool( +def reposetup(ui, repo): + if isinstance(repo, localrepo.localrepository): + repo.svfs.options[CONFIG_KEY] = repo.ui.configbool( CONFIG_KEY, 'enabled', False) - self.svfs.options[REPO_ROOT_KEY] = self.root + repo.svfs.options[REPO_ROOT_KEY] = repo.root def _reposnames(ui): # '' is local repo. This also defines an order precedence for master.