##// END OF EJS Templates
hgweb: doctest of url creation from wildcard expansion
Mads Kiilerich -
r13402:f947d9a4 default
parent child Browse files
Show More
@@ -33,14 +33,25 b' def findrepos(paths):'
33 repos.append((prefix, root))
33 repos.append((prefix, root))
34 continue
34 continue
35 roothead = os.path.normpath(os.path.abspath(roothead))
35 roothead = os.path.normpath(os.path.abspath(roothead))
36 for path in util.walkrepos(roothead, followsym=True, recurse=recurse):
36 paths = util.walkrepos(roothead, followsym=True, recurse=recurse)
37 path = os.path.normpath(path)
37 repos.extend(urlrepos(prefix, roothead, paths))
38 name = util.pconvert(path[len(roothead):]).strip('/')
39 if prefix:
40 name = prefix + '/' + name
41 repos.append((name, path))
42 return repos
38 return repos
43
39
40 def urlrepos(prefix, roothead, paths):
41 """yield url paths and filesystem paths from a list of repo paths
42
43 >>> list(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
44 [('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg/', '/opt')]
45 >>> list(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
46 [('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')]
47 """
48 for path in paths:
49 path = os.path.normpath(path)
50 name = util.pconvert(path[len(roothead):]).strip('/')
51 if prefix:
52 name = prefix + '/' + name
53 yield name, path
54
44 class hgwebdir(object):
55 class hgwebdir(object):
45 refreshinterval = 20
56 refreshinterval = 20
46
57
@@ -22,5 +22,8 b' doctest.testmod(mercurial.util)'
22 import mercurial.encoding
22 import mercurial.encoding
23 doctest.testmod(mercurial.encoding)
23 doctest.testmod(mercurial.encoding)
24
24
25 import mercurial.hgweb.hgwebdir_mod
26 doctest.testmod(mercurial.hgweb.hgwebdir_mod)
27
25 import hgext.convert.cvsps
28 import hgext.convert.cvsps
26 doctest.testmod(hgext.convert.cvsps)
29 doctest.testmod(hgext.convert.cvsps)
General Comments 0
You need to be logged in to leave comments. Login now