diff --git a/mercurial/context.py b/mercurial/context.py index 91c4e6d2c9e55d5a7ad0e665a964bfb2a630b17b_bWVyY3VyaWFsL2NvbnRleHQucHk=..a8614c5a5e9a312c7f4d956e9b19af5314f48ce6_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644 --- a/mercurial/context.py +++ b/mercurial/context.py @@ -75,7 +75,7 @@ @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 index 91c4e6d2c9e55d5a7ad0e665a964bfb2a630b17b_bWVyY3VyaWFsL3N1YnJlcG8ucHk=..a8614c5a5e9a312c7f4d956e9b19af5314f48ce6_bWVyY3VyaWFsL3N1YnJlcG8ucHk= 100644 --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -12,7 +12,7 @@ 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 @@ 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 @@ 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 index 0000000000000000000000000000000000000000..a8614c5a5e9a312c7f4d956e9b19af5314f48ce6_dGVzdHMvdGVzdC1zdWJyZXBvLXBhdGhz --- /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 <<EOF +[subpaths] +http://example.net = ssh://localhost +EOF + +echo '% hg debugsub with remapping' +hg debugsub + +echo '% test bad subpaths pattern' +cat > .hg/hgrc <<EOF +[subpaths] +.* = \1 +EOF +hg debugsub 2>&1 | "$TESTDIR/filtertmp.py" + +exit 0 diff --git a/tests/test-subrepo-paths.out b/tests/test-subrepo-paths.out new file mode 100644 index 0000000000000000000000000000000000000000..a8614c5a5e9a312c7f4d956e9b19af5314f48ce6_dGVzdHMvdGVzdC1zdWJyZXBvLXBhdGhzLm91dA== --- /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