Mercurial > hg
comparison mercurial/revlog.py @ 42567:4eaf7197a740
cleanup: use named constants for second arg to .seek()
Differential Revision: https://phab.mercurial-scm.org/D6556
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 20 Jun 2019 14:33:42 -0400 |
parents | bc4373babd04 |
children | 24111fb9a725 |
comparison
equal
deleted
inserted
replaced
42566:f802a75da585 | 42567:4eaf7197a740 |
---|---|
14 from __future__ import absolute_import | 14 from __future__ import absolute_import |
15 | 15 |
16 import collections | 16 import collections |
17 import contextlib | 17 import contextlib |
18 import errno | 18 import errno |
19 import io | |
19 import os | 20 import os |
20 import struct | 21 import struct |
21 import zlib | 22 import zlib |
22 | 23 |
23 # import stuff from node for others to import from revlog | 24 # import stuff from node for others to import from revlog |
2304 if len(self): | 2305 if len(self): |
2305 expected = max(0, self.end(len(self) - 1)) | 2306 expected = max(0, self.end(len(self) - 1)) |
2306 | 2307 |
2307 try: | 2308 try: |
2308 with self._datafp() as f: | 2309 with self._datafp() as f: |
2309 f.seek(0, 2) | 2310 f.seek(0, io.SEEK_END) |
2310 actual = f.tell() | 2311 actual = f.tell() |
2311 dd = actual - expected | 2312 dd = actual - expected |
2312 except IOError as inst: | 2313 except IOError as inst: |
2313 if inst.errno != errno.ENOENT: | 2314 if inst.errno != errno.ENOENT: |
2314 raise | 2315 raise |
2315 dd = 0 | 2316 dd = 0 |
2316 | 2317 |
2317 try: | 2318 try: |
2318 f = self.opener(self.indexfile) | 2319 f = self.opener(self.indexfile) |
2319 f.seek(0, 2) | 2320 f.seek(0, io.SEEK_END) |
2320 actual = f.tell() | 2321 actual = f.tell() |
2321 f.close() | 2322 f.close() |
2322 s = self._io.size | 2323 s = self._io.size |
2323 i = max(0, actual // s) | 2324 i = max(0, actual // s) |
2324 di = actual - (i * s) | 2325 di = actual - (i * s) |