##// END OF EJS Templates
remotefilelog: stop using the `pycompat.open()` shim
Matt Harbison -
r53280:51df2bf7 default
parent child Browse files
Show More
@@ -136,7 +136,6 from mercurial.node import (
136 wdirrev,
136 wdirrev,
137 )
137 )
138 from mercurial.i18n import _
138 from mercurial.i18n import _
139 from mercurial.pycompat import open
140 from mercurial import (
139 from mercurial import (
141 changegroup,
140 changegroup,
142 changelog,
141 changelog,
@@ -868,7 +867,7 def gcclient(ui, cachepath):
868 ui.warn(_(b"no known cache at %s\n") % cachepath)
867 ui.warn(_(b"no known cache at %s\n") % cachepath)
869 return
868 return
870
869
871 reposfile = open(repospath, b'rb')
870 reposfile = open(repospath, 'rb')
872 repos = {r[:-1] for r in reposfile.readlines()}
871 repos = {r[:-1] for r in reposfile.readlines()}
873 reposfile.close()
872 reposfile.close()
874
873
@@ -942,7 +941,7 def gcclient(ui, cachepath):
942 # write list of valid repos back
941 # write list of valid repos back
943 oldumask = os.umask(0o002)
942 oldumask = os.umask(0o002)
944 try:
943 try:
945 reposfile = open(repospath, b'wb')
944 reposfile = open(repospath, 'wb')
946 reposfile.writelines([(b"%s\n" % r) for r in validrepos])
945 reposfile.writelines([(b"%s\n" % r) for r in validrepos])
947 reposfile.close()
946 reposfile.close()
948 finally:
947 finally:
@@ -1010,7 +1009,7 def readytofetch(repo):
1010 fname = repo.vfs.join(b'lastprefetch')
1009 fname = repo.vfs.join(b'lastprefetch')
1011
1010
1012 ready = False
1011 ready = False
1013 with open(fname, b'a'):
1012 with open(fname, 'a'):
1014 # the with construct above is used to avoid race conditions
1013 # the with construct above is used to avoid race conditions
1015 modtime = os.path.getmtime(fname)
1014 modtime = os.path.getmtime(fname)
1016 if (time.time() - modtime) > timeout:
1015 if (time.time() - modtime) > timeout:
@@ -7,7 +7,6 import time
7
7
8 from mercurial.i18n import _
8 from mercurial.i18n import _
9 from mercurial.node import bin, hex
9 from mercurial.node import bin, hex
10 from mercurial.pycompat import open
11 from mercurial import (
10 from mercurial import (
12 error,
11 error,
13 pycompat,
12 pycompat,
@@ -224,7 +223,7 class basestore:
224 data = shallowutil.readfile(filepath)
223 data = shallowutil.readfile(filepath)
225 if self._validatecache and not self._validatedata(data, filepath):
224 if self._validatecache and not self._validatedata(data, filepath):
226 if self._validatecachelog:
225 if self._validatecachelog:
227 with open(self._validatecachelog, b'ab+') as f:
226 with open(self._validatecachelog, 'ab+') as f:
228 f.write(b"corrupt %s during read\n" % filepath)
227 f.write(b"corrupt %s during read\n" % filepath)
229 os.rename(filepath, filepath + b".corrupt")
228 os.rename(filepath, filepath + b".corrupt")
230 raise KeyError(b"corrupt local cache file %s" % filepath)
229 raise KeyError(b"corrupt local cache file %s" % filepath)
@@ -268,7 +267,7 class basestore:
268 they want to be kept alive in the store.
267 they want to be kept alive in the store.
269 """
268 """
270 repospath = os.path.join(self._path, b"repos")
269 repospath = os.path.join(self._path, b"repos")
271 with open(repospath, b'ab') as reposfile:
270 with open(repospath, 'ab') as reposfile:
272 reposfile.write(os.path.dirname(path) + b"\n")
271 reposfile.write(os.path.dirname(path) + b"\n")
273
272
274 repospathstat = os.stat(repospath)
273 repospathstat = os.stat(repospath)
@@ -276,14 +275,14 class basestore:
276 os.chmod(repospath, 0o0664)
275 os.chmod(repospath, 0o0664)
277
276
278 def _validatekey(self, path, action):
277 def _validatekey(self, path, action):
279 with open(path, b'rb') as f:
278 with open(path, 'rb') as f:
280 data = f.read()
279 data = f.read()
281
280
282 if self._validatedata(data, path):
281 if self._validatedata(data, path):
283 return True
282 return True
284
283
285 if self._validatecachelog:
284 if self._validatecachelog:
286 with open(self._validatecachelog, b'ab+') as f:
285 with open(self._validatecachelog, 'ab+') as f:
287 f.write(b"corrupt %s during %s\n" % (path, action))
286 f.write(b"corrupt %s during %s\n" % (path, action))
288
287
289 os.rename(path, path + b".corrupt")
288 os.rename(path, path + b".corrupt")
@@ -17,7 +17,6 from mercurial.node import (
17 short,
17 short,
18 )
18 )
19 from mercurial.i18n import _
19 from mercurial.i18n import _
20 from mercurial.pycompat import open
21 from mercurial import (
20 from mercurial import (
22 error,
21 error,
23 filelog,
22 filelog,
@@ -228,7 +227,7 def _decompressblob(raw):
228
227
229
228
230 def parsefileblob(path, decompress):
229 def parsefileblob(path, decompress):
231 f = open(path, b"rb")
230 f = open(path, "rb")
232 try:
231 try:
233 raw = f.read()
232 raw = f.read()
234 finally:
233 finally:
@@ -14,7 +14,6 import zlib
14
14
15 from mercurial.i18n import _
15 from mercurial.i18n import _
16 from mercurial.node import bin, hex
16 from mercurial.node import bin, hex
17 from mercurial.pycompat import open
18 from mercurial import (
17 from mercurial import (
19 changegroup,
18 changegroup,
20 changelog,
19 changelog,
@@ -282,7 +281,7 def _loadfileblob(repo, cachepath, path,
282 finally:
281 finally:
283 os.umask(oldumask)
282 os.umask(oldumask)
284 else:
283 else:
285 with open(filecachepath, b"rb") as f:
284 with open(filecachepath, "rb") as f:
286 text = f.read()
285 text = f.read()
287 return text
286 return text
288
287
@@ -14,7 +14,6 import struct
14 import tempfile
14 import tempfile
15
15
16 from mercurial.i18n import _
16 from mercurial.i18n import _
17 from mercurial.pycompat import open
18 from mercurial.node import hex
17 from mercurial.node import hex
19 from mercurial import (
18 from mercurial import (
20 error,
19 error,
@@ -322,7 +321,7 def ancestormap(raw):
322
321
323
322
324 def readfile(path):
323 def readfile(path):
325 f = open(path, b'rb')
324 f = open(path, 'rb')
326 try:
325 try:
327 result = f.read()
326 result = f.read()
328
327
General Comments 0
You need to be logged in to leave comments. Login now