Mercurial > hg
comparison mercurial/httppeer.py @ 28485:d3893900f6c8
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.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 11 Mar 2016 11:33:43 -0500 |
parents | da6f713ab480 |
children | 50314dc3ae4e |
comparison
equal
deleted
inserted
replaced
28484:da6f713ab480 | 28485:d3893900f6c8 |
---|---|
95 headers = args.pop('headers', {}) | 95 headers = args.pop('headers', {}) |
96 | 96 |
97 self.ui.debug("sending %s command\n" % cmd) | 97 self.ui.debug("sending %s command\n" % cmd) |
98 q = [('cmd', cmd)] | 98 q = [('cmd', cmd)] |
99 headersize = 0 | 99 headersize = 0 |
100 if len(args) > 0: | 100 if True: |
101 httpheader = self.capable('httpheader') | 101 if len(args) > 0: |
102 if httpheader: | 102 httpheader = self.capable('httpheader') |
103 headersize = int(httpheader.split(',', 1)[0]) | 103 if httpheader: |
104 if headersize > 0: | 104 headersize = int(httpheader.split(',', 1)[0]) |
105 # The headers can typically carry more data than the URL. | 105 if headersize > 0: |
106 encargs = urllib.urlencode(sorted(args.items())) | 106 # The headers can typically carry more data than the URL. |
107 headerfmt = 'X-HgArg-%s' | 107 encargs = urllib.urlencode(sorted(args.items())) |
108 contentlen = headersize - len(headerfmt % '000' + ': \r\n') | 108 headerfmt = 'X-HgArg-%s' |
109 headernum = 0 | 109 contentlen = headersize - len(headerfmt % '000' + ': \r\n') |
110 for i in xrange(0, len(encargs), contentlen): | 110 headernum = 0 |
111 headernum += 1 | 111 for i in xrange(0, len(encargs), contentlen): |
112 header = headerfmt % str(headernum) | 112 headernum += 1 |
113 headers[header] = encargs[i:i + contentlen] | 113 header = headerfmt % str(headernum) |
114 varyheaders = [headerfmt % str(h) for h in range(1, headernum + 1)] | 114 headers[header] = encargs[i:i + contentlen] |
115 headers['Vary'] = ','.join(varyheaders) | 115 varyheaders = [ |
116 else: | 116 headerfmt % str(h) for h in range(1, headernum + 1)] |
117 q += sorted(args.items()) | 117 headers['Vary'] = ','.join(varyheaders) |
118 else: | |
119 q += sorted(args.items()) | |
118 qs = '?%s' % urllib.urlencode(q) | 120 qs = '?%s' % urllib.urlencode(q) |
119 cu = "%s%s" % (self._url, qs) | 121 cu = "%s%s" % (self._url, qs) |
120 size = 0 | 122 size = 0 |
121 if util.safehasattr(data, 'length'): | 123 if util.safehasattr(data, 'length'): |
122 size = data.length | 124 size = data.length |