##// END OF EJS Templates
subrepos: support remapping of .hgsub source paths...
Martin Geisler -
r11775:a8614c5a default
parent child Browse files
Show More
@@ -0,0 +1,27 b''
1 #!/bin/sh
2
3 hg init outer
4 cd outer
5
6 echo 'sub = http://example.net/libfoo' > .hgsub
7 hg add .hgsub
8
9 echo '% hg debugsub with no remapping'
10 hg debugsub
11
12 cat > .hg/hgrc <<EOF
13 [subpaths]
14 http://example.net = ssh://localhost
15 EOF
16
17 echo '% hg debugsub with remapping'
18 hg debugsub
19
20 echo '% test bad subpaths pattern'
21 cat > .hg/hgrc <<EOF
22 [subpaths]
23 .* = \1
24 EOF
25 hg debugsub 2>&1 | "$TESTDIR/filtertmp.py"
26
27 exit 0
@@ -0,0 +1,10 b''
1 % hg debugsub with no remapping
2 path sub
3 source http://example.net/libfoo
4 revision
5 % hg debugsub with remapping
6 path sub
7 source ssh://localhost/libfoo
8 revision
9 % test bad subpaths pattern
10 abort: bad subrepository pattern in $HGTMP/test-subrepo-paths/outer/.hg/hgrc:2: invalid group reference
@@ -75,7 +75,7 b' class changectx(object):'
75
75
76 @propertycache
76 @propertycache
77 def substate(self):
77 def substate(self):
78 return subrepo.state(self)
78 return subrepo.state(self, self._repo.ui)
79
79
80 def __contains__(self, key):
80 def __contains__(self, key):
81 return key in self._manifest
81 return key in self._manifest
@@ -12,7 +12,7 b' hg = None'
12
12
13 nullstate = ('', '', 'empty')
13 nullstate = ('', '', 'empty')
14
14
15 def state(ctx):
15 def state(ctx, ui):
16 """return a state dict, mapping subrepo paths configured in .hgsub
16 """return a state dict, mapping subrepo paths configured in .hgsub
17 to tuple: (source from .hgsub, revision from .hgsubstate, kind
17 to tuple: (source from .hgsub, revision from .hgsubstate, kind
18 (key in types dict))
18 (key in types dict))
@@ -27,6 +27,9 b' def state(ctx):'
27 if '.hgsub' in ctx:
27 if '.hgsub' in ctx:
28 read('.hgsub')
28 read('.hgsub')
29
29
30 for path, src in ui.configitems('subpaths'):
31 p.set('subpaths', path, src, ui.configsource('subpaths', path))
32
30 rev = {}
33 rev = {}
31 if '.hgsubstate' in ctx:
34 if '.hgsubstate' in ctx:
32 try:
35 try:
@@ -45,6 +48,14 b' def state(ctx):'
45 raise util.Abort(_('missing ] in subrepo source'))
48 raise util.Abort(_('missing ] in subrepo source'))
46 kind, src = src.split(']', 1)
49 kind, src = src.split(']', 1)
47 kind = kind[1:]
50 kind = kind[1:]
51
52 for pattern, repl in p.items('subpaths'):
53 try:
54 src = re.sub(pattern, repl, src, 1)
55 except re.error, e:
56 raise util.Abort(_("bad subrepository pattern in %s: %s")
57 % (p.source('subpaths', pattern), e))
58
48 state[path] = (src.strip(), rev.get(path, ''), kind)
59 state[path] = (src.strip(), rev.get(path, ''), kind)
49
60
50 return state
61 return state
General Comments 0
You need to be logged in to leave comments. Login now