Patchwork [3,of,5,postargs] httppeer: indent existing argument handling with if True

login
register
mail settings
Submitter Augie Fackler
Date March 11, 2016, 4:55 p.m.
Message ID <5355f92bff4a5527d7fd.1457715314@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/13795/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Augie Fackler - March 11, 2016, 4:55 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1457714023 18000
#      Fri Mar 11 11:33:43 2016 -0500
# Node ID 5355f92bff4a5527d7fdde189bc6d6a0c720095f
# Parent  b93d91a613340e102a3241d22cae7967d973de54
# EXP-Topic batch
httppeer: indent existing argument handling with if True

I'm about to add another case, so it makes sense to split this out to make the
semantic changes in the next change more obvious.

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -97,24 +97,26 @@  class httppeer(wireproto.wirepeer):
         self.ui.debug("sending %s command\n" % cmd)
         q = [('cmd', cmd)]
         headersize = 0
-        if len(args) > 0:
-            httpheader = self.capable('httpheader')
-            if httpheader:
-                headersize = int(httpheader.split(',', 1)[0])
-        if headersize > 0:
-            # The headers can typically carry more data than the URL.
-            encargs = urllib.urlencode(sorted(args.items()))
-            headerfmt = 'X-HgArg-%s'
-            contentlen = headersize - len(headerfmt % '000' + ': \r\n')
-            headernum = 0
-            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)]
-            headers['Vary'] = ','.join(varyheaders)
-        else:
-            q += sorted(args.items())
+        if True:
+            if len(args) > 0:
+                httpheader = self.capable('httpheader')
+                if httpheader:
+                    headersize = int(httpheader.split(',', 1)[0])
+            if headersize > 0:
+                # The headers can typically carry more data than the URL.
+                encargs = urllib.urlencode(sorted(args.items()))
+                headerfmt = 'X-HgArg-%s'
+                contentlen = headersize - len(headerfmt % '000' + ': \r\n')
+                headernum = 0
+                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)]
+                headers['Vary'] = ','.join(varyheaders)
+            else:
+                q += sorted(args.items())
         qs = '?%s' % urllib.urlencode(q)
         cu = "%s%s" % (self._url, qs)
         size = 0