##// END OF EJS Templates
pycompat: custom implementation of urllib.parse.quote()...
pycompat: custom implementation of urllib.parse.quote() urllib.parse.quote() accepts either str or bytes and returns str. There exists a urllib.parse.quote_from_bytes() which only accepts bytes. We should probably use that to retain strong typing and avoid surprises. In addition, since nearly all strings in Mercurial are bytes, we probably don't want quote() returning unicode. So, this patch implements a custom quote() that only accepts bytes and returns bytes. The quoted URL should only contain URL safe characters which is a strict subset of ASCII. So `.encode('ascii', 'strict')` should be safe.

File last commit:

r30559:d83ca854 default
r31400:fb1f7033 default
Show More
test-hgwebdir-paths.py
48 lines | 1.1 KiB | text/x-python | PythonLexer
/ tests / test-hgwebdir-paths.py
Pulkit Goyal
tests: make test-hgwebdir-paths use absolute_import
r28932 from __future__ import absolute_import
Jeremy Whitlock
hgweb: make hgwebdir handle dict/list paths the same as config paths...
r8529 import os
Pulkit Goyal
tests: make test-hgwebdir-paths use absolute_import
r28932 from mercurial import (
hg,
ui as uimod,
)
from mercurial.hgweb import (
hgwebdir_mod,
)
hgwebdir = hgwebdir_mod.hgwebdir
Jeremy Whitlock
hgweb: make hgwebdir handle dict/list paths the same as config paths...
r8529
os.mkdir('webdir')
os.chdir('webdir')
Matt Mackall
backout dbdb777502dc (issue3077) (issue3071)...
r15381 webdir = os.path.realpath('.')
Jeremy Whitlock
hgweb: make hgwebdir handle dict/list paths the same as config paths...
r8529
Yuya Nishihara
ui: factor out ui.load() to create a ui without loading configs (API)...
r30559 u = uimod.ui.load()
Jeremy Whitlock
hgweb: make hgwebdir handle dict/list paths the same as config paths...
r8529 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