diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -75,7 +75,7 @@ class changectx(object): @propertycache def substate(self): - return subrepo.state(self) + return subrepo.state(self, self._repo.ui) def __contains__(self, key): return key in self._manifest diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -12,7 +12,7 @@ hg = None nullstate = ('', '', 'empty') -def state(ctx): +def state(ctx, ui): """return a state dict, mapping subrepo paths configured in .hgsub to tuple: (source from .hgsub, revision from .hgsubstate, kind (key in types dict)) @@ -27,6 +27,9 @@ def state(ctx): if '.hgsub' in ctx: read('.hgsub') + for path, src in ui.configitems('subpaths'): + p.set('subpaths', path, src, ui.configsource('subpaths', path)) + rev = {} if '.hgsubstate' in ctx: try: @@ -45,6 +48,14 @@ def state(ctx): raise util.Abort(_('missing ] in subrepo source')) kind, src = src.split(']', 1) kind = kind[1:] + + for pattern, repl in p.items('subpaths'): + try: + src = re.sub(pattern, repl, src, 1) + except re.error, e: + raise util.Abort(_("bad subrepository pattern in %s: %s") + % (p.source('subpaths', pattern), e)) + state[path] = (src.strip(), rev.get(path, ''), kind) return state diff --git a/tests/test-subrepo-paths b/tests/test-subrepo-paths new file mode 100755 --- /dev/null +++ b/tests/test-subrepo-paths @@ -0,0 +1,27 @@ +#!/bin/sh + +hg init outer +cd outer + +echo 'sub = http://example.net/libfoo' > .hgsub +hg add .hgsub + +echo '% hg debugsub with no remapping' +hg debugsub + +cat > .hg/hgrc < .hg/hgrc <&1 | "$TESTDIR/filtertmp.py" + +exit 0 diff --git a/tests/test-subrepo-paths.out b/tests/test-subrepo-paths.out new file mode 100644 --- /dev/null +++ b/tests/test-subrepo-paths.out @@ -0,0 +1,10 @@ +% hg debugsub with no remapping +path sub + source http://example.net/libfoo + revision +% hg debugsub with remapping +path sub + source ssh://localhost/libfoo + revision +% test bad subpaths pattern +abort: bad subrepository pattern in $HGTMP/test-subrepo-paths/outer/.hg/hgrc:2: invalid group reference