# HG changeset patch # User FUJIWARA Katsunori # Date 2017-07-02 17:52:40 # Node ID b7f6885cb0554e8ac653c165dfd3aa7ae22644eb # Parent 7367b76ef75c349a2bdae076ddc6ac66cf491bca dirstate: centralize _cwd handling into _cwd method Before this patch, immediate value is assigned to dirstate._cwd, if ui.forcecwd is specified at instantiation of dirstate. But this doesn't work as expected in some cases. For example, hgweb set ui.forcecwd after instantiation of repo object. If an extension touches repo.dirstate in its reposetup(), dirstate is instantiated without setting ui.forcecwd, and dirstate.getcwd() returns incorrect result. In addition to it, hgweb.__init__() can take already instantiated repo object, too. In this case, repo.dirstate might be already instantiated, even if all enabled extensions don't so in their own reposetup(). To avoid such issue, this patch centralizes _cwd handling into _cwd method. This issue can be reproduced by running test-hgweb-commands.t with fsmonitor-run-tests.py. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -83,10 +83,6 @@ class dirstate(object): # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is # UNC path pointing to root share (issue4557) self._rootdir = pathutil.normasprefix(root) - # internal config: ui.forcecwd - forcecwd = ui.config('ui', 'forcecwd') - if forcecwd: - self._cwd = forcecwd self._dirty = False self._dirtypl = False self._lastnormaltime = 0 @@ -299,6 +295,10 @@ class dirstate(object): @propertycache def _cwd(self): + # internal config: ui.forcecwd + forcecwd = self._ui.config('ui', 'forcecwd') + if forcecwd: + return forcecwd return pycompat.getcwd() def getcwd(self):