configs: register more of our configs

Upstream has added devel warnings that require us to register all the configs
and remove the defaults that are specified at read time. This doesn't fix all
the cases, but is the start.

Differential Revision: https://phab.mercurial-scm.org/D1206
This commit is contained in:
Durham Goode 2017-10-23 20:02:57 -07:00
parent 6db0ad3d03
commit f260c80298
20 changed files with 205 additions and 65 deletions

View File

@ -109,6 +109,14 @@ from implementation import manifestfactory, fastmanifestcache
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('fastmanifest', 'logfile', default='')
configitem('fastmanifest', 'debugmetrics', default=False)
configitem('fastmanifest', 'usecache', default=True)
configitem('fastmanifest', 'usetree', default=False)
@command('^debugcachemanifest', [
('r', 'rev', [], 'cache the manifest for revs', 'REV'),
('a', 'all', False, 'cache all relevant revisions', ''),
@ -206,7 +214,7 @@ class FastManifestExtension(object):
manifest.memmanifestctx, 'write', factory.ctxwrite)
extensions.wrapfunction(manifest.manifestrevlog, 'add', factory.add)
if ui.configbool('fastmanifest', 'usecache', True):
if ui.configbool('fastmanifest', 'usecache'):
revsetmod.symbols['fastmanifesttocache'] = (
cachemanager.fastmanifesttocache
)

View File

@ -13,7 +13,7 @@ class manifestaccesslogger(object):
def revwrap(self, orig, *args, **kwargs):
"""Wraps manifest.rev and log access"""
r = orig(*args, **kwargs)
logfile = self._ui.config("fastmanifest", "logfile", "")
logfile = self._ui.config("fastmanifest", "logfile")
if logfile:
try:
with open(logfile, "a") as f:

View File

@ -54,7 +54,7 @@ class hybridmanifest(object):
else:
self.__treemanifest = False
if ui.configbool("fastmanifest", "usecache", True):
if ui.configbool("fastmanifest", "usecache"):
self.__cachedmanifest = fast
else:
self.__cachedmanifest = False
@ -949,8 +949,8 @@ class manifestfactory(object):
p1text = None
p1hexnode = revlog.hex(p1)
cacheenabled = self.ui.configbool("fastmanifest", "usecache", True)
treeenabled = self.ui.configbool("fastmanifest", "usetree", False)
cacheenabled = self.ui.configbool("fastmanifest", "usecache")
treeenabled = self.ui.configbool("fastmanifest", "usetree")
if (cacheenabled and
p1hexnode in fastcache and

View File

@ -118,7 +118,7 @@ class metricscollector(object):
def logsamples(self, ui):
self._addaggregatesamples()
debug = ui.configbool("fastmanifest", "debugmetrics", False)
debug = ui.configbool("fastmanifest", "debugmetrics")
if debug:
ui.status(("[FM-METRICS] Begin metrics\n"))

View File

@ -54,6 +54,11 @@ testedwith = 'ships-with-fb-hgext'
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('absorb', 'amendflag', default=None)
colortable = {
'absorb.node': 'blue bold',
'absorb.path': 'bold',
@ -1018,4 +1023,4 @@ def _amendcmd(flag, orig, ui, repo, *pats, **opts):
return 1
def extsetup(ui):
_wrapamend(ui.config('absorb', 'amendflag', None))
_wrapamend(ui.config('absorb', 'amendflag'))

View File

@ -24,6 +24,11 @@ else: # compat with hg < 4.3
from mercurial import cmdutil
command = cmdutil.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('directaccess', 'loadsafter', default=[])
# By default, all the commands have directaccess with warnings
# List of commands that have no directaccess and directaccess with no warning
directaccesslevel = [

View File

@ -24,7 +24,11 @@ Please not that this extension modifies only order of loading extensions. It
will not load them for you
"""
from mercurial import extensions
from mercurial import (
extensions,
registrar,
)
try:
from mercurial import chgserver
except ImportError:
@ -33,6 +37,9 @@ chgserver._configsections.append('extorder')
testedwith = 'ships-with-fb-hgext'
configtable = {}
configitem = registrar.configitem(configtable)
class MercurialExtOrderException(BaseException):
'''Special exception to bypass upstream exception catching
@ -49,14 +56,17 @@ def uisetup(ui):
preferlast = []
preferfirst = []
for item, _v in ui.configitems('extorder'):
val = ui.configlist('extorder', item)
if item == 'preferlast':
preferlast.extend(val)
elif item == 'preferfirst':
preferfirst.extend(val)
else:
deps[item] = val
# The configs being read here are user defined, so we need to suppress
# warnings telling us to register them.
with ui.configoverride({("devel", "all-warnings"): False}):
for item, _v in ui.configitems('extorder'):
val = ui.configlist('extorder', item)
if item == 'preferlast':
preferlast.extend(val)
elif item == 'preferfirst':
preferfirst.extend(val)
else:
deps[item] = val
exts = list(extensions._order)
for e in preferfirst + preferlast:

View File

@ -92,6 +92,15 @@ cmdtable.update(prune.cmdtable)
cmdtable.update(split.cmdtable)
cmdtable.update(unamend.cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('fbamend', 'alwaysnewest', default=False)
configitem('fbamend', 'date', default=None)
configitem('fbamend', 'education', default=None)
configitem('fbamend', 'safestrip', default=True)
configitem('fbamend', 'userestack', default=False)
testedwith = 'ships-with-fb-hgext'
amendopts = [

View File

@ -282,5 +282,5 @@ def wrapstrip(loaded):
def uisetup(ui):
# developer config: fbamend.safestrip
if ui.configbool('fbamend', 'safestrip', True):
if ui.configbool('fbamend', 'safestrip'):
extensions.afterloaded('strip', wrapstrip)

View File

@ -28,6 +28,11 @@ from mercurial.i18n import _
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('fbhistedit', 'exec_in_user_shell', default=None)
testedwith = 'ships-with-fb-hgext'
def defineactions():

View File

@ -24,10 +24,19 @@ message and override some other config items.
import os
import grp
from mercurial import (
registrar,
)
testedwith = 'ships-with-fb-hgext'
_missinggroup = None
configtable = {}
configitem = registrar.configitem(configtable)
configitem('grpcheck', 'groups', default=[])
def _grpname2gid(name):
try:
return grp.getgrnam(name).gr_gid

View File

@ -20,8 +20,14 @@ import os
from mercurial import (
extensions,
localrepo,
registrar,
)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('logging', 'configoptions', default=[])
def _localrepoinit(orig, self, baseui, path=None, create=False):
orig(self, baseui, path, create)
reponame = self.ui.config('paths', 'default')
@ -29,14 +35,18 @@ def _localrepoinit(orig, self, baseui, path=None, create=False):
reponame = os.path.basename(reponame)
configoptstolog = self.ui.configlist('logging', 'configoptions')
kwargs = {'repo': reponame}
for option in configoptstolog:
splitted = option.split('.')
if len(splitted) != 2:
continue
section, name = splitted
value = self.ui.config(section, name)
if value is not None:
kwargs[name] = value
# The configs being read here are user defined, so we need to suppress
# warnings telling us to register them.
with self.ui.configoverride({("devel", "all-warnings"): False}):
for option in configoptstolog:
splitted = option.split('.')
if len(splitted) != 2:
continue
section, name = splitted
value = self.ui.config(section, name)
if value is not None:
kwargs[name] = value
obsstore_size = 0
try:

View File

@ -17,8 +17,17 @@ from mercurial.i18n import _
from mercurial import merge as mergemod
from mercurial import scmutil
from mercurial import (
registrar,
)
UPDATEARGS = 'updateargs'
configtable = {}
configitem = registrar.configitem(configtable)
configitem('morestatus', 'show', default=False)
def prefixlines(raw):
'''Surround lineswith a comment char and a new line'''
lines = raw.splitlines()
@ -112,7 +121,7 @@ STATES = (
def extsetup(ui):
if ui.configbool('morestatus', 'show', False) and not ui.plain():
if ui.configbool('morestatus', 'show') and not ui.plain():
wrapcommand(commands.table, 'status', statuscmd)
# Write down `hg update` args to show the continue command in
# interrupted update state.

View File

@ -22,10 +22,14 @@ callsign = E
"""
from mercurial import hg
from mercurial import extensions
from mercurial import revset, smartset
from mercurial import error
from mercurial import (
error,
extensions,
hg,
registrar,
revset,
smartset,
)
from mercurial.i18n import _
try:
@ -39,6 +43,11 @@ import json
import re
import subprocess
configtable = {}
configitem = registrar.configitem(configtable)
configitem('phrevset', 'callsign', default=None)
DIFFERENTIAL_REGEX = re.compile(
'Differential Revision: http.+?/' # Line start, URL
'D(?P<id>[0-9]+)', # Differential ID, just numeric part

View File

@ -14,10 +14,15 @@
# - If the file cannot be created or accessed, fails silently
#
# The configuration details can be found in the documentation of ui.log below
from mercurial import encoding, util
from mercurial import encoding, registrar, util
import json, os
configtable = {}
configitem = registrar.configitem(configtable)
configitem('sampling', 'filepath', default='')
def _parentfolderexists(f):
return (f is not None and
os.path.exists(os.path.dirname(os.path.normpath(f))))
@ -25,7 +30,7 @@ def _parentfolderexists(f):
def _getcandidatelocation(ui):
for candidatelocation in (
encoding.environ.get("SCM_SAMPLING_FILEPATH", None),
ui.config("sampling", "filepath", "")):
ui.config("sampling", "filepath")):
if _parentfolderexists(candidatelocation):
return candidatelocation
return None

View File

@ -22,8 +22,18 @@ import sys
import time
import traceback
from mercurial import (
registrar,
)
pathformat = '/tmp/trace-%(pid)s-%(time)s.log'
configtable = {}
configitem = registrar.configitem(configtable)
configitem('sigtrace', 'pathformat', default=pathformat)
configitem('sigtrace', 'signal', default='USR1')
def printstacks(sig, currentframe):
content = ''
for tid, frame in sys._current_frames().iteritems():
@ -35,8 +45,8 @@ def printstacks(sig, currentframe):
def uisetup(ui):
global pathformat
pathformat = ui.config('sigtrace', 'pathformat', pathformat)
signame = ui.config('sigtrace', 'signal', 'USR1')
pathformat = ui.config('sigtrace', 'pathformat')
signame = ui.config('sigtrace', 'signal')
sig = getattr(signal, 'SIG' + signame, None)
if sig is not None:
signal.signal(sig, printstacks)

View File

@ -53,7 +53,9 @@ Config::
nodesthint = ''
nodestmsg = ''
rollbackhint = ''
rollbackmessage = ''
singlecolonmsg = ''
tagmessage = ''
tagsmessage = ''
# output new hashes when nodes get updated
@ -105,6 +107,52 @@ logopts = [
('', 'all', None, _('shows all changesets in the repo')),
]
configtable = {}
configitem = registrar.configitem(configtable)
configitem('grep', 'command', default='grep')
configitem(globaldata, createmarkersoperation, default=None)
configitem('tweakdefaults', 'singlecolonabort', default=False)
configitem('tweakdefaults', 'singlecolonwarn', default=False)
configitem('tweakdefaults', 'showupdated', default=False)
configitem('tweakdefaults', 'nooprebase', default=True)
configitem('tweakdefaults', 'amendkeepdate', default=False)
configitem('tweakdefaults', 'graftkeepdate', default=False)
configitem('tweakdefaults', 'histeditkeepdate', default=False)
configitem('tweakdefaults', 'rebasekeepdate', default=False)
configitem('tweakdefaults', 'allowbranch', default=True)
configitem('tweakdefaults', 'allowfullrepohistgrep', default=False)
configitem('tweakdefaults', 'allowmerge', default=True)
configitem('tweakdefaults', 'allowrollback', default=True)
configitem('tweakdefaults', 'allowtags', default=True)
rebasemsg = _('you must use a bookmark with tracking '
'or manually specify a destination for the rebase')
configitem('tweakdefaults', 'bmnodesthint', default=
_('set up tracking with `hg book -t <destination>` '
'or manually supply --dest / -d'))
configitem('tweakdefaults', 'bmnodestmsg', default=rebasemsg)
configitem('tweakdefaults', 'branchmessage', default=
_('new named branches are disabled in this repository'))
configitem('tweakdefaults', 'branchesmessage', default=None)
configitem('tweakdefaults', 'mergemessage', default=
_('merging is not supported for this repository'))
configitem('tweakdefaults', 'nodesthint', default=
_('set up tracking with `hg book <name> -t <destination>` '
'or manually supply --dest / -d'))
configitem('tweakdefaults', 'nodestmsg', default=rebasemsg)
configitem('tweakdefaults', 'rollbackmessage', default=
_('the use of rollback is disabled'))
configitem('tweakdefaults', 'rollbackhint', default=None)
configitem('tweakdefaults', 'singlecolonmsg', default=
_("use of ':' is deprecated"))
configitem('tweakdefaults', 'tagmessage', default=
_('new tags are disabled in this repository'))
configitem('tweakdefaults', 'tagsmessage', default='')
def uisetup(ui):
tweakorder()
# if we want to replace command's docstring (not just add stuff to it),
@ -297,18 +345,12 @@ def pull(orig, ui, repo, *args, **opts):
raise error.Abort(mess)
if (isrebase or update) and not dest:
rebasemsg = _('you must use a bookmark with tracking '
'or manually specify a destination for the rebase')
if isrebase and bmactive(repo):
mess = ui.config('tweakdefaults', 'bmnodestmsg', rebasemsg)
hint = ui.config('tweakdefaults', 'bmnodesthint', _(
'set up tracking with `hg book -t <destination>` '
'or manually supply --dest / -d'))
mess = ui.config('tweakdefaults', 'bmnodestmsg')
hint = ui.config('tweakdefaults', 'bmnodesthint')
elif isrebase:
mess = ui.config('tweakdefaults', 'nodestmsg', rebasemsg)
hint = ui.config('tweakdefaults', 'nodesthint', _(
'set up tracking with `hg book <name> -t <destination>` '
'or manually supply --dest / -d'))
mess = ui.config('tweakdefaults', 'nodestmsg')
hint = ui.config('tweakdefaults', 'nodesthint')
else: # update
mess = _('you must specify a destination for the update')
hint = _('use `hg pull --update --dest <destination>`')
@ -379,7 +421,7 @@ def tweakbehaviors(ui):
def _nothingtorebase(orig, *args, **kwargs):
return 0
if ui.configbool("tweakdefaults", "nooprebase", True):
if ui.configbool("tweakdefaults", "nooprebase"):
try:
rebase = extensions.find("rebase")
extensions.wrapfunction(
@ -595,7 +637,7 @@ def grep(ui, repo, pattern, *pats, **opts):
For the old 'hg grep', see 'histgrep'."""
grepcommandstr = ui.config('grep', 'command', default='grep')
grepcommandstr = ui.config('grep', 'command')
# Use shlex.split() to split up grepcommandstr into multiple arguments.
# this allows users to specify a command plus arguments (e.g., "grep -i").
# We don't use a real shell to execute this, which ensures we won't do
@ -712,8 +754,7 @@ def _analyzewrapper(orig, x, ui):
if enabled and isinstance(x, tuple) and \
(x[0] in ('range', 'rangepre', 'rangepost')) and \
x != ('rangepre', ('symbol', '.')):
msg = ui.config('tweakdefaults', 'singlecolonmsg',
_("use of ':' is deprecated"))
msg = ui.config('tweakdefaults', 'singlecolonmsg')
if abort:
raise error.Abort('%s' % msg)
if warn:
@ -754,7 +795,7 @@ def _rebase(orig, ui, repo, **opts):
formattercommands = set()
def cleanupnodeswrapper(orig, repo, mapping, operation, *args, **kwargs):
if (repo.ui.configbool('tweakdefaults', 'showupdated', False) and
if (repo.ui.configbool('tweakdefaults', 'showupdated') and
operation not in formattercommands):
maxoutput = 10
oldnodes = sorted(mapping.keys())
@ -834,9 +875,8 @@ def log(orig, ui, repo, *pats, **opts):
return orig(ui, repo, *pats, **opts)
def branchcmd(orig, ui, repo, label=None, **opts):
message = ui.config('tweakdefaults', 'branchmessage',
_('new named branches are disabled in this repository'))
enabled = ui.configbool('tweakdefaults', 'allowbranch', True)
message = ui.config('tweakdefaults', 'branchmessage')
enabled = ui.configbool('tweakdefaults', 'allowbranch')
if (enabled and opts.get('new')) or label is None:
if 'new' in opts:
del opts['new']
@ -861,8 +901,7 @@ def mergecmd(orig, ui, repo, node=None, **opts):
if ui.configbool('tweakdefaults','allowmerge', True):
return orig(ui, repo, node, **opts)
else:
message = ui.config('tweakdefaults', 'mergemessage',
_('merging is not supported for this repository'))
message = ui.config('tweakdefaults', 'mergemessage')
hint = ui.config('tweakdefaults', 'mergehint', _('use rebase instead'))
raise error.Abort(message, hint=hint)
@ -899,27 +938,25 @@ def rollbackcmd(orig, ui, repo, **opts):
"""
Allowing to disable the rollback command
"""
if ui.configbool('tweakdefaults', 'allowrollback', True):
if ui.configbool('tweakdefaults', 'allowrollback'):
return orig(ui, repo, **opts)
else:
message = ui.config('tweakdefaults', 'rollbackmessage',
_('the use of rollback is disabled'))
hint = ui.config('tweakdefaults', 'rollbackhint', None)
message = ui.config('tweakdefaults', 'rollbackmessage')
hint = ui.config('tweakdefaults', 'rollbackhint')
raise error.Abort(message, hint=hint)
def tagcmd(orig, ui, repo, name1, *names, **opts):
"""
Allowing to disable tags
"""
message = ui.config('tweakdefaults', 'tagmessage',
_('new tags are disabled in this repository'))
if ui.configbool('tweakdefaults', 'allowtags', True):
message = ui.config('tweakdefaults', 'tagmessage')
if ui.configbool('tweakdefaults', 'allowtags'):
return orig(ui, repo, name1, *names, **opts)
else:
raise error.Abort(message)
def tagscmd(orig, ui, repo, **opts):
message = ui.config('tweakdefaults', 'tagsmessage', '')
message = ui.config('tweakdefaults', 'tagsmessage')
if message:
ui.warn(message + '\n')
return orig(ui, repo, **opts)
@ -981,7 +1018,10 @@ def bmactive(repo):
def _createmarkers(orig, repo, relations, flag=0, date=None, metadata=None,
operation=None):
operation = repo.ui.config(globaldata, createmarkersoperation, operation)
configoperation = repo.ui.config(globaldata, createmarkersoperation)
if configoperation is not None:
operation = configoperation
if operation is None:
return orig(repo, relations, flag, date, metadata)

View File

@ -49,6 +49,11 @@ from hgext3rd import (
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('undo', '_duringundologlock', default=False)
# Setup
def extsetup(ui):

View File

@ -29,7 +29,7 @@ New errors are not allowed. Warnings are strongly discouraged.
undocumented: fastmanifest.logfile (str)
undocumented: fastmanifest.maxinmemoryentries (str) [DEFAULT_MAX_MEMORY_ENTRIES]
undocumented: fastmanifest.silent (bool)
undocumented: fastmanifest.usecache (bool) [True]
undocumented: fastmanifest.usecache (bool)
undocumented: fastmanifest.usetree (bool)
undocumented: fbconduit.backingrepos (list) [[reponame]]
undocumented: fbconduit.gitcallsigns (list)
@ -38,7 +38,7 @@ New errors are not allowed. Warnings are strongly discouraged.
undocumented: fbconduit.protocol (str)
undocumented: fbconduit.reponame (str)
undocumented: fbhistedit.exec_in_user_shell (str)
undocumented: grep.command (str) ['grep']
undocumented: grep.command (str)
undocumented: morestatus.show (bool)
undocumented: nointerrupt.interactiveonly (bool) [True]
undocumented: perftweaks.cachenoderevs (bool) [True]

View File

@ -5,6 +5,7 @@ Set up test environment.
> directaccess=$TESTDIR/../hgext3rd/directaccess.py
> fbamend=$TESTDIR/../hgext3rd/fbamend
> inhibit=$TESTDIR/../hgext3rd/inhibit.py
> histedit=
> rebase=
> [experimental]
> evolution = createmarkers, allowunstable