Mercurial > hg
comparison hgext/fastannotate/revmap.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 | 1205ba8f11ac |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
42566:f802a75da585 | 42567:4eaf7197a740 |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import bisect | 10 import bisect |
11 import io | |
11 import os | 12 import os |
12 import struct | 13 import struct |
13 | 14 |
14 from mercurial.node import hex | 15 from mercurial.node import hex |
15 from mercurial import ( | 16 from mercurial import ( |
244 this is equivalent to `m = revmap(path); m.rev2hsh(m.maxrev)`, but faster. | 245 this is equivalent to `m = revmap(path); m.rev2hsh(m.maxrev)`, but faster. |
245 """ | 246 """ |
246 hsh = None | 247 hsh = None |
247 try: | 248 try: |
248 with open(path, 'rb') as f: | 249 with open(path, 'rb') as f: |
249 f.seek(-_hshlen, 2) | 250 f.seek(-_hshlen, io.SEEK_END) |
250 if f.tell() > len(revmap.HEADER): | 251 if f.tell() > len(revmap.HEADER): |
251 hsh = f.read(_hshlen) | 252 hsh = f.read(_hshlen) |
252 except IOError: | 253 except IOError: |
253 pass | 254 pass |
254 return hsh | 255 return hsh |