# HG changeset patch # User Matt Mackall # Date 1240782643 18000 # Node ID 2858ab754995b909bebaac74cd03b1845bf2bf2b # Parent b97abc7c1135cf09663ca7a4390fe207289a1133 config: allow including other config files diff -r b97abc7c1135 -r 2858ab754995 mercurial/config.py --- a/mercurial/config.py Sun Apr 26 16:50:43 2009 -0500 +++ b/mercurial/config.py Sun Apr 26 16:50:43 2009 -0500 @@ -1,5 +1,5 @@ from i18n import _ -import re, error +import re, error, os class sortdict(dict): 'a simple append-only sorted dictionary' @@ -62,6 +62,7 @@ itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') contre = re.compile(r'\s+(\S.*)') emptyre = re.compile(r'(;|#|\s*$)') + includere = re.compile(r'%include\s+(\S.*)') section = "" item = None line = 0 @@ -79,6 +80,14 @@ self.set(section, item, v, "%s:%d" % (path, line)) continue item = None + m = includere.match(l) + if m: + inc = m.group(1) + base = os.path.dirname(path) + inc = os.path.normpath(os.path.join(base, inc)) + incfp = open(inc) + self.read(inc, incfp) + continue if emptyre.match(l): continue m = sectionre.match(l)