Commit Graph

50 Commits

Author SHA1 Message Date
Gregory Szorc
90bae1ad52 config: use absolute_import 2015-08-08 00:28:53 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Jordi Gutiérrez Hermoso
cdc5a09f13 config: give it an includepaths option for looking for config files
It is desirable to "derive" templates from the provided templates. A
simple way to do this is e.g.

    %include map-cmdline.default

in your own mapfile. Then you only have to redefine a few templates
instead of copying over the whole thing. This %include mechanism
already works for the built-in templates because by default it *only*
looks for files that are in the same directory as the including
mapfile.

With this changeset, config grows an option to add more include paths
for config files.
2015-05-15 09:04:32 -04:00
Matt Mackall
5bfd322b62 ui: move samplehgrcs from config
config is generic code that doesn't know about Mercurial usage, so
this was at the wrong layer
2014-09-11 12:26:12 -05:00
Matt Mackall
0653ac4e4b config: normalize style between user/global example configs 2014-09-11 12:21:15 -05:00
Jordi Gutiérrez Hermoso
f26ea7b700 config: propose some sample global config file
An example of what could be suggested to the user as a global config
file. Trying to be conservative here, and only suggesting the safest
possible extensions. In addition to the user-level extensions, the
blackbox extension is something a sysadmin might reasonable want to
enable for every repo on the system.
2014-08-24 19:45:46 -04:00
Jordi Gutiérrez Hermoso
87b5d13400 config: give more fine-tuned sample hgrcs to this command
The hgrc for user config is typically different from the hgrc at the
system-wide or repository level. This patch provides different sample
hgrcs for each level. Sometimes when copying repos around, the copy or
the original don't have a default path yet, so at least for `hg config
-l`, this ought to provide a more reasonable default and suggestions
of what typically goes there.

The actual sample configs go in the config.py file, to minimise
clutter. In order to avoid an unnecessary import, the corresponding
import for this dictionary is at the file level.
2014-08-13 17:05:48 -04:00
Pierre-Yves David
c79537766d config: fix restoreconfig of non existing config
When the section, but no value existed, the `del` call raised a key error.
2014-08-05 21:16:24 -07:00
Siddharth Agarwal
f1a50f9fee config: use util.re.compile instead of util.compilere 2014-07-15 14:50:58 -07:00
Angel Ezquerra
74f8eca049 config: move config.sortdict class into util
This makes it more natural to use the sortdict class from outside config.py.
2014-02-23 01:56:31 +01:00
Mads Kiilerich
41ac098c3e config: don't set source when no source is specified - don't overwrite with ''
This prevents ui.fixconfig from overwriting the source of paths and it will
thus show up in showconfig --debug.
2014-03-19 02:45:14 +01:00
FUJIWARA Katsunori
a48794b349 config: discard "%unset" values defined in the other files read in previously
Before this patch, "%unset" can't unset values defined in the other
files read in previously, even though online help document says that
it can. It can unset only values defined in the same configuration
file.

For example, the value defined in "~/.hgrc" can't be unset by "%unset"
in ".hg/hgrc" of the repository.

This patch records "%unset"-ed values in "config.parse()", and
discards corresponding values in "config.update()".
2013-04-26 23:36:12 +09:00
timeless@mozdev.org
5ac26e3e56 grammar: it-handles 2012-08-17 13:58:19 -07:00
timeless@mozdev.org
e014ca03ca spelling: value 2012-08-17 13:58:19 -07:00
Bryan O'Sullivan
229aceade4 config: use util.compilere to compile regexps 2012-06-01 15:26:46 -07:00
Angel Ezquerra
d0a81b6fbd config: make sortdict keys() and iterkeys() methods respect the item order
The config.sortdict class is a simple "sorted dictionary" container
class, based on python's regular dict container. The main difference
compared to regular dicts is that sortdicts remember the order in
which items have been added to it.

Without this patch the items() method returns the sortdict elements in
the right order. However, getting the list of keys by using the keys()
or iterkeys() methods, and consequencly, looping through the container
elements in a for loop does not respect that order. This patch fixes
this problem.
2012-05-29 23:26:55 +02:00
Matt Mackall
0dce04d2d0 config: discard UTF-8 BOM if found 2012-04-03 11:35:04 -05:00
Pierre-Yves David
3dfd3d6ee3 config: have a way to backup and restore value in config
This is introduce to allow temporary overwriting of a config value while being
able to reinstall the old value once done. The main advantage over using
``config`` and ``setconfig`` is that backup and restore will properly restore
the lack of any config. Restoring the fact that there was no value is important
to allow config user to keep using meaniful default value.

A more naive approach will result in the following scenario::

  Before:
    config(section, item, my_default) --> my_default

  temporal overwrite
    old = config(section, item)
    …
    setconfig(section, item, old)

  After
    config(section, item, my_default) --> None

The first user of this feature should be mq to overwriting minimal phase of
future commit.
2012-01-18 16:52:26 +01:00
Sune Foldager
ec11e30560 config.sortdict: override clear method
Overrides dict.clear. It's not currently used, but was broken for sortdict.
Contributed by Stepan Koltsov <yozh@mx1.ru>
2011-06-20 10:51:37 +02:00
Matt Mackall
eb5cc8dd93 config: undo change of empty line definition
We don't allow spaces in front of comment markers
2011-06-17 15:36:56 -05:00
Matt Mackall
bf73994e3d config: handle comment lines in continuations (issue2854) 2011-06-16 13:24:44 -05:00
Matt Mackall
ebb03b5a77 config: ignore include errors for nonexistent files 2011-05-31 16:00:39 -05:00
Adrian Buehlmann
c639e13569 config: use util.posixfile 2011-03-16 18:48:59 +01:00
Martin Geisler
6a3d9310ab code style: prefer 'is' and 'is not' tests with singletons 2010-11-22 18:15:58 +01:00
Matt Mackall
476998d3a8 error: fix up test-hgrc 2010-06-04 23:04:31 -05:00
Matt Mackall
969c51b3cf error: add new ParseError for various parsing errors 2010-06-04 20:57:26 -05:00
Chad Dombrova
2d1fae5fc2 config: expand hgrc %include paths 2010-05-26 14:03:29 -07:00
Matt Mackall
6bd5cfceca config: handle short continuations (issue1999)
Thanks to Greg Ward for spotting and testing
2010-01-28 23:07:28 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
46bbcdcea6 config: raise ConfigError on non-existing include files
Before, an %include directive for a non-existing file resulted in an
IOError and a traceback.
2009-12-12 16:46:16 +01:00
Martin Geisler
969ff27288 Merge with crew-stable 2009-09-19 13:55:18 +02:00
Nicolas Dumazet
7626c98965 config: abort on indented non-continuation lines (issue1829)
Previously, as soon as a continuation would be met, "cont" would stay
forever set to True, but "item" was set back to "None".
This caused the continuation code bits to run every time, until the next
"self.get(section, item) + '\n'" which would crash.
2009-09-12 11:17:07 +02:00
Andrey
b2bc363ed9 config: improve code readability 2009-08-12 11:50:27 +02:00
Nicolas Dumazet
7eadbe8d42 for calls expecting bool args, pass bool instead of int
str.splitlines and email.message.as_string both expect a bool argument
defaulting at False: replace f(1) by f(True) and f(0) by f()
2009-07-13 09:50:26 +09:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Matt Mackall
ec94003cea config: make remap actually work 2009-05-04 14:21:43 -05:00
Matt Mackall
83d555f0f7 config: add parse interface 2009-04-30 19:22:06 -05:00
Matt Mackall
f3552e4141 config: allow spaces in key portion of items 2009-04-29 20:47:30 -05:00
Martin Geisler
539f6e1aac config: add copyright and license header 2009-04-26 01:56:41 +02:00
Dirkjan Ochtman
80de6974e4 more whitespace cleanup and some other style nits 2009-04-27 12:37:19 +02:00
Matt Mackall
86dab18ddb config: getsource -> source 2009-04-26 16:50:43 -05:00
Matt Mackall
036f77e767 config: add section filter to read
move section filtering out of ui.readconfig
kill section filtering in config.update
2009-04-26 16:50:43 -05:00
Matt Mackall
f74e9a6511 config: deal with spaces at end of line more carefully 2009-04-26 16:50:43 -05:00
Matt Mackall
10af375ad9 ui: less links to parentui 2009-04-26 16:50:43 -05:00
Matt Mackall
1217ed8107 config: add some helper methods 2009-04-26 16:50:43 -05:00
Matt Mackall
9c7f505708 config: split source data out into separate map 2009-04-26 16:50:43 -05:00
Matt Mackall
a85b71443f config: add %unset name support 2009-04-26 16:50:43 -05:00
Matt Mackall
bc6c19544f config: allow including other config files 2009-04-26 16:50:43 -05:00
Matt Mackall
8034ce6ca9 hgweb: use config.config 2009-04-26 16:50:43 -05:00
Matt Mackall
e8b3de6bf8 ui: introduce new config parser 2009-04-23 15:40:10 -05:00