[PATCH 4 of 4] config: set a 'source' in most cases where config don't come from file but code

Mads Kiilerich mads at kiilerich.com
Tue Mar 18 20:45:26 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1395193514 -3600
#      Wed Mar 19 02:45:14 2014 +0100
# Node ID e036b9c6118260654fcd567eb5653ec45bcc86a0
# Parent  aecee5b4ae61ae98a138583c63ce03a9e82084f0
config: set a 'source' in most cases where config don't come from file but code

Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.

diff --git a/hgext/eol.py b/hgext/eol.py
--- a/hgext/eol.py
+++ b/hgext/eol.py
@@ -151,7 +151,7 @@ class eolfile(object):
         self.cfg = config.config()
         # Our files should not be touched. The pattern must be
         # inserted first override a '** = native' pattern.
-        self.cfg.set('patterns', '.hg*', 'BIN')
+        self.cfg.set('patterns', '.hg*', 'BIN', 'eol')
         # We can then parse the user's patterns.
         self.cfg.parse('.hgeol', data)
 
@@ -176,14 +176,14 @@ class eolfile(object):
         for pattern, style in self.cfg.items('patterns'):
             key = style.upper()
             try:
-                ui.setconfig('decode', pattern, self._decode[key])
-                ui.setconfig('encode', pattern, self._encode[key])
+                ui.setconfig('decode', pattern, self._decode[key], 'eol')
+                ui.setconfig('encode', pattern, self._encode[key], 'eol')
             except KeyError:
                 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
                         % (style, self.cfg.source('patterns', pattern)))
         # eol.only-consistent can be specified in ~/.hgrc or .hgeol
         for k, v in self.cfg.items('eol'):
-            ui.setconfig('eol', k, v)
+            ui.setconfig('eol', k, v, 'eol')
 
     def checkrev(self, repo, ctx, files):
         failed = []
@@ -261,7 +261,7 @@ def preupdate(ui, repo, hooktype, parent
     return False
 
 def uisetup(ui):
-    ui.setconfig('hooks', 'preupdate.eol', preupdate)
+    ui.setconfig('hooks', 'preupdate.eol', preupdate, 'eol')
 
 def extsetup(ui):
     try:
@@ -280,7 +280,7 @@ def reposetup(ui, repo):
     for name, fn in filters.iteritems():
         repo.adddatafilter(name, fn)
 
-    ui.setconfig('patch', 'eol', 'auto')
+    ui.setconfig('patch', 'eol', 'auto', 'eol')
 
     class eolrepo(repo.__class__):
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -198,7 +198,8 @@ def commitfuncfor(repo, src):
     def commitfunc(**kwargs):
         phasebackup = repo.ui.backupconfig('phases', 'new-commit')
         try:
-            repo.ui.setconfig('phases', 'new-commit', phasemin)
+            repo.ui.setconfig('phases', 'new-commit', phasemin,
+                              'histedit')
             extra = kwargs.get('extra', {}).copy()
             extra['histedit_source'] = src.hex()
             kwargs['extra'] = extra
@@ -220,11 +221,12 @@ def applychanges(ui, repo, ctx, opts):
     else:
         try:
             # ui.forcemerge is an internal variable, do not document
-            repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+            repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                              'histedit')
             stats = mergemod.update(repo, ctx.node(), True, True, False,
                                     ctx.p1().node())
         finally:
-            repo.ui.setconfig('ui', 'forcemerge', '')
+            repo.ui.setconfig('ui', 'forcemerge', '', 'histedit')
         repo.setparents(wcpar, node.nullid)
         repo.dirstate.write()
         # fix up dirstate for copies and renames
@@ -375,7 +377,7 @@ def finishfold(ui, repo, ctx, oldctx, ne
     phasebackup = repo.ui.backupconfig('phases', 'new-commit')
     try:
         phasemin = max(ctx.phase(), oldctx.phase())
-        repo.ui.setconfig('phases', 'new-commit', phasemin)
+        repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
         n = collapse(repo, ctx, repo[newnode], commitopts)
     finally:
         repo.ui.restoreconfig(phasebackup)
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -385,10 +385,10 @@ def demo(ui, repo, *args, **opts):
     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
     ui.note(_('creating temporary repository at %s\n') % tmpdir)
     repo = localrepo.localrepository(repo.baseui, tmpdir, True)
-    ui.setconfig('keyword', fn, '')
+    ui.setconfig('keyword', fn, '', 'keyword')
     svn = ui.configbool('keywordset', 'svn')
     # explicitly set keywordset for demo output
-    ui.setconfig('keywordset', 'svn', svn)
+    ui.setconfig('keywordset', 'svn', svn, 'keyword')
 
     uikwmaps = ui.configitems('keywordmaps')
     if args or opts.get('rcfile'):
@@ -419,7 +419,7 @@ def demo(ui, repo, *args, **opts):
         if uikwmaps:
             ui.status(_('\tdisabling current template maps\n'))
             for k, v in kwmaps.iteritems():
-                ui.setconfig('keywordmaps', k, v)
+                ui.setconfig('keywordmaps', k, v, 'keyword')
     else:
         ui.status(_('\n\tconfiguration using current keyword template maps\n'))
         if uikwmaps:
@@ -445,7 +445,7 @@ def demo(ui, repo, *args, **opts):
         wlock.release()
     for name, cmd in ui.configitems('hooks'):
         if name.split('.', 1)[0].find('commit') > -1:
-            repo.ui.setconfig('hooks', name, '')
+            repo.ui.setconfig('hooks', name, '', 'keyword')
     msg = _('hg keyword configuration and expansion example')
     ui.note(("hg ci -m '%s'\n" % msg))
     repo.commit(text=msg)
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -510,5 +510,6 @@ def reposetup(ui, repo):
             repo.requirements.add('largefiles')
             repo._writerequirements()
 
-    ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles)
-    ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles)
+    ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles,
+                 'largefiles')
+    ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles')
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -304,7 +304,7 @@ def newcommit(repo, phase, *args, **kwar
         backup = repo.ui.backupconfig('phases', 'new-commit')
     try:
         if phase is not None:
-            repo.ui.setconfig('phases', 'new-commit', phase)
+            repo.ui.setconfig('phases', 'new-commit', phase, 'mq')
         return repo.commit(*args, **kwargs)
     finally:
         if phase is not None:
diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -129,8 +129,8 @@ def uisetup(ui):
                 if (always or auto and
                     (cmd in attend or
                      (cmd not in ignore and not attend))):
-                    ui.setconfig('ui', 'formatted', ui.formatted())
-                    ui.setconfig('ui', 'interactive', False)
+                    ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
+                    ui.setconfig('ui', 'interactive', False, 'pager')
                     if util.safehasattr(signal, "SIGPIPE"):
                         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
                     _runpager(ui, p)
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -546,11 +546,11 @@ def patchbomb(ui, repo, *revs, **opts):
             if not sendmail:
                 verifycert = ui.config('smtp', 'verifycert')
                 if opts.get('insecure'):
-                    ui.setconfig('smtp', 'verifycert', 'loose')
+                    ui.setconfig('smtp', 'verifycert', 'loose', 'patchbomb')
                 try:
                     sendmail = mail.connect(ui, mbox=mbox)
                 finally:
-                    ui.setconfig('smtp', 'verifycert', verifycert)
+                    ui.setconfig('smtp', 'verifycert', verifycert, 'patchbomb')
             ui.status(_('sending '), subj, ' ...\n')
             ui.progress(_('sending'), i, item=subj, total=len(msgs))
             if not mbox:
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -330,14 +330,15 @@ def rebase(ui, repo, **opts):
                     repo.ui.debug('resuming interrupted rebase\n')
                 else:
                     try:
-                        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                                     'rebase')
                         stats = rebasenode(repo, rev, p1, state, collapsef)
                         if stats and stats[3] > 0:
                             raise error.InterventionRequired(
                                 _('unresolved conflicts (see hg '
                                   'resolve, then hg rebase --continue)'))
                     finally:
-                        ui.setconfig('ui', 'forcemerge', '')
+                        ui.setconfig('ui', 'forcemerge', '', 'rebase')
                 cmdutil.duplicatecopies(repo, rev, target)
                 if not collapsef:
                     newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn,
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -193,7 +193,7 @@ class bundlerepository(localrepo.localre
             self._tempparent = tempfile.mkdtemp()
             localrepo.instance(ui, self._tempparent, 1)
             localrepo.localrepository.__init__(self, ui, self._tempparent)
-        self.ui.setconfig('phases', 'publish', False)
+        self.ui.setconfig('phases', 'publish', False, 'bundlerepo')
 
         if path:
             self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1982,10 +1982,10 @@ def amend(ui, repo, commitfunc, old, ext
                     commitphase = 'secret'
                 else:
                     commitphase = old.phase()
-                repo.ui.setconfig('phases', 'new-commit', commitphase)
+                repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
                 newid = repo.commitctx(new)
             finally:
-                repo.ui.setconfig('phases', 'new-commit', ph)
+                repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
             if newid != old.node():
                 # Reroute the working copy parent to the new changeset
                 repo.setparents(newid, nullid)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -465,7 +465,8 @@ def backout(ui, repo, node=None, rev=Non
         rctx = scmutil.revsingle(repo, hex(parent))
         if not opts.get('merge') and op1 != node:
             try:
-                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                             'backout')
                 stats = mergemod.update(repo, parent, True, True, False,
                                         node, False)
                 repo.setparents(op1, op2)
@@ -479,7 +480,7 @@ def backout(ui, repo, node=None, rev=Non
                     ui.status(msg % short(node))
                 return stats[3] > 0
             finally:
-                ui.setconfig('ui', 'forcemerge', '')
+                ui.setconfig('ui', 'forcemerge', '', '')
         else:
             hg.clean(repo, node, show_stats=False)
             repo.dirstate.setbranch(branch)
@@ -507,10 +508,11 @@ def backout(ui, repo, node=None, rev=Non
             ui.status(_('merging with changeset %s\n')
                       % nice(repo.changelog.tip()))
             try:
-                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                             'backout')
                 return hg.merge(repo, hex(repo.changelog.tip()))
             finally:
-                ui.setconfig('ui', 'forcemerge', '')
+                ui.setconfig('ui', 'forcemerge', '', '')
     finally:
         wlock.release()
     return 0
@@ -1361,7 +1363,7 @@ def commit(ui, repo, *pats, **opts):
         if opts.get('amend'):
             raise util.Abort(_('cannot amend with --subrepos'))
         # Let --subrepos on the command line override config setting.
-        ui.setconfig('ui', 'commitsubrepos', True)
+        ui.setconfig('ui', 'commitsubrepos', True, 'commit')
 
     # Save this for restoring it later
     oldcommitphase = ui.config('phases', 'new-commit')
@@ -1436,15 +1438,17 @@ def commit(ui, repo, *pats, **opts):
         def commitfunc(ui, repo, message, match, opts):
             try:
                 if opts.get('secret'):
-                    ui.setconfig('phases', 'new-commit', 'secret')
+                    ui.setconfig('phases', 'new-commit', 'secret', 'commit')
                     # Propagate to subrepos
-                    repo.baseui.setconfig('phases', 'new-commit', 'secret')
+                    repo.baseui.setconfig('phases', 'new-commit', 'secret',
+                                          'commit')
 
                 return repo.commit(message, opts.get('user'), opts.get('date'),
                                    match, editor=e, extra=extra)
             finally:
-                ui.setconfig('phases', 'new-commit', oldcommitphase)
-                repo.baseui.setconfig('phases', 'new-commit', oldcommitphase)
+                ui.setconfig('phases', 'new-commit', oldcommitphase, 'commit')
+                repo.baseui.setconfig('phases', 'new-commit', oldcommitphase,
+                                      'commit')
 
 
         node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
@@ -3176,11 +3180,12 @@ def graft(ui, repo, *revs, **opts):
                 # perform the graft merge with p1(rev) as 'ancestor'
                 try:
                     # ui.forcemerge is an internal variable, do not document
-                    repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                    repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                                      'graft')
                     stats = mergemod.update(repo, ctx.node(), True, True, False,
                                             ctx.p1().node())
                 finally:
-                    repo.ui.setconfig('ui', 'forcemerge', '')
+                    repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
                 # report any conflicts
                 if stats and stats[3] > 0:
                     # write out state for --continue
@@ -4305,10 +4310,10 @@ def merge(ui, repo, node=None, **opts):
 
     try:
         # ui.forcemerge is an internal variable, do not document
-        repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+        repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
         return hg.merge(repo, node, force=opts.get('force'))
     finally:
-        ui.setconfig('ui', 'forcemerge', '')
+        ui.setconfig('ui', 'forcemerge', '', 'merge')
 
 @command('outgoing|out',
     [('f', 'force', None, _('run even when the destination is unrelated')),
@@ -4688,7 +4693,7 @@ def push(ui, repo, dest=None, **opts):
     """
 
     if opts.get('bookmark'):
-        ui.setconfig('bookmarks', 'pushing', opts['bookmark'])
+        ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
         for b in opts['bookmark']:
             # translate -B options to -r so changesets get pushed
             if b in repo._bookmarks:
@@ -4964,11 +4969,12 @@ def resolve(ui, repo, *pats, **opts):
 
                 try:
                     # resolve file
-                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                                 'resolve')
                     if ms.resolve(f, wctx):
                         ret = 1
                 finally:
-                    ui.setconfig('ui', 'forcemerge', '')
+                    ui.setconfig('ui', 'forcemerge', '', 'resolve')
                     ms.commit()
 
                 # replace filemerge's .orig file with our resolve file
@@ -5185,9 +5191,9 @@ def serve(ui, repo, **opts):
         val = opts.get(o, '')
         if val in (None, ''): # should check against default options instead
             continue
-        baseui.setconfig("web", o, val)
+        baseui.setconfig("web", o, val, 'serve')
         if repo and repo.ui != baseui:
-            repo.ui.setconfig("web", o, val)
+            repo.ui.setconfig("web", o, val, 'serve')
 
     o = opts.get('web_conf') or opts.get('webdir_conf')
     if not o:
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -405,7 +405,7 @@ def clone(ui, peeropts, source, dest=Non
             fp.write("default = %s\n" % defaulturl)
             fp.close()
 
-            destrepo.ui.setconfig('paths', 'default', defaulturl)
+            destrepo.ui.setconfig('paths', 'default', defaulturl, 'clone')
 
             if update:
                 if update is not True:
@@ -613,19 +613,19 @@ def remoteui(src, opts):
     for o in 'ssh', 'remotecmd':
         v = opts.get(o) or src.config('ui', o)
         if v:
-            dst.setconfig("ui", o, v)
+            dst.setconfig("ui", o, v, 'copied')
 
     # copy bundle-specific options
     r = src.config('bundle', 'mainreporoot')
     if r:
-        dst.setconfig('bundle', 'mainreporoot', r)
+        dst.setconfig('bundle', 'mainreporoot', r, 'copied')
 
     # copy selected local settings to the remote ui
     for sect in ('auth', 'hostfingerprints', 'http_proxy'):
         for key, val in src.configitems(sect):
-            dst.setconfig(sect, key, val)
+            dst.setconfig(sect, key, val, 'copied')
     v = src.config('web', 'cacerts')
     if v:
-        dst.setconfig('web', 'cacerts', util.expandpath(v))
+        dst.setconfig('web', 'cacerts', util.expandpath(v), 'copied')
 
     return dst
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -64,10 +64,10 @@ class hgweb(object):
             r = repo
 
         r = self._getview(r)
-        r.ui.setconfig('ui', 'report_untrusted', 'off')
-        r.baseui.setconfig('ui', 'report_untrusted', 'off')
-        r.ui.setconfig('ui', 'nontty', 'true')
-        r.baseui.setconfig('ui', 'nontty', 'true')
+        r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
+        r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
+        r.ui.setconfig('ui', 'nontty', 'true', 'hgweb')
+        r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb')
         self.repo = r
         hook.redirect(True)
         self.mtime = -1
diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -96,8 +96,8 @@ class hgwebdir(object):
             u = self.baseui.copy()
         else:
             u = ui.ui()
-            u.setconfig('ui', 'report_untrusted', 'off')
-            u.setconfig('ui', 'nontty', 'true')
+            u.setconfig('ui', 'report_untrusted', 'off', 'hgwebdir')
+            u.setconfig('ui', 'nontty', 'true', 'hgwebdir')
 
         if not isinstance(self.conf, (dict, list, tuple)):
             map = {'paths': 'hgweb-paths'}
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -512,8 +512,8 @@ class hgsubrepo(abstractsubrepo):
         for s, k in [('ui', 'commitsubrepos')]:
             v = r.ui.config(s, k)
             if v:
-                self._repo.ui.setconfig(s, k, v)
-        self._repo.ui.setconfig('ui', '_usedassubrepo', 'True')
+                self._repo.ui.setconfig(s, k, v, 'subrepo')
+        self._repo.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo')
         self._initrepo(r, state[0], create)
 
     def storeclean(self, path):
@@ -594,7 +594,7 @@ class hgsubrepo(abstractsubrepo):
             def addpathconfig(key, value):
                 if value:
                     fp.write('%s = %s\n' % (key, value))
-                    self._repo.ui.setconfig('paths', key, value)
+                    self._repo.ui.setconfig('paths', key, value, 'subrepo')
 
             defpath = _abssource(self._repo, abort=False)
             defpushpath = _abssource(self._repo, True, abort=False)
diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -170,7 +170,7 @@ class unionpeer(localrepo.localpeer):
 class unionrepository(localrepo.localrepository):
     def __init__(self, ui, path, path2):
         localrepo.localrepository.__init__(self, ui, path)
-        self.ui.setconfig('phases', 'publish', False)
+        self.ui.setconfig('phases', 'publish', False, 'unionrepo')
 
         self._url = 'union:%s+%s' % (util.expandpath(path),
                                      util.expandpath(path2))


More information about the Mercurial-devel mailing list