##// END OF EJS Templates
hgweb: extend [paths] syntax to match repositories recursively (issue852)...
Patrick Mezard -
r7450:79d1bb73 default
parent child Browse files
Show More
@@ -29,12 +29,28 b' from flup.server.fcgi import WSGIServer'
29 # repos, collections of repos in a directory tree, or both.
29 # repos, collections of repos in a directory tree, or both.
30 #
30 #
31 # [paths]
31 # [paths]
32 # virtual/path = /real/path
32 # virtual/path1 = /real/path1
33 # virtual/path = /real/path
33 # virtual/path2 = /real/path2
34 # virtual/root = /real/root/*
35 # / = /real/root2/*
34 #
36 #
35 # [collections]
37 # [collections]
36 # /prefix/to/strip/off = /root/of/tree/full/of/repos
38 # /prefix/to/strip/off = /root/of/tree/full/of/repos
37 #
39 #
40 # paths example:
41 #
42 # * First two lines mount one repository into one virtual path, like
43 # '/real/path1' into 'virtual/path1'.
44 #
45 # * The third entry tells every mercurial repository found in
46 # '/real/root', recursively, should be mounted in 'virtual/root'. This
47 # format is preferred over the [collections] one, using absolute paths
48 # as configuration keys is not supported on every platform (including
49 # Windows).
50 #
51 # * The last entry is a special case mounting all repositories in
52 # '/real/root2' in the root of the virtual directory.
53 #
38 # collections example: say directory tree /foo contains repos /foo/bar,
54 # collections example: say directory tree /foo contains repos /foo/bar,
39 # /foo/quux/baz. Give this config section:
55 # /foo/quux/baz. Give this config section:
40 # [collections]
56 # [collections]
@@ -28,12 +28,28 b' import mercurial.hgweb.wsgicgi as wsgicg'
28 # repos, collections of repos in a directory tree, or both.
28 # repos, collections of repos in a directory tree, or both.
29 #
29 #
30 # [paths]
30 # [paths]
31 # virtual/path = /real/path
31 # virtual/path1 = /real/path1
32 # virtual/path = /real/path
32 # virtual/path2 = /real/path2
33 # virtual/root = /real/root/*
34 # / = /real/root2/*
33 #
35 #
34 # [collections]
36 # [collections]
35 # /prefix/to/strip/off = /root/of/tree/full/of/repos
37 # /prefix/to/strip/off = /root/of/tree/full/of/repos
36 #
38 #
39 # paths example:
40 #
41 # * First two lines mount one repository into one virtual path, like
42 # '/real/path1' into 'virtual/path1'.
43 #
44 # * The third entry tells every mercurial repository found in
45 # '/real/root', recursively, should be mounted in 'virtual/root'. This
46 # format is preferred over the [collections] one, using absolute paths
47 # as configuration keys is not supported on every platform (including
48 # Windows).
49 #
50 # * The last entry is a special case mounting all repositories in
51 # /'real/root2' in the root of the virtual directory.
52 #
37 # collections example: say directory tree /foo contains repos /foo/bar,
53 # collections example: say directory tree /foo contains repos /foo/bar,
38 # /foo/quux/baz. Give this config section:
54 # /foo/quux/baz. Give this config section:
39 # [collections]
55 # [collections]
@@ -51,7 +51,21 b' class hgwebdir(object):'
51 if cp.has_option('web', 'baseurl'):
51 if cp.has_option('web', 'baseurl'):
52 self._baseurl = cp.get('web', 'baseurl')
52 self._baseurl = cp.get('web', 'baseurl')
53 if cp.has_section('paths'):
53 if cp.has_section('paths'):
54 self.repos.extend(cleannames(cp.items('paths')))
54 paths = cleannames(cp.items('paths'))
55 for prefix, root in paths:
56 roothead, roottail = os.path.split(root)
57 if roottail != '*':
58 self.repos.append((prefix, root))
59 continue
60 # "foo = /bar/*" makes every subrepo of /bar/ to be
61 # mounted as foo/subrepo
62 roothead = os.path.normpath(roothead)
63 for path in util.walkrepos(roothead, followsym=True):
64 path = os.path.normpath(path)
65 name = util.pconvert(path[len(roothead):]).strip('/')
66 if prefix:
67 name = prefix + '/' + name
68 self.repos.append((name, path))
55 if cp.has_section('collections'):
69 if cp.has_section('collections'):
56 for prefix, root in cp.items('collections'):
70 for prefix, root in cp.items('collections'):
57 for path in util.walkrepos(root, followsym=True):
71 for path in util.walkrepos(root, followsym=True):
@@ -51,6 +51,7 b' cat > paths.conf <<EOF'
51 [paths]
51 [paths]
52 t/a/=$root/a
52 t/a/=$root/a
53 b=$root/b
53 b=$root/b
54 coll=$root/*
54 EOF
55 EOF
55
56
56 hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
57 hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
@@ -66,6 +67,9 b' echo % should succeed, slashy names'
66 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/?style=atom' \
67 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/?style=atom' \
67 | sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//"
68 | sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//"
68 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/file/tip/a?style=raw'
69 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/file/tip/a?style=raw'
70 # Test [paths] '*' extension
71 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/coll/?style=raw'
72 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/coll/a/file/tip/a?style=raw'
69
73
70 cat > collections.conf <<EOF
74 cat > collections.conf <<EOF
71 [collections]
75 [collections]
@@ -30,6 +30,10 b' 200 Script output follows'
30
30
31
31
32 /b/
32 /b/
33 /coll/a/
34 /coll/b/
35 /coll/b/d/
36 /coll/c/
33 /t/a/
37 /t/a/
34
38
35 200 Script output follows
39 200 Script output follows
@@ -103,6 +107,17 b' 200 Script output follows'
103 200 Script output follows
107 200 Script output follows
104
108
105 a
109 a
110 200 Script output follows
111
112
113 /coll/a/
114 /coll/b/
115 /coll/b/d/
116 /coll/c/
117
118 200 Script output follows
119
120 a
106 % should succeed
121 % should succeed
107 200 Script output follows
122 200 Script output follows
108
123
General Comments 0
You need to be logged in to leave comments. Login now