Show More
@@ -10,7 +10,6 import contextlib | |||||
10 | import os |
|
10 | import os | |
11 |
|
11 | |||
12 | from mercurial.i18n import _ |
|
12 | from mercurial.i18n import _ | |
13 | from mercurial.pycompat import open |
|
|||
14 | from mercurial import ( |
|
13 | from mercurial import ( | |
15 | error, |
|
14 | error, | |
16 | extensions, |
|
15 | extensions, | |
@@ -84,7 +83,7 def _getannotate(repo, proto, path, last | |||||
84 | for p in [actx.revmappath, actx.linelogpath]: |
|
83 | for p in [actx.revmappath, actx.linelogpath]: | |
85 | if not os.path.exists(p): |
|
84 | if not os.path.exists(p): | |
86 | continue |
|
85 | continue | |
87 |
with open(p, |
|
86 | with open(p, 'rb') as f: | |
88 | content = f.read() |
|
87 | content = f.read() | |
89 | vfsbaselen = len(repo.vfs.base + b'/') |
|
88 | vfsbaselen = len(repo.vfs.base + b'/') | |
90 | relpath = p[vfsbaselen:] |
|
89 | relpath = p[vfsbaselen:] |
@@ -13,7 +13,6 import os | |||||
13 | import struct |
|
13 | import struct | |
14 |
|
14 | |||
15 | from mercurial.node import hex |
|
15 | from mercurial.node import hex | |
16 | from mercurial.pycompat import open |
|
|||
17 | from mercurial import ( |
|
16 | from mercurial import ( | |
18 | error as hgerror, |
|
17 | error as hgerror, | |
19 | ) |
|
18 | ) | |
@@ -163,12 +162,12 class revmap: | |||||
163 | if not self.path: |
|
162 | if not self.path: | |
164 | return |
|
163 | return | |
165 | if self._lastmaxrev == -1: # write the entire file |
|
164 | if self._lastmaxrev == -1: # write the entire file | |
166 |
with open(self.path, |
|
165 | with open(self.path, 'wb') as f: | |
167 | f.write(self.HEADER) |
|
166 | f.write(self.HEADER) | |
168 | for i in range(1, len(self._rev2hsh)): |
|
167 | for i in range(1, len(self._rev2hsh)): | |
169 | self._writerev(i, f) |
|
168 | self._writerev(i, f) | |
170 | else: # append incrementally |
|
169 | else: # append incrementally | |
171 |
with open(self.path, |
|
170 | with open(self.path, 'ab') as f: | |
172 | for i in range(self._lastmaxrev + 1, len(self._rev2hsh)): |
|
171 | for i in range(self._lastmaxrev + 1, len(self._rev2hsh)): | |
173 | self._writerev(i, f) |
|
172 | self._writerev(i, f) | |
174 | self._lastmaxrev = self.maxrev |
|
173 | self._lastmaxrev = self.maxrev | |
@@ -181,7 +180,7 class revmap: | |||||
181 | # which is faster than both LOAD_CONST and LOAD_GLOBAL. |
|
180 | # which is faster than both LOAD_CONST and LOAD_GLOBAL. | |
182 | flaglen = 1 |
|
181 | flaglen = 1 | |
183 | hshlen = _hshlen |
|
182 | hshlen = _hshlen | |
184 |
with open(self.path, |
|
183 | with open(self.path, 'rb') as f: | |
185 | if f.read(len(self.HEADER)) != self.HEADER: |
|
184 | if f.read(len(self.HEADER)) != self.HEADER: | |
186 | raise error.CorruptedFileError() |
|
185 | raise error.CorruptedFileError() | |
187 | self.clear(flush=False) |
|
186 | self.clear(flush=False) | |
@@ -251,7 +250,7 def getlastnode(path): | |||||
251 | """ |
|
250 | """ | |
252 | hsh = None |
|
251 | hsh = None | |
253 | try: |
|
252 | try: | |
254 |
with open(path, |
|
253 | with open(path, 'rb') as f: | |
255 | f.seek(-_hshlen, io.SEEK_END) |
|
254 | f.seek(-_hshlen, io.SEEK_END) | |
256 | if f.tell() > len(revmap.HEADER): |
|
255 | if f.tell() > len(revmap.HEADER): | |
257 | hsh = f.read(_hshlen) |
|
256 | hsh = f.read(_hshlen) |
General Comments 0
You need to be logged in to leave comments.
Login now