comparison mercurial/dirstate.py @ 33215:b7f6885cb055

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 03 Jul 2017 02:52:40 +0900
parents 7ad95626f6a7
children fb320398a21c
comparison
equal deleted inserted replaced
33214:7367b76ef75c 33215:b7f6885cb055
81 self._validate = validate 81 self._validate = validate
82 self._root = root 82 self._root = root
83 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is 83 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is
84 # UNC path pointing to root share (issue4557) 84 # UNC path pointing to root share (issue4557)
85 self._rootdir = pathutil.normasprefix(root) 85 self._rootdir = pathutil.normasprefix(root)
86 # internal config: ui.forcecwd
87 forcecwd = ui.config('ui', 'forcecwd')
88 if forcecwd:
89 self._cwd = forcecwd
90 self._dirty = False 86 self._dirty = False
91 self._dirtypl = False 87 self._dirtypl = False
92 self._lastnormaltime = 0 88 self._lastnormaltime = 0
93 self._ui = ui 89 self._ui = ui
94 self._filecache = {} 90 self._filecache = {}
297 else: 293 else:
298 return fallback 294 return fallback
299 295
300 @propertycache 296 @propertycache
301 def _cwd(self): 297 def _cwd(self):
298 # internal config: ui.forcecwd
299 forcecwd = self._ui.config('ui', 'forcecwd')
300 if forcecwd:
301 return forcecwd
302 return pycompat.getcwd() 302 return pycompat.getcwd()
303 303
304 def getcwd(self): 304 def getcwd(self):
305 '''Return the path from which a canonical path is calculated. 305 '''Return the path from which a canonical path is calculated.
306 306