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