changeset 18770:dcb6a99e82ff

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.
author Angel Ezquerra <angel.ezquerra@gmail.com>
date Wed, 06 Feb 2013 10:06:45 +0100
parents 83a99f10c45c
children bb38f4f78104
files tests/test-archive.t
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-archive.t	Thu Mar 14 16:56:10 2013 -0700
+++ b/tests/test-archive.t	Wed Feb 06 10:06:45 2013 +0100
@@ -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