diff --git a/fastmanifest/__init__.py b/fastmanifest/__init__.py --- a/fastmanifest/__init__.py +++ b/fastmanifest/__init__.py @@ -109,6 +109,14 @@ 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 @@ 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 ) diff --git a/fastmanifest/debug.py b/fastmanifest/debug.py --- a/fastmanifest/debug.py +++ b/fastmanifest/debug.py @@ -13,7 +13,7 @@ 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: diff --git a/fastmanifest/implementation.py b/fastmanifest/implementation.py --- a/fastmanifest/implementation.py +++ b/fastmanifest/implementation.py @@ -54,7 +54,7 @@ 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 @@ 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 diff --git a/fastmanifest/metrics.py b/fastmanifest/metrics.py --- a/fastmanifest/metrics.py +++ b/fastmanifest/metrics.py @@ -118,7 +118,7 @@ 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")) diff --git a/hgext3rd/absorb/__init__.py b/hgext3rd/absorb/__init__.py --- a/hgext3rd/absorb/__init__.py +++ b/hgext3rd/absorb/__init__.py @@ -54,6 +54,11 @@ 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 @@ return 1 def extsetup(ui): - _wrapamend(ui.config('absorb', 'amendflag', None)) + _wrapamend(ui.config('absorb', 'amendflag')) diff --git a/hgext3rd/directaccess.py b/hgext3rd/directaccess.py --- a/hgext3rd/directaccess.py +++ b/hgext3rd/directaccess.py @@ -24,6 +24,11 @@ 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 = [ diff --git a/hgext3rd/extorder.py b/hgext3rd/extorder.py --- a/hgext3rd/extorder.py +++ b/hgext3rd/extorder.py @@ -24,7 +24,11 @@ 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 @@ testedwith = 'ships-with-fb-hgext' +configtable = {} +configitem = registrar.configitem(configtable) + class MercurialExtOrderException(BaseException): '''Special exception to bypass upstream exception catching @@ -49,14 +56,17 @@ 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: diff --git a/hgext3rd/fbamend/__init__.py b/hgext3rd/fbamend/__init__.py --- a/hgext3rd/fbamend/__init__.py +++ b/hgext3rd/fbamend/__init__.py @@ -92,6 +92,15 @@ 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 = [ diff --git a/hgext3rd/fbamend/prune.py b/hgext3rd/fbamend/prune.py --- a/hgext3rd/fbamend/prune.py +++ b/hgext3rd/fbamend/prune.py @@ -282,5 +282,5 @@ def uisetup(ui): # developer config: fbamend.safestrip - if ui.configbool('fbamend', 'safestrip', True): + if ui.configbool('fbamend', 'safestrip'): extensions.afterloaded('strip', wrapstrip) diff --git a/hgext3rd/fbhistedit.py b/hgext3rd/fbhistedit.py --- a/hgext3rd/fbhistedit.py +++ b/hgext3rd/fbhistedit.py @@ -28,6 +28,11 @@ 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(): diff --git a/hgext3rd/grpcheck.py b/hgext3rd/grpcheck.py --- a/hgext3rd/grpcheck.py +++ b/hgext3rd/grpcheck.py @@ -24,10 +24,19 @@ 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 diff --git a/hgext3rd/logginghelper.py b/hgext3rd/logginghelper.py --- a/hgext3rd/logginghelper.py +++ b/hgext3rd/logginghelper.py @@ -20,8 +20,14 @@ 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 @@ 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: diff --git a/hgext3rd/morestatus.py b/hgext3rd/morestatus.py --- a/hgext3rd/morestatus.py +++ b/hgext3rd/morestatus.py @@ -17,8 +17,17 @@ 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 @@ 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. diff --git a/hgext3rd/phrevset.py b/hgext3rd/phrevset.py --- a/hgext3rd/phrevset.py +++ b/hgext3rd/phrevset.py @@ -22,10 +22,14 @@ """ -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 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[0-9]+)', # Differential ID, just numeric part diff --git a/hgext3rd/sampling.py b/hgext3rd/sampling.py --- a/hgext3rd/sampling.py +++ b/hgext3rd/sampling.py @@ -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 _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 diff --git a/hgext3rd/sigtrace.py b/hgext3rd/sigtrace.py --- a/hgext3rd/sigtrace.py +++ b/hgext3rd/sigtrace.py @@ -22,8 +22,18 @@ 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 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) diff --git a/hgext3rd/tweakdefaults.py b/hgext3rd/tweakdefaults.py --- a/hgext3rd/tweakdefaults.py +++ b/hgext3rd/tweakdefaults.py @@ -53,7 +53,9 @@ nodesthint = '' nodestmsg = '' rollbackhint = '' + rollbackmessage = '' singlecolonmsg = '' + tagmessage = '' tagsmessage = '' # output new hashes when nodes get updated @@ -105,6 +107,52 @@ ('', '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 ` ' + '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 -t ` ' + '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 @@ 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 ` ' - '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 -t ` ' - '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 `') @@ -379,7 +421,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ """ 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 _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) diff --git a/hgext3rd/undo.py b/hgext3rd/undo.py --- a/hgext3rd/undo.py +++ b/hgext3rd/undo.py @@ -49,6 +49,11 @@ cmdtable = {} command = registrar.command(cmdtable) +configtable = {} +configitem = registrar.configitem(configtable) + +configitem('undo', '_duringundologlock', default=False) + # Setup def extsetup(ui): diff --git a/tests/test-check-config-hg.t b/tests/test-check-config-hg.t --- a/tests/test-check-config-hg.t +++ b/tests/test-check-config-hg.t @@ -29,7 +29,7 @@ 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 @@ 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] diff --git a/tests/test-fbamend-to.t b/tests/test-fbamend-to.t --- a/tests/test-fbamend-to.t +++ b/tests/test-fbamend-to.t @@ -5,6 +5,7 @@ > directaccess=$TESTDIR/../hgext3rd/directaccess.py > fbamend=$TESTDIR/../hgext3rd/fbamend > inhibit=$TESTDIR/../hgext3rd/inhibit.py + > histedit= > rebase= > [experimental] > evolution = createmarkers, allowunstable