[PATCH 4 of 5 postargs] httppeer: compute header names only once

Augie Fackler raf at durin42.com
Fri Mar 11 11:55:15 EST 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1457715082 18000
#      Fri Mar 11 11:51:22 2016 -0500
# Node ID efcc8e438753cddf5af209ae812f77c2affead07
# Parent  5355f92bff4a5527d7fdde189bc6d6a0c720095f
# EXP-Topic batch
httppeer: compute header names only once

This also helps make the code a little more readable.

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -108,12 +108,12 @@ class httppeer(wireproto.wirepeer):
                 headerfmt = 'X-HgArg-%s'
                 contentlen = headersize - len(headerfmt % '000' + ': \r\n')
                 headernum = 0
+                varyheaders = []
                 for i in xrange(0, len(encargs), contentlen):
                     headernum += 1
                     header = headerfmt % str(headernum)
                     headers[header] = encargs[i:i + contentlen]
-                varyheaders = [
-                    headerfmt % str(h) for h in range(1, headernum + 1)]
+                    varyheaders.append(header)
                 headers['Vary'] = ','.join(varyheaders)
             else:
                 q += sorted(args.items())


More information about the Mercurial-devel mailing list