comparison 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
comparison
equal deleted inserted replaced
8528:4ddffb793d18 8529:a767998f0a78
1 import os
2 from mercurial import hg, ui
3 from mercurial.hgweb.hgwebdir_mod import hgwebdir
4
5 os.mkdir('webdir')
6 os.chdir('webdir')
7
8 webdir = os.path.realpath('.')
9
10 u = ui.ui()
11 hg.repository(u, 'a', create=1)
12 hg.repository(u, 'b', create=1)
13 os.chdir('b')
14 hg.repository(u, 'd', create=1)
15 os.chdir('..')
16 hg.repository(u, 'c', create=1)
17 os.chdir('..')
18
19 paths = {'t/a/': '%s/a' % webdir,
20 'b': '%s/b' % webdir,
21 'coll': '%s/*' % webdir,
22 'rcoll': '%s/**' % webdir}
23
24 config = os.path.join(webdir, 'hgwebdir.conf')
25 configfile = open(config, 'w')
26 configfile.write('[paths]\n')
27 for k, v in paths.items():
28 configfile.write('%s = %s\n' % (k, v))
29 configfile.close()
30
31 confwd = hgwebdir(config)
32 dictwd = hgwebdir(paths)
33
34 assert len(confwd.repos) == len(dictwd.repos), 'different numbers'
35 assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos)
36
37 found = dict(confwd.repos)
38 for key, path in dictwd.repos:
39 assert key in found, 'repository %s was not found' % key
40 assert found[key] == path, 'different paths for repo %s' % key