[PATCH 1 of 2 V5] test-archive: gracefully handle HTTPErrors on get-with-headers
Angel Ezquerra
angel.ezquerra at gmail.com
Sun Feb 17 17:14:00 CST 2013
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1360141605 -3600
# Node ID 2f7b559540108a021cba31c0c7affa011ef119cc
# Parent 013fcd112f13f31a35ea6a40d8cd1c6923cdaf20
test-archive: gracefully handle HTTPErrors on get-with-headers
This avoids pritting out a traceback when a get-with-headers call causes hgweb
to respond with an HTTPError code.
diff --git a/tests/test-archive.t b/tests/test-archive.t
--- a/tests/test-archive.t
+++ b/tests/test-archive.t
@@ -69,10 +69,18 @@
> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
> except ImportError:
> pass
- > node, archive = sys.argv[1:]
- > f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
- > % (os.environ['HGPORT'], node, archive))
- > sys.stdout.write(f.read())
+ > if len(sys.argv) <= 3:
+ > node, archive = sys.argv[1:]
+ > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive)
+ > else:
+ > node, archive, file = sys.argv[1:]
+ > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file)
+ > try:
+ > f = urllib2.urlopen('http://127.0.0.1:%s/?%s'
+ > % (os.environ['HGPORT'], requeststr))
+ > sys.stdout.write(f.read())
+ > except urllib2.HTTPError, e:
+ > sys.stderr.write(str(e) + '\n')
> EOF
$ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
test-archive-2c0277f05ed4/.hg_archival.txt
More information about the Mercurial-devel
mailing list