mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
chgserver: use global ui instead of repo ui for dispatch.request.ui
Before this patch, chgserver will use repo ui as dispatch.request.ui, while req.ui is designed to be global ui without repo config. Passing repo ui as dispatch.request.ui leads to repo.ui being incorrect, which can lead to unwanted results. For example, if the repo config has [extensions], it could affect which localrepository.featuresetupfuncs get executed and the repo may have an incorrect list of supported requirements. This patch changes _renewui to return both global ui and repo ui. The global ui is passed to req.ui, and the repo ui is used to calculate confighash. It will make chg pass test-largefiles-misc.t and test-requires.t, which are both related to repo requirements.
This commit is contained in:
parent
f6dffaf6bd
commit
7aa59d1e65
@ -267,7 +267,7 @@ def _newchgui(srcui, csystem):
|
||||
|
||||
return chgui(srcui)
|
||||
|
||||
def _renewui(srcui, args=None):
|
||||
def _loadnewui(srcui, args=None):
|
||||
if not args:
|
||||
args = []
|
||||
|
||||
@ -277,14 +277,7 @@ def _renewui(srcui, args=None):
|
||||
if util.safehasattr(srcui, '_csystem'):
|
||||
newui._csystem = srcui._csystem
|
||||
|
||||
# load wd and repo config, copied from dispatch.py
|
||||
cwds = dispatch._earlygetopt(['--cwd'], args)
|
||||
cwd = cwds and os.path.realpath(cwds[-1]) or None
|
||||
rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
|
||||
path, newui = dispatch._getlocal(newui, rpath, wd=cwd)
|
||||
|
||||
# internal config: extensions.chgserver
|
||||
# copy it. it can only be overrided from command line.
|
||||
newui.setconfig('extensions', 'chgserver',
|
||||
srcui.config('extensions', 'chgserver'), '--config')
|
||||
|
||||
@ -301,7 +294,15 @@ def _renewui(srcui, args=None):
|
||||
# ui.configsource returns 'none' by default
|
||||
source = ''
|
||||
newui.setconfig(section, name, value, source)
|
||||
return newui
|
||||
|
||||
# load wd and repo config, copied from dispatch.py
|
||||
args = args[:]
|
||||
cwds = dispatch._earlygetopt(['--cwd'], args)
|
||||
cwd = cwds and os.path.realpath(cwds[-1]) or None
|
||||
rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
|
||||
path, newlui = dispatch._getlocal(newui, rpath, wd=cwd)
|
||||
|
||||
return (newui, newlui)
|
||||
|
||||
class channeledsystem(object):
|
||||
"""Propagate ui.system() request in the following format:
|
||||
@ -450,13 +451,13 @@ class chgcmdserver(commandserver.server):
|
||||
"""
|
||||
args = self._readlist()
|
||||
try:
|
||||
self.ui = _renewui(self.ui, args)
|
||||
self.ui, lui = _loadnewui(self.ui, args)
|
||||
except error.ParseError as inst:
|
||||
dispatch._formatparse(self.ui.warn, inst)
|
||||
self.ui.flush()
|
||||
self.cresult.write('exit 255')
|
||||
return
|
||||
newhash = hashstate.fromui(self.ui, self.hashstate.mtimepaths)
|
||||
newhash = hashstate.fromui(lui, self.hashstate.mtimepaths)
|
||||
insts = []
|
||||
if newhash.mtimehash != self.hashstate.mtimehash:
|
||||
addr = _hashaddress(self.baseaddress, self.hashstate.confighash)
|
||||
@ -533,7 +534,7 @@ class chgcmdserver(commandserver.server):
|
||||
|
||||
if set(['HGPLAIN', 'HGPLAINEXCEPT']) & diffkeys:
|
||||
# reload config so that ui.plain() takes effect
|
||||
self.ui = _renewui(self.ui)
|
||||
self.ui, _lui = _loadnewui(self.ui)
|
||||
|
||||
_clearenvaliases(commands.table)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user