Mercurial > public > mercurial-scm > hg-stable
diff tests/test-hgwebdir-paths.py @ 8529:a767998f0a78
hgweb: make hgwebdir handle dict/list paths the same as config paths
Before this patch, the only way to get hgwebdir to honor the recursive paths
was to create a config object or a config file with the recursive paths in it.
This patch makes hgwebdir treat paths the same whether passed in as a list,
tuple, config or however hgwebdir supports passing paths.
author | Jeremy Whitlock <jcscoobyrs@gmail.com> |
---|---|
date | Wed, 20 May 2009 16:04:37 +0200 |
parents | |
children | dbdb777502dc |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-hgwebdir-paths.py Wed May 20 16:04:37 2009 +0200 @@ -0,0 +1,40 @@ +import os +from mercurial import hg, ui +from mercurial.hgweb.hgwebdir_mod import hgwebdir + +os.mkdir('webdir') +os.chdir('webdir') + +webdir = os.path.realpath('.') + +u = ui.ui() +hg.repository(u, 'a', create=1) +hg.repository(u, 'b', create=1) +os.chdir('b') +hg.repository(u, 'd', create=1) +os.chdir('..') +hg.repository(u, 'c', create=1) +os.chdir('..') + +paths = {'t/a/': '%s/a' % webdir, + 'b': '%s/b' % webdir, + 'coll': '%s/*' % webdir, + 'rcoll': '%s/**' % webdir} + +config = os.path.join(webdir, 'hgwebdir.conf') +configfile = open(config, 'w') +configfile.write('[paths]\n') +for k, v in paths.items(): + configfile.write('%s = %s\n' % (k, v)) +configfile.close() + +confwd = hgwebdir(config) +dictwd = hgwebdir(paths) + +assert len(confwd.repos) == len(dictwd.repos), 'different numbers' +assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos) + +found = dict(confwd.repos) +for key, path in dictwd.repos: + assert key in found, 'repository %s was not found' % key + assert found[key] == path, 'different paths for repo %s' % key