[PATCH] configuration: --norc option disables custom config files (issue3147)
Alexander Plavin
me at aplavin.ru
Fri Apr 19 13:44:15 CDT 2013
# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1366396791 -14400
# Fri Apr 19 22:39:51 2013 +0400
# Branch stable
# Node ID c1d33cc4465312478b8446c00c5a85c9eccae4a9
# Parent e57ef039ba021471c012451da6cc1b9afd86e30a
configuration: --norc option disables custom config files (issue3147)
Use default settings insted of custom ones in --norc option is specified
diff -r e57ef039ba02 -r c1d33cc44653 mercurial/commands.py
--- a/mercurial/commands.py Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/commands.py Fri Apr 19 22:39:51 2013 +0400
@@ -50,6 +50,7 @@
('', 'version', None, _('output version information and exit')),
('h', 'help', None, _('display help and exit')),
('', 'hidden', False, _('consider hidden changesets')),
+ ('', 'norc', False, _('use default configuration, ignore all hgrc files')),
]
dryrunopts = [('n', 'dry-run', None,
diff -r e57ef039ba02 -r c1d33cc44653 mercurial/config.py
--- a/mercurial/config.py Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/config.py Fri Apr 19 22:39:51 2013 +0400
@@ -104,6 +104,10 @@
del self._data[section][item]
self._source.pop((section, item), None)
+ def clear(self):
+ self._data = {}
+ self._source = {}
+
def parse(self, src, data, sections=None, remap=None, include=None):
sectionre = util.compilere(r'\[([^\[]+)\]')
itemre = util.compilere(r'([^=\s][^=]*?)\s*=\s*(.*\S|)')
diff -r e57ef039ba02 -r c1d33cc44653 mercurial/dispatch.py
--- a/mercurial/dispatch.py Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/dispatch.py Fri Apr 19 22:39:51 2013 +0400
@@ -670,6 +670,10 @@
for cfg in cfgs:
req.repo.ui.setconfig(*cfg)
+ if options['norc']:
+ for ui_ in uis:
+ ui_.clearconfig()
+
if options['verbose'] or options['debug'] or options['quiet']:
for opt in ('verbose', 'debug', 'quiet'):
val = str(bool(options[opt]))
@@ -714,6 +718,8 @@
raise util.Abort(_("repository '%s' is not local") % path)
if options['hidden']:
repo = repo.unfiltered()
+ if options['norc']:
+ repo.ui.clearconfig()
repo.ui.setconfig("bundle", "mainreporoot", repo.root)
except error.RequirementError:
raise
diff -r e57ef039ba02 -r c1d33cc44653 mercurial/ui.py
--- a/mercurial/ui.py Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/ui.py Fri Apr 19 22:39:51 2013 +0400
@@ -163,6 +163,11 @@
self._ucfg.set(section, name, value)
self.fixconfig(section=section)
+ def clearconfig(self):
+ self._tcfg.clear()
+ self._ucfg.clear()
+ self._ocfg.clear()
+
def _data(self, untrusted):
return untrusted and self._ucfg or self._tcfg
diff -r e57ef039ba02 -r c1d33cc44653 tests/test-completion.t
--- a/tests/test-completion.t Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-completion.t Fri Apr 19 22:39:51 2013 +0400
@@ -127,6 +127,7 @@
--help
--hidden
--noninteractive
+ --norc
--profile
--quiet
--repository
@@ -160,6 +161,7 @@
--ipv6
--name
--noninteractive
+ --norc
--pid-file
--port
--prefix
diff -r e57ef039ba02 -r c1d33cc44653 tests/test-extension.t
--- a/tests/test-extension.t Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-extension.t Fri Apr 19 22:39:51 2013 +0400
@@ -202,6 +202,7 @@
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
+ --norc use default configuration, ignore all hgrc files
[+] marked option can be specified multiple times
@@ -233,6 +234,7 @@
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
+ --norc use default configuration, ignore all hgrc files
[+] marked option can be specified multiple times
$ echo 'debugextension = !' >> $HGRCPATH
diff -r e57ef039ba02 -r c1d33cc44653 tests/test-help.t
--- a/tests/test-help.t Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-help.t Fri Apr 19 22:39:51 2013 +0400
@@ -249,6 +249,7 @@
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
+ --norc use default configuration, ignore all hgrc files
[+] marked option can be specified multiple times
@@ -336,6 +337,7 @@
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
+ --norc use default configuration, ignore all hgrc files
[+] marked option can be specified multiple times
@@ -1599,6 +1601,9 @@
<tr><td></td>
<td>--hidden</td>
<td>consider hidden changesets</td></tr>
+ <tr><td></td>
+ <td>--norc</td>
+ <td>use default configuration, ignore all hgrc files</td></tr>
</table>
<p>
[+] marked option can be specified multiple times
@@ -1751,6 +1756,9 @@
<tr><td></td>
<td>--hidden</td>
<td>consider hidden changesets</td></tr>
+ <tr><td></td>
+ <td>--norc</td>
+ <td>use default configuration, ignore all hgrc files</td></tr>
</table>
<p>
[+] marked option can be specified multiple times
diff -r e57ef039ba02 -r c1d33cc44653 tests/test-hgrc.t
--- a/tests/test-hgrc.t Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-hgrc.t Fri Apr 19 22:39:51 2013 +0400
@@ -51,6 +51,10 @@
foo.bar=a\nb\nc\nde\nfg
foo.baz=bif cb
+ $ hg --norc showconfig
+ bundle.mainreporoot=$TESTTMP
+ $ hg --norc showconfig foo
+
$ FAKEPATH=/path/to/nowhere
$ export FAKEPATH
$ echo '%include $FAKEPATH/no-such-file' > $HGRC
More information about the Mercurial-devel
mailing list