| 1 |
import os |
| 2 |
from mercurial import ( |
| 3 |
ui as uimod, |
| 4 |
) |
| 5 |
from mercurial.hgweb import hgwebdir_mod |
| 6 |
from mercurial.repo import factory |
| 7 |
|
| 8 |
hgwebdir = hgwebdir_mod.hgwebdir |
| 9 |
|
| 10 |
os.mkdir(b'webdir') |
| 11 |
os.chdir(b'webdir') |
| 12 |
|
| 13 |
webdir = os.path.realpath(b'.') |
| 14 |
|
| 15 |
u = uimod.ui.load() |
| 16 |
factory.repository(u, b'a', create=1) |
| 17 |
factory.repository(u, b'b', create=1) |
| 18 |
os.chdir(b'b') |
| 19 |
factory.repository(u, b'd', create=1) |
| 20 |
os.chdir(b'..') |
| 21 |
factory.repository(u, b'c', create=1) |
| 22 |
os.chdir(b'..') |
| 23 |
|
| 24 |
paths = { |
| 25 |
b't/a/': b'%s/a' % webdir, |
| 26 |
b'b': b'%s/b' % webdir, |
| 27 |
b'coll': b'%s/*' % webdir, |
| 28 |
b'rcoll': b'%s/**' % webdir, |
| 29 |
} |
| 30 |
|
| 31 |
config = os.path.join(webdir, b'hgwebdir.conf') |
| 32 |
configfile = open(config, 'wb') |
| 33 |
configfile.write(b'[paths]\n') |
| 34 |
for k, v in paths.items(): |
| 35 |
configfile.write(b'%s = %s\n' % (k, v)) |
| 36 |
configfile.close() |
| 37 |
|
| 38 |
confwd = hgwebdir(config) |
| 39 |
dictwd = hgwebdir(paths) |
| 40 |
|
| 41 |
assert len(confwd.repos) == len(dictwd.repos), 'different numbers' |
| 42 |
assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos) |
| 43 |
|
| 44 |
found = dict(confwd.repos) |
| 45 |
for key, path in dictwd.repos: |
| 46 |
assert key in found, 'repository %s was not found' % key |
| 47 |
assert found[key] == path, 'different paths for repo %s' % key |