##// END OF EJS Templates
subrepo: calculate _relpath for hgsubrepo based on self instead of parent...
subrepo: calculate _relpath for hgsubrepo based on self instead of parent Prior to 105758d1b37b, the subrelpath() (now _relpath) for hgsubrepo was calculated by removing the root path of the outermost repo from the root path of the subrepo. Since the root paths use platform specific separators, and the relative path is printed by various commands, the output of these commands require a glob (and check-code.py enforces this). In an effort to be generic to all subrepos, 105758d1b37b started calculating this path based on the parent repo, and then joining the subrepo path in .hgsub. One of the tests in test-subrepo.t creates a subrepo inside a directory, so the path being joined contained '/' instead of '\'. This made the test fail with a '~' status, because the glob is unnecessary[1]. Removing them made the test work, but then check-code complains. We can't just drop the check-code rule, because sub-subrepos are still joined with '\'. Presumably the other subrepo types have this issue as well, but there likely isn't a test with git or svn repos inside a subdirectory. This simply restores the exact _relpath value (and output) for hgsubrepos prior to 105758d1b37b. [1] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068720.html

File last commit:

r24543:74740108 default
r24786:56e15db9 default
Show More
get-with-headers.py
88 lines | 2.4 KiB | text/x-python | PythonLexer
/ tests / get-with-headers.py
Eric Hopper
Add a test for getting raw files via the web UI.
r2532 #!/usr/bin/env python
Martin Geisler
tests: fix doc string in get-with-headers.py
r8447 """This does HTTP GET requests given a host:port and path and returns
Eric Hopper
Add a test for getting raw files via the web UI.
r2532 a subset of the headers plus the body of the result."""
Nicolas Dumazet
pylint, pyflakes: remove unused or duplicate imports
r10905 import httplib, sys
Patrick Mezard
get-with-headers: fix stream modes under Windows
r7054
try:
Gregory Szorc
get-with-headers: support parsing and pretty printing JSON...
r24543 import json
except ImportError:
try:
import simplejson as json
except ImportError:
json = None
try:
Patrick Mezard
get-with-headers: fix stream modes under Windows
r7054 import msvcrt, os
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 twice = False
if '--twice' in sys.argv:
sys.argv.remove('--twice')
twice = True
Pierre-Yves David
get-with-headers: add a --headeronly switch...
r18400 headeronly = False
if '--headeronly' in sys.argv:
sys.argv.remove('--headeronly')
headeronly = True
Gregory Szorc
get-with-headers: support parsing and pretty printing JSON...
r24543 formatjson = False
if '--json' in sys.argv:
sys.argv.remove('--json')
formatjson = True
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182
Dirkjan Ochtman
tests: fix incompatibility with python-2.4 in test-hgweb...
r12250 reasons = {'Not modified': 'Not Modified'} # python 2.4
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 tag = None
def request(host, path, show):
Mads Kiilerich
tests: prepare get-with-headers.py for MSYS...
r17017 assert not path.startswith('/'), path
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 global tag
headers = {}
if tag:
headers['If-None-Match'] = tag
Bryan O'Sullivan
hgweb: return meaningful HTTP status codes instead of nonsense
r5561
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 conn = httplib.HTTPConnection(host)
Mads Kiilerich
tests: prepare get-with-headers.py for MSYS...
r17017 conn.request("GET", '/' + path, None, headers)
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 response = conn.getresponse()
Dirkjan Ochtman
tests: fix incompatibility with python-2.4 in test-hgweb...
r12250 print response.status, reasons.get(response.reason, response.reason)
Mads Kiilerich
serve: don't send any content headers with 304 responses...
r18380 if show[:1] == ['-']:
Mads Kiilerich
tests: make test-hgweb.t output stable...
r18393 show = sorted(h for h, v in response.getheaders()
if h.lower() not in show)
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182 for h in [h.lower() for h in show]:
if response.getheader(h, None) is not None:
print "%s: %s" % (h, response.getheader(h))
Pierre-Yves David
get-with-headers: add a --headeronly switch...
r18400 if not headeronly:
print
Gregory Szorc
hgweb: send proper HTTP response after uncaught exception...
r23409 data = response.read()
Gregory Szorc
get-with-headers: support parsing and pretty printing JSON...
r24543
# Pretty print JSON. This also has the beneficial side-effect
# of verifying emitted JSON is well-formed.
if formatjson:
if not json:
print 'no json module not available'
print 'did you forget a #require json?'
sys.exit(1)
# json.dumps() will print trailing newlines. Eliminate them
# to make tests easier to write.
data = json.loads(data)
lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
for line in lines:
print line.rstrip()
else:
sys.stdout.write(data)
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182
Pierre-Yves David
get-with-headers: add a --headeronly switch...
r18400 if twice and response.getheader('ETag', None):
tag = response.getheader('ETag')
Dirkjan Ochtman
tests: extend get-with-headers to support cache testing
r12182
return response.status
status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
if twice:
status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
if 200 <= status <= 305:
Bryan O'Sullivan
hgweb: return meaningful HTTP status codes instead of nonsense
r5561 sys.exit(0)
sys.exit(1)