Mercurial > hg-stable
changeset 13402:f947d9a4c45c
hgweb: doctest of url creation from wildcard expansion
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 15 Feb 2011 01:04:10 +0100 |
parents | 12773f1b7728 |
children | 8ed91088acbb |
files | mercurial/hgweb/hgwebdir_mod.py tests/test-doctest.py |
diffstat | 2 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Mon Feb 14 18:04:20 2011 -0600 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Feb 15 01:04:10 2011 +0100 @@ -33,14 +33,25 @@ repos.append((prefix, root)) continue roothead = os.path.normpath(os.path.abspath(roothead)) - for path in util.walkrepos(roothead, followsym=True, recurse=recurse): - path = os.path.normpath(path) - name = util.pconvert(path[len(roothead):]).strip('/') - if prefix: - name = prefix + '/' + name - repos.append((name, path)) + paths = util.walkrepos(roothead, followsym=True, recurse=recurse) + repos.extend(urlrepos(prefix, roothead, paths)) return repos +def urlrepos(prefix, roothead, paths): + """yield url paths and filesystem paths from a list of repo paths + + >>> list(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) + [('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg/', '/opt')] + >>> list(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) + [('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')] + """ + for path in paths: + path = os.path.normpath(path) + name = util.pconvert(path[len(roothead):]).strip('/') + if prefix: + name = prefix + '/' + name + yield name, path + class hgwebdir(object): refreshinterval = 20
--- a/tests/test-doctest.py Mon Feb 14 18:04:20 2011 -0600 +++ b/tests/test-doctest.py Tue Feb 15 01:04:10 2011 +0100 @@ -22,5 +22,8 @@ import mercurial.encoding doctest.testmod(mercurial.encoding) +import mercurial.hgweb.hgwebdir_mod +doctest.testmod(mercurial.hgweb.hgwebdir_mod) + import hgext.convert.cvsps doctest.testmod(hgext.convert.cvsps)