changeset 11224:f23f87462c18

config: expand hgrc %include paths
author Chad Dombrova <chadrik@gmail.com>
date Wed, 26 May 2010 14:03:29 -0700
parents 0d09f2244805
children d6dbd5e4ee72
files mercurial/config.py tests/test-hgrc tests/test-hgrc.out
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/config.py	Wed May 26 16:16:47 2010 +0200
+++ b/mercurial/config.py	Wed May 26 14:03:29 2010 -0700
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-import error
+import error, util
 import re, os
 
 class sortdict(dict):
@@ -96,7 +96,7 @@
                 cont = False
             m = includere.match(l)
             if m:
-                inc = m.group(1)
+                inc = util.expandpath(m.group(1))
                 base = os.path.dirname(src)
                 inc = os.path.normpath(os.path.join(base, inc))
                 if include:
--- a/tests/test-hgrc	Wed May 26 16:16:47 2010 +0200
+++ b/tests/test-hgrc	Wed May 26 14:03:29 2010 -0700
@@ -23,8 +23,11 @@
     > $HGRCPATH
 hg showconfig foo
 
-echo '%include /no-such-file' > $HGRCPATH
+FAKEPATH=/path/to/nowhere
+export FAKEPATH
+echo '%include $FAKEPATH/no-such-file' > $HGRCPATH
 hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
+unset FAKEPATH
 
 # HGPLAIN
 cd ..
--- a/tests/test-hgrc.out	Wed May 26 16:16:47 2010 +0200
+++ b/tests/test-hgrc.out	Wed May 26 14:03:29 2010 -0700
@@ -9,7 +9,7 @@
 hg: config error at $HGRCPATH:2: '  x = y'
 foo.bar=a\nb\nc\nde\nfg
 foo.baz=bif cb
-hg: config error at $HGRCPATH:1: cannot include /no-such-file (No such file or directory)
+hg: config error at $HGRCPATH:1: cannot include /path/to/nowhere/no-such-file (No such file or directory)
 % customized hgrc
 read config from: .../.hgrc
 .../.hgrc:13: alias.log=log -g