##// END OF EJS Templates
merge with stable
Matt Mackall -
r15159:85322c19 merge default
parent child Browse files
Show More
@@ -22,8 +22,9 b' from mercurial.i18n import _'
22 22 class httpsendfile(object):
23 23 """This is a wrapper around the objects returned by python's "open".
24 24
25 Its purpose is to send file-like objects via HTTP and, to do so, it
26 defines a __len__ attribute to feed the Content-Length header.
25 Its purpose is to send file-like objects via HTTP.
26 It do however not define a __len__ attribute because the length
27 might be more than Py_ssize_t can handle.
27 28 """
28 29
29 30 def __init__(self, ui, *args, **kwargs):
@@ -35,9 +36,9 b' class httpsendfile(object):'
35 36 self.seek = self._data.seek
36 37 self.close = self._data.close
37 38 self.write = self._data.write
38 self._len = os.fstat(self._data.fileno()).st_size
39 self.length = os.fstat(self._data.fileno()).st_size
39 40 self._pos = 0
40 self._total = self._len / 1024 * 2
41 self._total = self.length / 1024 * 2
41 42
42 43 def read(self, *args, **kwargs):
43 44 try:
@@ -54,9 +55,6 b' class httpsendfile(object):'
54 55 unit=_('kb'), total=self._total)
55 56 return ret
56 57
57 def __len__(self):
58 return self._len
59
60 58 # moved here from url.py to avoid a cycle
61 59 def readauthforuri(ui, uri, user):
62 60 # Read configuration
@@ -73,9 +73,14 b' class httprepository(wireproto.wirerepos'
73 73 if cmd == 'pushkey':
74 74 args['data'] = ''
75 75 data = args.pop('data', None)
76 size = 0
77 if util.safehasattr(data, 'length'):
78 size = data.length
79 elif data is not None:
80 size = len(data)
76 81 headers = args.pop('headers', {})
77 82
78 if data and self.ui.configbool('ui', 'usehttp2', False):
83 if size and self.ui.configbool('ui', 'usehttp2', False):
79 84 headers['Expect'] = '100-Continue'
80 85 headers['X-HgHttp2'] = '1'
81 86
@@ -104,9 +109,6 b' class httprepository(wireproto.wirerepos'
104 109 cu = "%s%s" % (self._url, qs)
105 110 req = urllib2.Request(cu, data, headers)
106 111 if data is not None:
107 # len(data) is broken if data doesn't fit into Py_ssize_t
108 # add the header ourself to avoid OverflowError
109 size = data.__len__()
110 112 self.ui.debug("sending %s bytes\n" % size)
111 113 req.add_unredirected_header('Content-Length', '%d' % size)
112 114 try:
@@ -188,7 +188,7 b' def extract(ui, fileobj):'
188 188 pend = subject.find(']')
189 189 if pend >= 0:
190 190 subject = subject[pend + 1:].lstrip()
191 subject = subject.replace('\n\t', ' ')
191 subject = re.sub(r'\n[ \t]+', ' ', subject)
192 192 ui.debug('Subject: %s\n' % subject)
193 193 if user:
194 194 ui.debug('From: %s\n' % user)
@@ -913,7 +913,12 b" def datestr(date=None, format='%a %b %d "
913 913 minutes = abs(tz) // 60
914 914 format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
915 915 format = format.replace("%2", "%02d" % (minutes % 60))
916 s = time.strftime(format, time.gmtime(float(t) - tz))
916 try:
917 t = time.gmtime(float(t) - tz)
918 except ValueError:
919 # time was out of range
920 t = time.gmtime(sys.maxint)
921 s = time.strftime(format, t)
917 922 return s
918 923
919 924 def shortdate(date=None):
General Comments 0
You need to be logged in to leave comments. Login now