Patchwork [1,of,3,V6] test-archive: gracefully handle HTTPErrors on get-with-headers

login
register
mail settings
Submitter Angel Ezquerra
Date Feb. 27, 2013, 5:06 p.m.
Message ID <a1aab0b30144b6d9b383.1361984792@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/1060/
State Superseded
Commit dcb6a99e82ff4569c059224b26c13bd189e8691a
Headers show

Comments

Angel Ezquerra - Feb. 27, 2013, 5:06 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360141605 -3600
# Node ID a1aab0b30144b6d9b383e8021d24eecd5861c84e
# Parent  c8c3887a24c1ee30b0afbdb6812e64bb64b400e6
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.
Pierre-Yves David - March 12, 2013, 5:19 p.m.
On Wed, Feb 27, 2013 at 06:06:32PM +0100, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra@gmail.com>
> # Date 1360141605 -3600
> # Node ID a1aab0b30144b6d9b383e8021d24eecd5861c84e
> # Parent  c8c3887a24c1ee30b0afbdb6812e64bb64b400e6
> 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.

You should include a sample output of such message.

Patch

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