##// END OF EJS Templates
config: gather the path to edit through rcutil...
config: gather the path to edit through rcutil Using the common logic helps to reduce potential error when it changes

File last commit:

r53313:0a81f3ef default
r53324:8c509a70 default
Show More
test-config-env.py
61 lines | 1.3 KiB | text/x-python | PythonLexer
/ tests / test-config-env.py
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 # Test the config layer generated by environment variables
import os
from mercurial import (
encoding,
Martin von Zweigbergk
tests: make test-config-env.py a little less hacky...
r44324 extensions,
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 ui as uimod,
Matt Harbison
tests: print Unix style paths in *.py tests...
r31857 util,
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 )
config: move `rcutil` module under a new `mercurial.configuration` module...
r53313 from mercurial.configuration import rcutil
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.utils import procutil
Yuya Nishihara
procutil: bulk-replace util.std* to point to new module
r37137
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 testtmp = encoding.environ[b'TESTTMP']
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Raphaël Gomès
black: format the codebase with 23.3.0...
r52596
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 # prepare hgrc files
def join(name):
return os.path.join(testtmp, name)
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 with open(join(b'sysrc'), 'wb') as f:
f.write(b'[ui]\neditor=e0\n[pager]\npager=p0\n')
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 with open(join(b'userrc'), 'wb') as f:
f.write(b'[ui]\neditor=e1')
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Raphaël Gomès
black: format the codebase with 23.3.0...
r52596
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 # replace rcpath functions so they point to the files above
def systemrcpath():
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 return [join(b'sysrc')]
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 def userrcpath():
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 return [join(b'userrc')]
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
ui: add the ability to apply `defaultrc` configs from resources...
r44483 extensions.wrapfunction(rcutil, 'default_rc_resources', lambda orig: [])
Martin von Zweigbergk
tests: make test-config-env.py a little less hacky...
r44324
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 rcutil.systemrcpath = systemrcpath
rcutil.userrcpath = userrcpath
Raphaël Gomès
black: format the codebase with 23.3.0...
r52596
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 # utility to print configs
def printconfigs(env):
encoding.environ = env
Augie Fackler
formatting: blacken the codebase...
r43346 rcutil._rccomponents = None # reset cache
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 ui = uimod.ui.load()
for section, name, value in ui.walkconfig():
source = ui.configsource(section, name)
Augie Fackler
formatting: blacken the codebase...
r43346 procutil.stdout.write(
b'%s.%s=%s # %s\n' % (section, name, value, util.pconvert(source))
)
Yuya Nishihara
procutil: bulk-replace util.std* to point to new module
r37137 procutil.stdout.write(b'\n')
Jun Wu
rcutil: let environ override system configs (BC)...
r31685
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 # environment variable overrides
printconfigs({})
Yuya Nishihara
py3: byte-stringify test-config.t and test-config-env.py
r36748 printconfigs({b'EDITOR': b'e2', b'PAGER': b'p2'})