##// END OF EJS Templates
bundle2: use os.SEEK_* constants...
Gregory Szorc -
r35037:241d9cac default
parent child Browse files
Show More
@@ -148,6 +148,7 b' preserve.'
148 148 from __future__ import absolute_import, division
149 149
150 150 import errno
151 import os
151 152 import re
152 153 import string
153 154 import struct
@@ -362,7 +363,7 b' class partiterator(object):'
362 363 self.count = count
363 364 self.current = p
364 365 yield p
365 p.seek(0, 2)
366 p.seek(0, os.SEEK_END)
366 367 self.current = None
367 368 self.iterator = func()
368 369 return self.iterator
@@ -384,11 +385,11 b' class partiterator(object):'
384 385 try:
385 386 if self.current:
386 387 # consume the part content to not corrupt the stream.
387 self.current.seek(0, 2)
388 self.current.seek(0, os.SEEK_END)
388 389
389 390 for part in self.iterator:
390 391 # consume the bundle content
391 part.seek(0, 2)
392 part.seek(0, os.SEEK_END)
392 393 except Exception:
393 394 seekerror = True
394 395
@@ -858,8 +859,8 b' class unbundle20(unpackermixin):'
858 859 # Seek to the end of the part to force it's consumption so the next
859 860 # part can be read. But then seek back to the beginning so the
860 861 # code consuming this generator has a part that starts at 0.
861 part.seek(0, 2)
862 part.seek(0)
862 part.seek(0, os.SEEK_END)
863 part.seek(0, os.SEEK_SET)
863 864 headerblock = self._readpartheader()
864 865 indebug(self.ui, 'end of bundle2 stream')
865 866
@@ -1164,7 +1165,7 b' class interrupthandler(unpackermixin):'
1164 1165 raise
1165 1166 finally:
1166 1167 if not hardabort:
1167 part.seek(0, 2)
1168 part.seek(0, os.SEEK_END)
1168 1169 self.ui.debug('bundle2-input-stream-interrupt:'
1169 1170 ' closing out of band context\n')
1170 1171
@@ -1330,12 +1331,12 b' class unbundlepart(unpackermixin):'
1330 1331 def tell(self):
1331 1332 return self._pos
1332 1333
1333 def seek(self, offset, whence=0):
1334 if whence == 0:
1334 def seek(self, offset, whence=os.SEEK_SET):
1335 if whence == os.SEEK_SET:
1335 1336 newpos = offset
1336 elif whence == 1:
1337 elif whence == os.SEEK_CUR:
1337 1338 newpos = self._pos + offset
1338 elif whence == 2:
1339 elif whence == os.SEEK_END:
1339 1340 if not self.consumed:
1340 1341 self.read()
1341 1342 newpos = self._chunkindex[-1][0] - offset
General Comments 0
You need to be logged in to leave comments. Login now