Show More
@@ -7,7 +7,6 | |||||
7 |
|
7 | |||
8 | import base64 |
|
8 | import base64 | |
9 | import datetime |
|
9 | import datetime | |
10 | import errno |
|
|||
11 | import os |
|
10 | import os | |
12 | import pickle |
|
11 | import pickle | |
13 | import re |
|
12 | import re | |
@@ -528,9 +527,7 class mapfile(dict): | |||||
528 | return |
|
527 | return | |
529 | try: |
|
528 | try: | |
530 | fp = open(self.path, b'rb') |
|
529 | fp = open(self.path, b'rb') | |
531 |
except |
|
530 | except FileNotFoundError: | |
532 | if err.errno != errno.ENOENT: |
|
|||
533 | raise |
|
|||
534 | return |
|
531 | return | |
535 | for i, line in enumerate(fp): |
|
532 | for i, line in enumerate(fp): | |
536 | line = line.splitlines()[0].rstrip() |
|
533 | line = line.splitlines()[0].rstrip() |
@@ -5,7 +5,6 | |||||
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
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 | import errno |
|
|||
9 | import os |
|
8 | import os | |
10 | import re |
|
9 | import re | |
11 | import shutil |
|
10 | import shutil | |
@@ -230,10 +229,8 class darcs_source(common.converter_sour | |||||
230 | try: |
|
229 | try: | |
231 | data = util.readfile(path) |
|
230 | data = util.readfile(path) | |
232 | mode = os.lstat(path).st_mode |
|
231 | mode = os.lstat(path).st_mode | |
233 |
except |
|
232 | except FileNotFoundError: | |
234 | if inst.errno == errno.ENOENT: |
|
|||
235 |
|
|
233 | return None, None | |
236 | raise |
|
|||
237 | mode = (mode & 0o111) and b'x' or b'' |
|
234 | mode = (mode & 0o111) and b'x' or b'' | |
238 | return data, mode |
|
235 | return data, mode | |
239 |
|
236 |
@@ -137,9 +137,8 class state: | |||||
137 | def invalidate(self): |
|
137 | def invalidate(self): | |
138 | try: |
|
138 | try: | |
139 | os.unlink(os.path.join(self._rootdir, b'.hg', b'fsmonitor.state')) |
|
139 | os.unlink(os.path.join(self._rootdir, b'.hg', b'fsmonitor.state')) | |
140 |
except |
|
140 | except FileNotFoundError: | |
141 | if inst.errno != errno.ENOENT: |
|
141 | pass | |
142 | raise |
|
|||
143 | self._identity = util.filestat(None) |
|
142 | self._identity = util.filestat(None) | |
144 |
|
143 | |||
145 | def setlastclock(self, clock): |
|
144 | def setlastclock(self, clock): |
@@ -1,5 +1,4 | |||||
1 | import contextlib |
|
1 | import contextlib | |
2 | import errno |
|
|||
3 | import os |
|
2 | import os | |
4 |
|
3 | |||
5 | from mercurial.node import sha1nodeconstants |
|
4 | from mercurial.node import sha1nodeconstants | |
@@ -318,9 +317,7 class gitdirstate: | |||||
318 | # TODO construct the stat info from the status object? |
|
317 | # TODO construct the stat info from the status object? | |
319 | try: |
|
318 | try: | |
320 | s = os.stat(os.path.join(cwd, path)) |
|
319 | s = os.stat(os.path.join(cwd, path)) | |
321 |
except |
|
320 | except FileNotFoundError: | |
322 | if e.errno != errno.ENOENT: |
|
|||
323 | raise |
|
|||
324 | continue |
|
321 | continue | |
325 | r[path] = s |
|
322 | r[path] = s | |
326 | return r |
|
323 | return r |
@@ -90,7 +90,6 delete this code at the end of 2020. | |||||
90 |
|
90 | |||
91 | import collections |
|
91 | import collections | |
92 | import contextlib |
|
92 | import contextlib | |
93 | import errno |
|
|||
94 | import functools |
|
93 | import functools | |
95 | import logging |
|
94 | import logging | |
96 | import os |
|
95 | import os | |
@@ -1307,9 +1306,8 def bundle2scratchbranch(op, part): | |||||
1307 | finally: |
|
1306 | finally: | |
1308 | try: |
|
1307 | try: | |
1309 | os.unlink(bundlefile) |
|
1308 | os.unlink(bundlefile) | |
1310 |
except |
|
1309 | except FileNotFoundError: | |
1311 | if e.errno != errno.ENOENT: |
|
1310 | pass | |
1312 | raise |
|
|||
1313 |
|
1311 | |||
1314 | return 1 |
|
1312 | return 1 | |
1315 |
|
1313 |
@@ -13,7 +13,6 bookmarks were previously located. | |||||
13 |
|
13 | |||
14 |
|
14 | |||
15 | import collections |
|
15 | import collections | |
16 | import errno |
|
|||
17 | import os |
|
16 | import os | |
18 | import weakref |
|
17 | import weakref | |
19 |
|
18 | |||
@@ -140,9 +139,7 def _readsharedfeatures(repo): | |||||
140 | """A set of shared features for this repository""" |
|
139 | """A set of shared features for this repository""" | |
141 | try: |
|
140 | try: | |
142 | return set(repo.vfs.read(b'shared').splitlines()) |
|
141 | return set(repo.vfs.read(b'shared').splitlines()) | |
143 |
except |
|
142 | except FileNotFoundError: | |
144 | if inst.errno != errno.ENOENT: |
|
|||
145 | raise |
|
|||
146 | return set() |
|
143 | return set() | |
147 |
|
144 | |||
148 |
|
145 |
@@ -9,7 +9,6 | |||||
9 | '''High-level command function for lfconvert, plus the cmdtable.''' |
|
9 | '''High-level command function for lfconvert, plus the cmdtable.''' | |
10 |
|
10 | |||
11 | import binascii |
|
11 | import binascii | |
12 | import errno |
|
|||
13 | import os |
|
12 | import os | |
14 | import shutil |
|
13 | import shutil | |
15 |
|
14 | |||
@@ -474,10 +473,8 def cachelfiles(ui, repo, node, filelist | |||||
474 | for lfile in lfiles: |
|
473 | for lfile in lfiles: | |
475 | try: |
|
474 | try: | |
476 | expectedhash = lfutil.readasstandin(ctx[lfutil.standin(lfile)]) |
|
475 | expectedhash = lfutil.readasstandin(ctx[lfutil.standin(lfile)]) | |
477 |
except |
|
476 | except FileNotFoundError: | |
478 | if err.errno == errno.ENOENT: |
|
|||
479 |
|
|
477 | continue # node must be None and standin wasn't found in wctx | |
480 | raise |
|
|||
481 | if not lfutil.findfile(repo, expectedhash): |
|
478 | if not lfutil.findfile(repo, expectedhash): | |
482 | toget.append((lfile, expectedhash)) |
|
479 | toget.append((lfile, expectedhash)) | |
483 |
|
480 |
@@ -63,7 +63,6 in the strip extension. | |||||
63 | ''' |
|
63 | ''' | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | import errno |
|
|||
67 | import os |
|
66 | import os | |
68 | import re |
|
67 | import re | |
69 | import shutil |
|
68 | import shutil | |
@@ -551,19 +550,15 class queue: | |||||
551 | try: |
|
550 | try: | |
552 | lines = self.opener.read(self.statuspath).splitlines() |
|
551 | lines = self.opener.read(self.statuspath).splitlines() | |
553 | return list(parselines(lines)) |
|
552 | return list(parselines(lines)) | |
554 |
except |
|
553 | except FileNotFoundError: | |
555 | if e.errno == errno.ENOENT: |
|
|||
556 |
|
|
554 | return [] | |
557 | raise |
|
|||
558 |
|
555 | |||
559 | @util.propertycache |
|
556 | @util.propertycache | |
560 | def fullseries(self): |
|
557 | def fullseries(self): | |
561 | try: |
|
558 | try: | |
562 | return self.opener.read(self.seriespath).splitlines() |
|
559 | return self.opener.read(self.seriespath).splitlines() | |
563 |
except |
|
560 | except FileNotFoundError: | |
564 | if e.errno == errno.ENOENT: |
|
|||
565 |
|
|
561 | return [] | |
566 | raise |
|
|||
567 |
|
562 | |||
568 | @util.propertycache |
|
563 | @util.propertycache | |
569 | def series(self): |
|
564 | def series(self): | |
@@ -691,9 +686,7 class queue: | |||||
691 | self.activeguards = [] |
|
686 | self.activeguards = [] | |
692 | try: |
|
687 | try: | |
693 | guards = self.opener.read(self.guardspath).split() |
|
688 | guards = self.opener.read(self.guardspath).split() | |
694 |
except |
|
689 | except FileNotFoundError: | |
695 | if err.errno != errno.ENOENT: |
|
|||
696 | raise |
|
|||
697 | guards = [] |
|
690 | guards = [] | |
698 | for i, guard in enumerate(guards): |
|
691 | for i, guard in enumerate(guards): | |
699 | bad = self.checkguard(guard) |
|
692 | bad = self.checkguard(guard) | |
@@ -1140,9 +1133,8 class queue: | |||||
1140 | for p in patches: |
|
1133 | for p in patches: | |
1141 | try: |
|
1134 | try: | |
1142 | os.unlink(self.join(p)) |
|
1135 | os.unlink(self.join(p)) | |
1143 |
except |
|
1136 | except FileNotFoundError: | |
1144 | if inst.errno != errno.ENOENT: |
|
1137 | pass | |
1145 | raise |
|
|||
1146 |
|
1138 | |||
1147 | qfinished = [] |
|
1139 | qfinished = [] | |
1148 | if numrevs: |
|
1140 | if numrevs: |
@@ -15,7 +15,6 https://mercurial-scm.org/wiki/RebaseExt | |||||
15 | ''' |
|
15 | ''' | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | import errno |
|
|||
19 | import os |
|
18 | import os | |
20 |
|
19 | |||
21 | from mercurial.i18n import _ |
|
20 | from mercurial.i18n import _ | |
@@ -1940,9 +1939,7 def restorecollapsemsg(repo, isabort): | |||||
1940 | f = repo.vfs(b"last-message.txt") |
|
1939 | f = repo.vfs(b"last-message.txt") | |
1941 | collapsemsg = f.readline().strip() |
|
1940 | collapsemsg = f.readline().strip() | |
1942 | f.close() |
|
1941 | f.close() | |
1943 |
except |
|
1942 | except FileNotFoundError: | |
1944 | if err.errno != errno.ENOENT: |
|
|||
1945 | raise |
|
|||
1946 | if isabort: |
|
1943 | if isabort: | |
1947 | # Oh well, just abort like normal |
|
1944 | # Oh well, just abort like normal | |
1948 | collapsemsg = b'' |
|
1945 | collapsemsg = b'' |
@@ -13,7 +13,6 process simpler by automating it. | |||||
13 |
|
13 | |||
14 |
|
14 | |||
15 | import difflib |
|
15 | import difflib | |
16 | import errno |
|
|||
17 | import re |
|
16 | import re | |
18 |
|
17 | |||
19 | from mercurial.i18n import _ |
|
18 | from mercurial.i18n import _ | |
@@ -688,10 +687,7 def releasenotes(ui, repo, file_=None, * | |||||
688 | try: |
|
687 | try: | |
689 | with open(file_, b'rb') as fh: |
|
688 | with open(file_, b'rb') as fh: | |
690 | notes = parsereleasenotesfile(sections, fh.read()) |
|
689 | notes = parsereleasenotesfile(sections, fh.read()) | |
691 |
except |
|
690 | except FileNotFoundError: | |
692 | if e.errno != errno.ENOENT: |
|
|||
693 | raise |
|
|||
694 |
|
||||
695 | notes = parsedreleasenotes() |
|
691 | notes = parsedreleasenotes() | |
696 |
|
692 | |||
697 | notes.merge(ui, incoming) |
|
693 | notes.merge(ui, incoming) |
@@ -166,9 +166,8 class basepackstore: | |||||
166 | ) |
|
166 | ) | |
167 | else: |
|
167 | else: | |
168 | ids.add(id) |
|
168 | ids.add(id) | |
169 |
except |
|
169 | except FileNotFoundError: | |
170 | if ex.errno != errno.ENOENT: |
|
170 | pass | |
171 | raise |
|
|||
172 |
|
171 | |||
173 | def _getavailablepackfilessorted(self): |
|
172 | def _getavailablepackfilessorted(self): | |
174 | """Like `_getavailablepackfiles`, but also sorts the files by mtime, |
|
173 | """Like `_getavailablepackfiles`, but also sorts the files by mtime, |
@@ -1,4 +1,3 | |||||
1 | import errno |
|
|||
2 |
|
|
1 | import os | |
3 | import shutil |
|
2 | import shutil | |
4 | import stat |
|
3 | import stat | |
@@ -344,10 +343,7 class basestore: | |||||
344 | count += 1 |
|
343 | count += 1 | |
345 | try: |
|
344 | try: | |
346 | pathstat = os.stat(path) |
|
345 | pathstat = os.stat(path) | |
347 |
except |
|
346 | except FileNotFoundError: | |
348 | # errno.ENOENT = no such file or directory |
|
|||
349 | if e.errno != errno.ENOENT: |
|
|||
350 | raise |
|
|||
351 | msg = _( |
|
347 | msg = _( | |
352 | b"warning: file %s was removed by another process\n" |
|
348 | b"warning: file %s was removed by another process\n" | |
353 | ) |
|
349 | ) | |
@@ -362,10 +358,7 class basestore: | |||||
362 | else: |
|
358 | else: | |
363 | try: |
|
359 | try: | |
364 | shallowutil.unlinkfile(path) |
|
360 | shallowutil.unlinkfile(path) | |
365 |
except |
|
361 | except FileNotFoundError: | |
366 | # errno.ENOENT = no such file or directory |
|
|||
367 | if e.errno != errno.ENOENT: |
|
|||
368 | raise |
|
|||
369 | msg = _( |
|
362 | msg = _( | |
370 | b"warning: file %s was removed by another " |
|
363 | b"warning: file %s was removed by another " | |
371 | b"process\n" |
|
364 | b"process\n" | |
@@ -388,10 +381,7 class basestore: | |||||
388 | atime, oldpath, oldpathstat = queue.get() |
|
381 | atime, oldpath, oldpathstat = queue.get() | |
389 | try: |
|
382 | try: | |
390 | shallowutil.unlinkfile(oldpath) |
|
383 | shallowutil.unlinkfile(oldpath) | |
391 |
except |
|
384 | except FileNotFoundError: | |
392 | # errno.ENOENT = no such file or directory |
|
|||
393 | if e.errno != errno.ENOENT: |
|
|||
394 | raise |
|
|||
395 | msg = _( |
|
385 | msg = _( | |
396 | b"warning: file %s was removed by another process\n" |
|
386 | b"warning: file %s was removed by another process\n" | |
397 | ) |
|
387 | ) |
@@ -66,7 +66,6 The following ``share.`` config options | |||||
66 | ''' |
|
66 | ''' | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | import errno |
|
|||
70 | from mercurial.i18n import _ |
|
69 | from mercurial.i18n import _ | |
71 | from mercurial import ( |
|
70 | from mercurial import ( | |
72 | bookmarks, |
|
71 | bookmarks, | |
@@ -177,9 +176,7 def _hassharedbookmarks(repo): | |||||
177 | return False |
|
176 | return False | |
178 | try: |
|
177 | try: | |
179 | shared = repo.vfs.read(b'shared').splitlines() |
|
178 | shared = repo.vfs.read(b'shared').splitlines() | |
180 |
except |
|
179 | except FileNotFoundError: | |
181 | if inst.errno != errno.ENOENT: |
|
|||
182 | raise |
|
|||
183 | return False |
|
180 | return False | |
184 | return hg.sharedbookmarks in shared |
|
181 | return hg.sharedbookmarks in shared | |
185 |
|
182 | |||
@@ -199,9 +196,8 def getbkfile(orig, repo): | |||||
199 | # is up-to-date. |
|
196 | # is up-to-date. | |
200 | return fp |
|
197 | return fp | |
201 | fp.close() |
|
198 | fp.close() | |
202 |
except |
|
199 | except FileNotFoundError: | |
203 | if inst.errno != errno.ENOENT: |
|
200 | pass | |
204 | raise |
|
|||
205 |
|
201 | |||
206 | # otherwise, we should read bookmarks from srcrepo, |
|
202 | # otherwise, we should read bookmarks from srcrepo, | |
207 | # because .hg/bookmarks in srcrepo might be already |
|
203 | # because .hg/bookmarks in srcrepo might be already |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import struct |
|
9 | import struct | |
11 |
|
10 | |||
12 | from .i18n import _ |
|
11 | from .i18n import _ | |
@@ -114,9 +113,8 class bmstore: | |||||
114 | _(b'malformed line in %s: %r\n') |
|
113 | _(b'malformed line in %s: %r\n') | |
115 | % (bookmarkspath, pycompat.bytestr(line)) |
|
114 | % (bookmarkspath, pycompat.bytestr(line)) | |
116 | ) |
|
115 | ) | |
117 |
except |
|
116 | except FileNotFoundError: | |
118 | if inst.errno != errno.ENOENT: |
|
117 | pass | |
119 | raise |
|
|||
120 | self._active = _readactive(repo, self) |
|
118 | self._active = _readactive(repo, self) | |
121 |
|
119 | |||
122 | @property |
|
120 | @property |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import os |
|
9 | import os | |
11 | import re |
|
10 | import re | |
12 | import sys |
|
11 | import sys | |
@@ -6175,9 +6174,8 def resolve(ui, repo, *pats, **opts): | |||||
6175 | a = repo.wjoin(f) |
|
6174 | a = repo.wjoin(f) | |
6176 | try: |
|
6175 | try: | |
6177 | util.copyfile(a, a + b".resolve") |
|
6176 | util.copyfile(a, a + b".resolve") | |
6178 |
except |
|
6177 | except FileNotFoundError: | |
6179 | if inst.errno != errno.ENOENT: |
|
6178 | pass | |
6180 | raise |
|
|||
6181 |
|
6179 | |||
6182 | try: |
|
6180 | try: | |
6183 | # preresolve file |
|
6181 | # preresolve file | |
@@ -6194,9 +6192,8 def resolve(ui, repo, *pats, **opts): | |||||
6194 | util.rename( |
|
6192 | util.rename( | |
6195 | a + b".resolve", scmutil.backuppath(ui, repo, f) |
|
6193 | a + b".resolve", scmutil.backuppath(ui, repo, f) | |
6196 | ) |
|
6194 | ) | |
6197 |
except |
|
6195 | except FileNotFoundError: | |
6198 | if inst.errno != errno.ENOENT: |
|
6196 | pass | |
6199 | raise |
|
|||
6200 |
|
6197 | |||
6201 | if hasconflictmarkers: |
|
6198 | if hasconflictmarkers: | |
6202 | ui.warn( |
|
6199 | ui.warn( |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import filecmp |
|
9 | import filecmp | |
11 | import os |
|
10 | import os | |
12 | import stat |
|
11 | import stat | |
@@ -1737,9 +1736,7 class workingctx(committablectx): | |||||
1737 | def copy(self, source, dest): |
|
1736 | def copy(self, source, dest): | |
1738 | try: |
|
1737 | try: | |
1739 | st = self._repo.wvfs.lstat(dest) |
|
1738 | st = self._repo.wvfs.lstat(dest) | |
1740 |
except |
|
1739 | except FileNotFoundError: | |
1741 | if err.errno != errno.ENOENT: |
|
|||
1742 | raise |
|
|||
1743 | self._repo.ui.warn( |
|
1740 | self._repo.ui.warn( | |
1744 | _(b"%s does not exist!\n") % self._repo.dirstate.pathto(dest) |
|
1741 | _(b"%s does not exist!\n") % self._repo.dirstate.pathto(dest) | |
1745 | ) |
|
1742 | ) | |
@@ -2169,9 +2166,7 class workingfilectx(committablefilectx) | |||||
2169 | t, tz = self._changectx.date() |
|
2166 | t, tz = self._changectx.date() | |
2170 | try: |
|
2167 | try: | |
2171 | return (self._repo.wvfs.lstat(self._path)[stat.ST_MTIME], tz) |
|
2168 | return (self._repo.wvfs.lstat(self._path)[stat.ST_MTIME], tz) | |
2172 |
except |
|
2169 | except FileNotFoundError: | |
2173 | if err.errno != errno.ENOENT: |
|
|||
2174 | raise |
|
|||
2175 | return (t, tz) |
|
2170 | return (t, tz) | |
2176 |
|
2171 | |||
2177 | def exists(self): |
|
2172 | def exists(self): |
@@ -2350,9 +2350,8 def debuglocks(ui, repo, **opts): | |||||
2350 | ) |
|
2350 | ) | |
2351 | ui.writenoi18n(b"%-6s %s (%ds)\n" % (name + b":", locker, age)) |
|
2351 | ui.writenoi18n(b"%-6s %s (%ds)\n" % (name + b":", locker, age)) | |
2352 | return 1 |
|
2352 | return 1 | |
2353 |
except |
|
2353 | except FileNotFoundError: | |
2354 | if e.errno != errno.ENOENT: |
|
2354 | pass | |
2355 | raise |
|
|||
2356 |
|
2355 | |||
2357 | ui.writenoi18n(b"%-6s free\n" % (name + b":")) |
|
2356 | ui.writenoi18n(b"%-6s free\n" % (name + b":")) | |
2358 | return 0 |
|
2357 | return 0 |
@@ -195,9 +195,7 class dirstate: | |||||
195 | def _branch(self): |
|
195 | def _branch(self): | |
196 | try: |
|
196 | try: | |
197 | return self._opener.read(b"branch").strip() or b"default" |
|
197 | return self._opener.read(b"branch").strip() or b"default" | |
198 |
except |
|
198 | except FileNotFoundError: | |
199 | if inst.errno != errno.ENOENT: |
|
|||
200 | raise |
|
|||
201 | return b"default" |
|
199 | return b"default" | |
202 |
|
200 | |||
203 | @property |
|
201 | @property |
@@ -4,8 +4,6 | |||||
4 | # GNU General Public License version 2 or any later version. |
|
4 | # GNU General Public License version 2 or any later version. | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | import errno |
|
|||
8 |
|
||||
9 | from .i18n import _ |
|
7 | from .i18n import _ | |
10 |
|
8 | |||
11 | from . import ( |
|
9 | from . import ( | |
@@ -95,9 +93,7 class _dirstatemapcommon: | |||||
95 | try: |
|
93 | try: | |
96 | with self._opendirstatefile() as fp: |
|
94 | with self._opendirstatefile() as fp: | |
97 | return fp.read(size) |
|
95 | return fp.read(size) | |
98 |
except |
|
96 | except FileNotFoundError: | |
99 | if err.errno != errno.ENOENT: |
|
|||
100 | raise |
|
|||
101 | # File doesn't exist, so the current state is empty |
|
97 | # File doesn't exist, so the current state is empty | |
102 | return b'' |
|
98 | return b'' | |
103 |
|
99 |
@@ -7,7 +7,6 | |||||
7 |
|
7 | |||
8 |
|
8 | |||
9 | import difflib |
|
9 | import difflib | |
10 | import errno |
|
|||
11 |
|
10 | |||
12 | from .i18n import _ |
|
11 | from .i18n import _ | |
13 |
|
12 | |||
@@ -158,9 +157,8 class grepsearcher: | |||||
158 | fctx = ctx[fn] |
|
157 | fctx = ctx[fn] | |
159 | try: |
|
158 | try: | |
160 | return fctx.data() |
|
159 | return fctx.data() | |
161 |
except |
|
160 | except FileNotFoundError: | |
162 | if e.errno != errno.ENOENT: |
|
161 | pass | |
163 | raise |
|
|||
164 | else: |
|
162 | else: | |
165 | flog = self._getfile(fn) |
|
163 | flog = self._getfile(fn) | |
166 | fnode = ctx.filenode(fn) |
|
164 | fnode = ctx.filenode(fn) |
@@ -7,7 +7,6 | |||||
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | import errno |
|
|||
11 | import functools |
|
10 | import functools | |
12 | import os |
|
11 | import os | |
13 | import random |
|
12 | import random | |
@@ -517,7 +516,7 def _readrequires(vfs, allowmissing): | |||||
517 | """reads the require file present at root of this vfs |
|
516 | """reads the require file present at root of this vfs | |
518 | and return a set of requirements |
|
517 | and return a set of requirements | |
519 |
|
518 | |||
520 |
If allowmissing is True, we suppress |
|
519 | If allowmissing is True, we suppress FileNotFoundError if raised""" | |
521 | # requires file contains a newline-delimited list of |
|
520 | # requires file contains a newline-delimited list of | |
522 | # features/capabilities the opener (us) must have in order to use |
|
521 | # features/capabilities the opener (us) must have in order to use | |
523 | # the repository. This file was introduced in Mercurial 0.9.2, |
|
522 | # the repository. This file was introduced in Mercurial 0.9.2, | |
@@ -525,8 +524,8 def _readrequires(vfs, allowmissing): | |||||
525 | # a missing file translates to no requirements. |
|
524 | # a missing file translates to no requirements. | |
526 | try: |
|
525 | try: | |
527 | requirements = set(vfs.read(b'requires').splitlines()) |
|
526 | requirements = set(vfs.read(b'requires').splitlines()) | |
528 |
except |
|
527 | except FileNotFoundError: | |
529 |
if not |
|
528 | if not allowmissing: | |
530 | raise |
|
529 | raise | |
531 | requirements = set() |
|
530 | requirements = set() | |
532 | return requirements |
|
531 | return requirements | |
@@ -583,9 +582,8 def makelocalrepository(baseui, path, in | |||||
583 | if not hgvfs.isdir(): |
|
582 | if not hgvfs.isdir(): | |
584 | try: |
|
583 | try: | |
585 | hgvfs.stat() |
|
584 | hgvfs.stat() | |
586 |
except |
|
585 | except FileNotFoundError: | |
587 | if e.errno != errno.ENOENT: |
|
586 | pass | |
588 | raise |
|
|||
589 | except ValueError as e: |
|
587 | except ValueError as e: | |
590 | # Can be raised on Python 3.8 when path is invalid. |
|
588 | # Can be raised on Python 3.8 when path is invalid. | |
591 | raise error.Abort( |
|
589 | raise error.Abort( | |
@@ -3503,9 +3501,8 def aftertrans(files): | |||||
3503 | vfs.tryunlink(dest) |
|
3501 | vfs.tryunlink(dest) | |
3504 | try: |
|
3502 | try: | |
3505 | vfs.rename(src, dest) |
|
3503 | vfs.rename(src, dest) | |
3506 |
except |
|
3504 | except FileNotFoundError: # journal file does not yet exist | |
3507 | if exc.errno != errno.ENOENT: |
|
3505 | pass | |
3508 | raise |
|
|||
3509 |
|
3506 | |||
3510 | return a |
|
3507 | return a | |
3511 |
|
3508 |
@@ -311,10 +311,8 class lock: | |||||
311 | """ |
|
311 | """ | |
312 | try: |
|
312 | try: | |
313 | return self.vfs.readlock(self.f) |
|
313 | return self.vfs.readlock(self.f) | |
314 | except (OSError, IOError) as why: |
|
314 | except FileNotFoundError: | |
315 | if why.errno == errno.ENOENT: |
|
|||
316 |
|
|
315 | return None | |
317 | raise |
|
|||
318 |
|
316 | |||
319 | def _lockshouldbebroken(self, locker): |
|
317 | def _lockshouldbebroken(self, locker): | |
320 | if locker is None: |
|
318 | if locker is None: |
@@ -7,7 +7,6 | |||||
7 |
|
7 | |||
8 |
|
8 | |||
9 | import collections |
|
9 | import collections | |
10 | import errno |
|
|||
11 | import struct |
|
10 | import struct | |
12 |
|
11 | |||
13 | from .i18n import _ |
|
12 | from .i18n import _ | |
@@ -1306,10 +1305,8 def calculateupdates( | |||||
1306 | def _getcwd(): |
|
1305 | def _getcwd(): | |
1307 | try: |
|
1306 | try: | |
1308 | return encoding.getcwd() |
|
1307 | return encoding.getcwd() | |
1309 |
except |
|
1308 | except FileNotFoundError: | |
1310 | if err.errno == errno.ENOENT: |
|
|||
1311 |
|
|
1309 | return None | |
1312 | raise |
|
|||
1313 |
|
1310 | |||
1314 |
|
1311 | |||
1315 | def batchremove(repo, wctx, actions): |
|
1312 | def batchremove(repo, wctx, actions): |
@@ -1,5 +1,4 | |||||
1 | import collections |
|
1 | import collections | |
2 | import errno |
|
|||
3 | import shutil |
|
2 | import shutil | |
4 | import struct |
|
3 | import struct | |
5 | import weakref |
|
4 | import weakref | |
@@ -629,9 +628,8 class mergestate(_mergestate_base): | |||||
629 | else: |
|
628 | else: | |
630 | records.append((RECORD_MERGED, l[:-1])) |
|
629 | records.append((RECORD_MERGED, l[:-1])) | |
631 | f.close() |
|
630 | f.close() | |
632 |
except |
|
631 | except FileNotFoundError: | |
633 | if err.errno != errno.ENOENT: |
|
632 | pass | |
634 | raise |
|
|||
635 | return records |
|
633 | return records | |
636 |
|
634 | |||
637 | def _readrecordsv2(self): |
|
635 | def _readrecordsv2(self): | |
@@ -669,9 +667,8 class mergestate(_mergestate_base): | |||||
669 | rtype, record = record[0:1], record[1:] |
|
667 | rtype, record = record[0:1], record[1:] | |
670 | records.append((rtype, record)) |
|
668 | records.append((rtype, record)) | |
671 | f.close() |
|
669 | f.close() | |
672 |
except |
|
670 | except FileNotFoundError: | |
673 | if err.errno != errno.ENOENT: |
|
671 | pass | |
674 | raise |
|
|||
675 | return records |
|
672 | return records | |
676 |
|
673 | |||
677 | def commit(self): |
|
674 | def commit(self): |
@@ -69,7 +69,6 comment associated with each format for | |||||
69 | """ |
|
69 | """ | |
70 |
|
70 | |||
71 | import binascii |
|
71 | import binascii | |
72 | import errno |
|
|||
73 | import struct |
|
72 | import struct | |
74 |
|
73 | |||
75 | from .i18n import _ |
|
74 | from .i18n import _ | |
@@ -582,11 +581,10 class obsstore: | |||||
582 | if not self._cached('_all'): |
|
581 | if not self._cached('_all'): | |
583 | try: |
|
582 | try: | |
584 | return self.svfs.stat(b'obsstore').st_size > 1 |
|
583 | return self.svfs.stat(b'obsstore').st_size > 1 | |
585 |
except |
|
584 | except FileNotFoundError: | |
586 | if inst.errno != errno.ENOENT: |
|
|||
587 | raise |
|
|||
588 | # just build an empty _all list if no obsstore exists, which |
|
585 | # just build an empty _all list if no obsstore exists, which | |
589 | # avoids further stat() syscalls |
|
586 | # avoids further stat() syscalls | |
|
587 | pass | |||
590 | return bool(self._all) |
|
588 | return bool(self._all) | |
591 |
|
589 | |||
592 | __bool__ = __nonzero__ |
|
590 | __bool__ = __nonzero__ |
@@ -10,7 +10,6 | |||||
10 | import collections |
|
10 | import collections | |
11 | import contextlib |
|
11 | import contextlib | |
12 | import copy |
|
12 | import copy | |
13 | import errno |
|
|||
14 | import os |
|
13 | import os | |
15 | import re |
|
14 | import re | |
16 | import shutil |
|
15 | import shutil | |
@@ -503,14 +502,11 class fsbackend(abstractbackend): | |||||
503 | isexec = False |
|
502 | isexec = False | |
504 | try: |
|
503 | try: | |
505 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 |
|
504 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 | |
506 |
except |
|
505 | except FileNotFoundError: | |
507 | if e.errno != errno.ENOENT: |
|
506 | pass | |
508 | raise |
|
|||
509 | try: |
|
507 | try: | |
510 | return (self.opener.read(fname), (False, isexec)) |
|
508 | return (self.opener.read(fname), (False, isexec)) | |
511 |
except |
|
509 | except FileNotFoundError: | |
512 | if e.errno != errno.ENOENT: |
|
|||
513 | raise |
|
|||
514 | return None, None |
|
510 | return None, None | |
515 |
|
511 | |||
516 | def setfile(self, fname, data, mode, copysource): |
|
512 | def setfile(self, fname, data, mode, copysource): |
@@ -101,7 +101,6 Note: old client behave as a publishing | |||||
101 | """ |
|
101 | """ | |
102 |
|
102 | |||
103 |
|
103 | |||
104 | import errno |
|
|||
105 | import struct |
|
104 | import struct | |
106 |
|
105 | |||
107 | from .i18n import _ |
|
106 | from .i18n import _ | |
@@ -202,9 +201,7 def _readroots(repo, phasedefaults=None) | |||||
202 | roots[int(phase)].add(bin(nh)) |
|
201 | roots[int(phase)].add(bin(nh)) | |
203 | finally: |
|
202 | finally: | |
204 | f.close() |
|
203 | f.close() | |
205 |
except |
|
204 | except FileNotFoundError: | |
206 | if inst.errno != errno.ENOENT: |
|
|||
207 | raise |
|
|||
208 | if phasedefaults: |
|
205 | if phasedefaults: | |
209 | for f in phasedefaults: |
|
206 | for f in phasedefaults: | |
210 | roots = f(repo, roots) |
|
207 | roots = f(repo, roots) |
@@ -175,9 +175,7 def copymode(src, dst, mode=None, enforc | |||||
175 | using umask.""" |
|
175 | using umask.""" | |
176 | try: |
|
176 | try: | |
177 | st_mode = os.lstat(src).st_mode & 0o777 |
|
177 | st_mode = os.lstat(src).st_mode & 0o777 | |
178 |
except |
|
178 | except FileNotFoundError: | |
179 | if inst.errno != errno.ENOENT: |
|
|||
180 | raise |
|
|||
181 | st_mode = mode |
|
179 | st_mode = mode | |
182 | if st_mode is None: |
|
180 | if st_mode is None: | |
183 | st_mode = ~umask |
|
181 | st_mode = ~umask | |
@@ -226,19 +224,16 def checkexec(path): | |||||
226 |
|
224 | |||
227 | try: |
|
225 | try: | |
228 | m = os.stat(checkisexec).st_mode |
|
226 | m = os.stat(checkisexec).st_mode | |
229 |
except |
|
227 | except FileNotFoundError: | |
230 | if e.errno != errno.ENOENT: |
|
|||
231 | raise |
|
|||
232 | # checkisexec does not exist - fall through ... |
|
228 | # checkisexec does not exist - fall through ... | |
|
229 | pass | |||
233 | else: |
|
230 | else: | |
234 | # checkisexec exists, check if it actually is exec |
|
231 | # checkisexec exists, check if it actually is exec | |
235 | if m & EXECFLAGS != 0: |
|
232 | if m & EXECFLAGS != 0: | |
236 | # ensure checkisexec exists, check it isn't exec |
|
233 | # ensure checkisexec exists, check it isn't exec | |
237 | try: |
|
234 | try: | |
238 | m = os.stat(checknoexec).st_mode |
|
235 | m = os.stat(checknoexec).st_mode | |
239 |
except |
|
236 | except FileNotFoundError: | |
240 | if e.errno != errno.ENOENT: |
|
|||
241 | raise |
|
|||
242 | open(checknoexec, b'w').close() # might fail |
|
237 | open(checknoexec, b'w').close() # might fail | |
243 | m = os.stat(checknoexec).st_mode |
|
238 | m = os.stat(checknoexec).st_mode | |
244 | if m & EXECFLAGS == 0: |
|
239 | if m & EXECFLAGS == 0: |
@@ -16,7 +16,6 and O(changes) merge between branches. | |||||
16 | import binascii |
|
16 | import binascii | |
17 | import collections |
|
17 | import collections | |
18 | import contextlib |
|
18 | import contextlib | |
19 | import errno |
|
|||
20 | import io |
|
19 | import io | |
21 | import os |
|
20 | import os | |
22 | import struct |
|
21 | import struct | |
@@ -486,9 +485,7 class revlog: | |||||
486 | return fp.read() |
|
485 | return fp.read() | |
487 | else: |
|
486 | else: | |
488 | return fp.read(size) |
|
487 | return fp.read(size) | |
489 |
except |
|
488 | except FileNotFoundError: | |
490 | if inst.errno != errno.ENOENT: |
|
|||
491 | raise |
|
|||
492 | return b'' |
|
489 | return b'' | |
493 |
|
490 | |||
494 | def _loadindex(self, docket=None): |
|
491 | def _loadindex(self, docket=None): | |
@@ -701,9 +698,7 class revlog: | |||||
701 | else: |
|
698 | else: | |
702 | f.seek(self._docket.index_end, os.SEEK_SET) |
|
699 | f.seek(self._docket.index_end, os.SEEK_SET) | |
703 | return f |
|
700 | return f | |
704 |
except |
|
701 | except FileNotFoundError: | |
705 | if inst.errno != errno.ENOENT: |
|
|||
706 | raise |
|
|||
707 | return self.opener( |
|
702 | return self.opener( | |
708 | self._indexfile, mode=b"w+", checkambig=self._checkambig |
|
703 | self._indexfile, mode=b"w+", checkambig=self._checkambig | |
709 | ) |
|
704 | ) | |
@@ -2116,9 +2111,7 class revlog: | |||||
2116 | dfh.seek(0, os.SEEK_END) |
|
2111 | dfh.seek(0, os.SEEK_END) | |
2117 | else: |
|
2112 | else: | |
2118 | dfh.seek(self._docket.data_end, os.SEEK_SET) |
|
2113 | dfh.seek(self._docket.data_end, os.SEEK_SET) | |
2119 |
except |
|
2114 | except FileNotFoundError: | |
2120 | if inst.errno != errno.ENOENT: |
|
|||
2121 | raise |
|
|||
2122 | dfh = self._datafp(b"w+") |
|
2115 | dfh = self._datafp(b"w+") | |
2123 | transaction.add(self._datafile, dsize) |
|
2116 | transaction.add(self._datafile, dsize) | |
2124 | if self._sidedatafile is not None: |
|
2117 | if self._sidedatafile is not None: | |
@@ -2127,9 +2120,7 class revlog: | |||||
2127 | try: |
|
2120 | try: | |
2128 | sdfh = self.opener(self._sidedatafile, mode=b"r+") |
|
2121 | sdfh = self.opener(self._sidedatafile, mode=b"r+") | |
2129 | dfh.seek(self._docket.sidedata_end, os.SEEK_SET) |
|
2122 | dfh.seek(self._docket.sidedata_end, os.SEEK_SET) | |
2130 |
except |
|
2123 | except FileNotFoundError: | |
2131 | if inst.errno != errno.ENOENT: |
|
|||
2132 | raise |
|
|||
2133 | sdfh = self.opener(self._sidedatafile, mode=b"w+") |
|
2124 | sdfh = self.opener(self._sidedatafile, mode=b"w+") | |
2134 | transaction.add( |
|
2125 | transaction.add( | |
2135 | self._sidedatafile, self._docket.sidedata_end |
|
2126 | self._sidedatafile, self._docket.sidedata_end | |
@@ -2832,9 +2823,7 class revlog: | |||||
2832 | f.seek(0, io.SEEK_END) |
|
2823 | f.seek(0, io.SEEK_END) | |
2833 | actual = f.tell() |
|
2824 | actual = f.tell() | |
2834 | dd = actual - expected |
|
2825 | dd = actual - expected | |
2835 |
except |
|
2826 | except FileNotFoundError: | |
2836 | if inst.errno != errno.ENOENT: |
|
|||
2837 | raise |
|
|||
2838 | dd = 0 |
|
2827 | dd = 0 | |
2839 |
|
2828 | |||
2840 | try: |
|
2829 | try: | |
@@ -2851,9 +2840,7 class revlog: | |||||
2851 | databytes += max(0, self.length(r)) |
|
2840 | databytes += max(0, self.length(r)) | |
2852 | dd = 0 |
|
2841 | dd = 0 | |
2853 | di = actual - len(self) * s - databytes |
|
2842 | di = actual - len(self) * s - databytes | |
2854 |
except |
|
2843 | except FileNotFoundError: | |
2855 | if inst.errno != errno.ENOENT: |
|
|||
2856 | raise |
|
|||
2857 | di = 0 |
|
2844 | di = 0 | |
2858 |
|
2845 | |||
2859 | return (dd, di) |
|
2846 | return (dd, di) |
@@ -16,7 +16,6 | |||||
16 | # * a data file, containing variable width data for these revisions, |
|
16 | # * a data file, containing variable width data for these revisions, | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | import errno |
|
|||
20 | import os |
|
19 | import os | |
21 | import random |
|
20 | import random | |
22 | import struct |
|
21 | import struct | |
@@ -51,9 +50,7 if stable_docket_file: | |||||
51 | try: |
|
50 | try: | |
52 | with open(stable_docket_file, mode='rb') as f: |
|
51 | with open(stable_docket_file, mode='rb') as f: | |
53 | seed = f.read().strip() |
|
52 | seed = f.read().strip() | |
54 |
except |
|
53 | except FileNotFoundError: | |
55 | if inst.errno != errno.ENOENT: |
|
|||
56 | raise |
|
|||
57 | seed = b'04' # chosen by a fair dice roll. garanteed to be random |
|
54 | seed = b'04' # chosen by a fair dice roll. garanteed to be random | |
58 | iter_seed = iter(seed) |
|
55 | iter_seed = iter(seed) | |
59 | # some basic circular sum hashing on 64 bits |
|
56 | # some basic circular sum hashing on 64 bits |
@@ -7,7 +7,6 | |||||
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | import errno |
|
|||
11 | import re |
|
10 | import re | |
12 | import struct |
|
11 | import struct | |
13 |
|
12 | |||
@@ -83,11 +82,8 def persisted_data(revlog): | |||||
83 | data = b'' |
|
82 | data = b'' | |
84 | else: |
|
83 | else: | |
85 | data = fd.read(data_length) |
|
84 | data = fd.read(data_length) | |
86 | except (IOError, OSError) as e: |
|
85 | except FileNotFoundError: | |
87 | if e.errno == errno.ENOENT: |
|
|||
88 |
|
|
86 | return None | |
89 | else: |
|
|||
90 | raise |
|
|||
91 | if len(data) < data_length: |
|
87 | if len(data) < data_length: | |
92 | return None |
|
88 | return None | |
93 | return docket, data |
|
89 | return docket, data |
@@ -1619,9 +1619,8 class filecachesubentry: | |||||
1619 | def stat(path): |
|
1619 | def stat(path): | |
1620 | try: |
|
1620 | try: | |
1621 | return util.cachestat(path) |
|
1621 | return util.cachestat(path) | |
1622 |
except |
|
1622 | except FileNotFoundError: | |
1623 | if e.errno != errno.ENOENT: |
|
1623 | pass | |
1624 | raise |
|
|||
1625 |
|
1624 | |||
1626 |
|
1625 | |||
1627 | class filecacheentry: |
|
1626 | class filecacheentry: |
@@ -22,7 +22,6 shelve". | |||||
22 | """ |
|
22 | """ | |
23 |
|
23 | |||
24 | import collections |
|
24 | import collections | |
25 | import errno |
|
|||
26 | import itertools |
|
25 | import itertools | |
27 | import stat |
|
26 | import stat | |
28 |
|
27 | |||
@@ -82,9 +81,7 class ShelfDir: | |||||
82 | """return all shelves in repo as list of (time, name)""" |
|
81 | """return all shelves in repo as list of (time, name)""" | |
83 | try: |
|
82 | try: | |
84 | names = self.vfs.listdir() |
|
83 | names = self.vfs.listdir() | |
85 |
except |
|
84 | except FileNotFoundError: | |
86 | if err.errno != errno.ENOENT: |
|
|||
87 | raise |
|
|||
88 | return [] |
|
85 | return [] | |
89 | info = [] |
|
86 | info = [] | |
90 | seen = set() |
|
87 | seen = set() | |
@@ -724,9 +721,7 def _loadshelvedstate(ui, repo, opts): | |||||
724 | state = shelvedstate.load(repo) |
|
721 | state = shelvedstate.load(repo) | |
725 | if opts.get(b'keep') is None: |
|
722 | if opts.get(b'keep') is None: | |
726 | opts[b'keep'] = state.keep |
|
723 | opts[b'keep'] = state.keep | |
727 |
except |
|
724 | except FileNotFoundError: | |
728 | if err.errno != errno.ENOENT: |
|
|||
729 | raise |
|
|||
730 | cmdutil.wrongtooltocontinue(repo, _(b'unshelve')) |
|
725 | cmdutil.wrongtooltocontinue(repo, _(b'unshelve')) | |
731 | except error.CorruptedState as err: |
|
726 | except error.CorruptedState as err: | |
732 | ui.debug(pycompat.bytestr(err) + b'\n') |
|
727 | ui.debug(pycompat.bytestr(err) + b'\n') |
@@ -181,9 +181,7 class statichttprepository( | |||||
181 |
|
181 | |||
182 | try: |
|
182 | try: | |
183 | requirements = set(self.vfs.read(b'requires').splitlines()) |
|
183 | requirements = set(self.vfs.read(b'requires').splitlines()) | |
184 |
except |
|
184 | except FileNotFoundError: | |
185 | if inst.errno != errno.ENOENT: |
|
|||
186 | raise |
|
|||
187 | requirements = set() |
|
185 | requirements = set() | |
188 |
|
186 | |||
189 | # check if it is a non-empty old-style repository |
|
187 | # check if it is a non-empty old-style repository | |
@@ -191,9 +189,7 class statichttprepository( | |||||
191 | fp = self.vfs(b"00changelog.i") |
|
189 | fp = self.vfs(b"00changelog.i") | |
192 | fp.read(1) |
|
190 | fp.read(1) | |
193 | fp.close() |
|
191 | fp.close() | |
194 |
except |
|
192 | except FileNotFoundError: | |
195 | if inst.errno != errno.ENOENT: |
|
|||
196 | raise |
|
|||
197 | # we do not care about empty old-style repositories here |
|
193 | # we do not care about empty old-style repositories here | |
198 | msg = _(b"'%s' does not appear to be an hg repository") % path |
|
194 | msg = _(b"'%s' does not appear to be an hg repository") % path | |
199 | raise error.RepoError(msg) |
|
195 | raise error.RepoError(msg) |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import functools |
|
9 | import functools | |
11 | import os |
|
10 | import os | |
12 | import re |
|
11 | import re | |
@@ -788,9 +787,8 class fncachestore(basicstore): | |||||
788 | assert t is not None, f |
|
787 | assert t is not None, f | |
789 | t |= FILEFLAGS_FILELOG |
|
788 | t |= FILEFLAGS_FILELOG | |
790 | yield t, f, self.getsize(ef) |
|
789 | yield t, f, self.getsize(ef) | |
791 |
except |
|
790 | except FileNotFoundError: | |
792 | if err.errno != errno.ENOENT: |
|
791 | pass | |
793 | raise |
|
|||
794 |
|
792 | |||
795 | def copylist(self): |
|
793 | def copylist(self): | |
796 | d = ( |
|
794 | d = ( | |
@@ -825,10 +823,7 class fncachestore(basicstore): | |||||
825 | try: |
|
823 | try: | |
826 | self.getsize(ef) |
|
824 | self.getsize(ef) | |
827 | return True |
|
825 | return True | |
828 |
except |
|
826 | except FileNotFoundError: | |
829 | if err.errno != errno.ENOENT: |
|
|||
830 | raise |
|
|||
831 | # nonexistent entry |
|
|||
832 | return False |
|
827 | return False | |
833 |
|
828 | |||
834 | def __contains__(self, path): |
|
829 | def __contains__(self, path): |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import os |
|
9 | import os | |
11 | import posixpath |
|
10 | import posixpath | |
12 | import re |
|
11 | import re | |
@@ -63,9 +62,7 def state(ctx, ui): | |||||
63 | if f in ctx: |
|
62 | if f in ctx: | |
64 | try: |
|
63 | try: | |
65 | data = ctx[f].data() |
|
64 | data = ctx[f].data() | |
66 |
except |
|
65 | except FileNotFoundError: | |
67 | if err.errno != errno.ENOENT: |
|
|||
68 | raise |
|
|||
69 | # handle missing subrepo spec files as removed |
|
66 | # handle missing subrepo spec files as removed | |
70 | ui.warn( |
|
67 | ui.warn( | |
71 | _(b"warning: subrepo spec file \'%s\' not found\n") |
|
68 | _(b"warning: subrepo spec file \'%s\' not found\n") | |
@@ -102,9 +99,8 def state(ctx, ui): | |||||
102 | % (repo.pathto(b'.hgsubstate'), (i + 1)) |
|
99 | % (repo.pathto(b'.hgsubstate'), (i + 1)) | |
103 | ) |
|
100 | ) | |
104 | rev[path] = revision |
|
101 | rev[path] = revision | |
105 |
except |
|
102 | except FileNotFoundError: | |
106 | if err.errno != errno.ENOENT: |
|
103 | pass | |
107 | raise |
|
|||
108 |
|
104 | |||
109 | def remap(src): |
|
105 | def remap(src): | |
110 | # type: (bytes) -> bytes |
|
106 | # type: (bytes) -> bytes |
@@ -12,7 +12,6 | |||||
12 |
|
12 | |||
13 |
|
13 | |||
14 | import binascii |
|
14 | import binascii | |
15 | import errno |
|
|||
16 | import io |
|
15 | import io | |
17 |
|
16 | |||
18 | from .node import ( |
|
17 | from .node import ( | |
@@ -242,9 +241,7 def readlocaltags(ui, repo, alltags, tag | |||||
242 | '''Read local tags in repo. Update alltags and tagtypes.''' |
|
241 | '''Read local tags in repo. Update alltags and tagtypes.''' | |
243 | try: |
|
242 | try: | |
244 | data = repo.vfs.read(b"localtags") |
|
243 | data = repo.vfs.read(b"localtags") | |
245 |
except |
|
244 | except FileNotFoundError: | |
246 | if inst.errno != errno.ENOENT: |
|
|||
247 | raise |
|
|||
248 | return |
|
245 | return | |
249 |
|
246 | |||
250 | # localtags is in the local encoding; re-encode to UTF-8 on |
|
247 | # localtags is in the local encoding; re-encode to UTF-8 on | |
@@ -652,9 +649,7 def _tag( | |||||
652 |
|
649 | |||
653 | try: |
|
650 | try: | |
654 | fp = repo.wvfs(b'.hgtags', b'rb+') |
|
651 | fp = repo.wvfs(b'.hgtags', b'rb+') | |
655 |
except |
|
652 | except FileNotFoundError: | |
656 | if e.errno != errno.ENOENT: |
|
|||
657 | raise |
|
|||
658 | fp = repo.wvfs(b'.hgtags', b'ab') |
|
653 | fp = repo.wvfs(b'.hgtags', b'ab') | |
659 | else: |
|
654 | else: | |
660 | prevtags = fp.read() |
|
655 | prevtags = fp.read() |
@@ -12,8 +12,6 | |||||
12 | # GNU General Public License version 2 or any later version. |
|
12 | # GNU General Public License version 2 or any later version. | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | import errno |
|
|||
16 |
|
||||
17 | from .i18n import _ |
|
15 | from .i18n import _ | |
18 | from . import ( |
|
16 | from . import ( | |
19 | error, |
|
17 | error, | |
@@ -71,9 +69,8 def _playback( | |||||
71 | else: |
|
69 | else: | |
72 | try: |
|
70 | try: | |
73 | opener.unlink(f) |
|
71 | opener.unlink(f) | |
74 |
except |
|
72 | except FileNotFoundError: | |
75 | if inst.errno != errno.ENOENT: |
|
73 | pass | |
76 | raise |
|
|||
77 |
|
74 | |||
78 | backupfiles = [] |
|
75 | backupfiles = [] | |
79 | for l, f, b, c in backupentries: |
|
76 | for l, f, b, c in backupentries: | |
@@ -95,9 +92,8 def _playback( | |||||
95 | target = f or b |
|
92 | target = f or b | |
96 | try: |
|
93 | try: | |
97 | vfs.unlink(target) |
|
94 | vfs.unlink(target) | |
98 |
except |
|
95 | except FileNotFoundError: | |
99 | if inst.errno != errno.ENOENT: |
|
96 | pass | |
100 | raise |
|
|||
101 | except (IOError, OSError, error.Abort): |
|
97 | except (IOError, OSError, error.Abort): | |
102 | if not c: |
|
98 | if not c: | |
103 | raise |
|
99 | raise |
@@ -6,8 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 |
|
||||
11 | from . import encoding |
|
9 | from . import encoding | |
12 |
|
10 | |||
13 |
|
11 | |||
@@ -29,7 +27,6 def trypending(root, vfs, filename, **kw | |||||
29 | if mayhavepending(root): |
|
27 | if mayhavepending(root): | |
30 | try: |
|
28 | try: | |
31 | return (vfs(b'%s.pending' % filename, **kwargs), True) |
|
29 | return (vfs(b'%s.pending' % filename, **kwargs), True) | |
32 |
except |
|
30 | except FileNotFoundError: | |
33 | if inst.errno != errno.ENOENT: |
|
31 | pass | |
34 | raise |
|
|||
35 | return (vfs(filename, **kwargs), False) |
|
32 | return (vfs(filename, **kwargs), False) |
@@ -1517,8 +1517,8 class ui: | |||||
1517 | stderr=procutil.stderr, |
|
1517 | stderr=procutil.stderr, | |
1518 | env=procutil.tonativeenv(procutil.shellenviron(env)), |
|
1518 | env=procutil.tonativeenv(procutil.shellenviron(env)), | |
1519 | ) |
|
1519 | ) | |
1520 |
except |
|
1520 | except FileNotFoundError: | |
1521 |
if |
|
1521 | if not shell: | |
1522 | self.warn( |
|
1522 | self.warn( | |
1523 | _(b"missing pager command '%s', skipping pager\n") % command |
|
1523 | _(b"missing pager command '%s', skipping pager\n") % command | |
1524 | ) |
|
1524 | ) |
@@ -6,7 +6,6 | |||||
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 |
|
8 | |||
9 | import errno |
|
|||
10 | import stat |
|
9 | import stat | |
11 |
|
10 | |||
12 | from ..i18n import _ |
|
11 | from ..i18n import _ | |
@@ -646,11 +645,10 def upgrade_dirstate(ui, srcrepo, upgrad | |||||
646 | util.copyfile( |
|
645 | util.copyfile( | |
647 | srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') |
|
646 | srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') | |
648 | ) |
|
647 | ) | |
649 | except (IOError, OSError) as e: |
|
648 | except FileNotFoundError: | |
650 | # The dirstate does not exist on an empty repo or a repo with no |
|
649 | # The dirstate does not exist on an empty repo or a repo with no | |
651 | # revision checked out |
|
650 | # revision checked out | |
652 | if e.errno != errno.ENOENT: |
|
651 | pass | |
653 | raise |
|
|||
654 |
|
652 | |||
655 | assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') |
|
653 | assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') | |
656 | srcrepo.dirstate._map.preload() |
|
654 | srcrepo.dirstate._map.preload() | |
@@ -659,11 +657,10 def upgrade_dirstate(ui, srcrepo, upgrad | |||||
659 | srcrepo.dirstate._dirty = True |
|
657 | srcrepo.dirstate._dirty = True | |
660 | try: |
|
658 | try: | |
661 | srcrepo.vfs.unlink(b'dirstate') |
|
659 | srcrepo.vfs.unlink(b'dirstate') | |
662 | except (IOError, OSError) as e: |
|
660 | except FileNotFoundError: | |
663 | # The dirstate does not exist on an empty repo or a repo with no |
|
661 | # The dirstate does not exist on an empty repo or a repo with no | |
664 | # revision checked out |
|
662 | # revision checked out | |
665 | if e.errno != errno.ENOENT: |
|
663 | pass | |
666 | raise |
|
|||
667 |
|
664 | |||
668 | srcrepo.dirstate.write(None) |
|
665 | srcrepo.dirstate.write(None) | |
669 |
|
666 |
@@ -2426,9 +2426,7 class filestat: | |||||
2426 | def frompath(cls, path): |
|
2426 | def frompath(cls, path): | |
2427 | try: |
|
2427 | try: | |
2428 | stat = os.stat(path) |
|
2428 | stat = os.stat(path) | |
2429 |
except |
|
2429 | except FileNotFoundError: | |
2430 | if err.errno != errno.ENOENT: |
|
|||
2431 | raise |
|
|||
2432 | stat = None |
|
2430 | stat = None | |
2433 | return cls(stat) |
|
2431 | return cls(stat) | |
2434 |
|
2432 | |||
@@ -2612,12 +2610,11 def unlinkpath(f, ignoremissing=False, r | |||||
2612 |
|
2610 | |||
2613 | def tryunlink(f): |
|
2611 | def tryunlink(f): | |
2614 | # type: (bytes) -> None |
|
2612 | # type: (bytes) -> None | |
2615 |
"""Attempt to remove a file, ignoring |
|
2613 | """Attempt to remove a file, ignoring FileNotFoundError.""" | |
2616 | try: |
|
2614 | try: | |
2617 | unlink(f) |
|
2615 | unlink(f) | |
2618 |
except |
|
2616 | except FileNotFoundError: | |
2619 | if e.errno != errno.ENOENT: |
|
2617 | pass | |
2620 | raise |
|
|||
2621 |
|
2618 | |||
2622 |
|
2619 | |||
2623 | def makedirs(name, mode=None, notindexed=False): |
|
2620 | def makedirs(name, mode=None, notindexed=False): |
@@ -6,7 +6,6 | |||||
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 | import contextlib |
|
8 | import contextlib | |
9 | import errno |
|
|||
10 | import os |
|
9 | import os | |
11 | import shutil |
|
10 | import shutil | |
12 | import stat |
|
11 | import stat | |
@@ -74,18 +73,16 class abstractvfs: | |||||
74 | '''gracefully return an empty string for missing files''' |
|
73 | '''gracefully return an empty string for missing files''' | |
75 | try: |
|
74 | try: | |
76 | return self.read(path) |
|
75 | return self.read(path) | |
77 |
except |
|
76 | except FileNotFoundError: | |
78 | if inst.errno != errno.ENOENT: |
|
77 | pass | |
79 | raise |
|
|||
80 | return b"" |
|
78 | return b"" | |
81 |
|
79 | |||
82 | def tryreadlines(self, path, mode=b'rb'): |
|
80 | def tryreadlines(self, path, mode=b'rb'): | |
83 | '''gracefully return an empty array for missing files''' |
|
81 | '''gracefully return an empty array for missing files''' | |
84 | try: |
|
82 | try: | |
85 | return self.readlines(path, mode=mode) |
|
83 | return self.readlines(path, mode=mode) | |
86 |
except |
|
84 | except FileNotFoundError: | |
87 | if inst.errno != errno.ENOENT: |
|
85 | pass | |
88 | raise |
|
|||
89 | return [] |
|
86 | return [] | |
90 |
|
87 | |||
91 | @util.propertycache |
|
88 | @util.propertycache | |
@@ -476,9 +473,7 class vfs(abstractvfs): | |||||
476 | nlink = util.nlinks(f) |
|
473 | nlink = util.nlinks(f) | |
477 | if nlink < 1: |
|
474 | if nlink < 1: | |
478 | nlink = 2 # force mktempcopy (issue1922) |
|
475 | nlink = 2 # force mktempcopy (issue1922) | |
479 |
except |
|
476 | except FileNotFoundError: | |
480 | if e.errno != errno.ENOENT: |
|
|||
481 | raise |
|
|||
482 | nlink = 0 |
|
477 | nlink = 0 | |
483 | if makeparentdirs: |
|
478 | if makeparentdirs: | |
484 | util.makedirs(dirname, self.createmode, notindexed) |
|
479 | util.makedirs(dirname, self.createmode, notindexed) |
@@ -362,9 +362,7 def parselistfiles(files, listtype, warn | |||||
362 | try: |
|
362 | try: | |
363 | path = os.path.expanduser(os.path.expandvars(filename)) |
|
363 | path = os.path.expanduser(os.path.expandvars(filename)) | |
364 | f = open(path, "rb") |
|
364 | f = open(path, "rb") | |
365 |
except |
|
365 | except FileNotFoundError: | |
366 | if err.errno != errno.ENOENT: |
|
|||
367 | raise |
|
|||
368 | if warn: |
|
366 | if warn: | |
369 | print("warning: no such %s file: %s" % (listtype, filename)) |
|
367 | print("warning: no such %s file: %s" % (listtype, filename)) | |
370 | continue |
|
368 | continue | |
@@ -390,9 +388,8 def parsettestcases(path): | |||||
390 | for l in f: |
|
388 | for l in f: | |
391 | if l.startswith(b'#testcases '): |
|
389 | if l.startswith(b'#testcases '): | |
392 | cases.append(sorted(l[11:].split())) |
|
390 | cases.append(sorted(l[11:].split())) | |
393 |
except |
|
391 | except FileNotFoundError: | |
394 | if ex.errno != errno.ENOENT: |
|
392 | pass | |
395 | raise |
|
|||
396 | return cases |
|
393 | return cases | |
397 |
|
394 | |||
398 |
|
395 | |||
@@ -1110,12 +1107,11 class Test(unittest.TestCase): | |||||
1110 | if os.path.exists(self.errpath): |
|
1107 | if os.path.exists(self.errpath): | |
1111 | try: |
|
1108 | try: | |
1112 | os.remove(self.errpath) |
|
1109 | os.remove(self.errpath) | |
1113 |
except |
|
1110 | except FileNotFoundError: | |
1114 | # We might have raced another test to clean up a .err |
|
1111 | # We might have raced another test to clean up a .err file, | |
1115 |
# |
|
1112 | # so ignore FileNotFoundError when removing a previous .err | |
1116 | # file. |
|
1113 | # file. | |
1117 | if e.errno != errno.ENOENT: |
|
1114 | pass | |
1118 | raise |
|
|||
1119 |
|
1115 | |||
1120 | if self._usechg: |
|
1116 | if self._usechg: | |
1121 | self._chgsockdir = os.path.join( |
|
1117 | self._chgsockdir = os.path.join( | |
@@ -2622,9 +2618,8 def loadtimes(outputdir): | |||||
2622 | times.append( |
|
2618 | times.append( | |
2623 | (m.group(1), [float(t) for t in m.group(2).split()]) |
|
2619 | (m.group(1), [float(t) for t in m.group(2).split()]) | |
2624 | ) |
|
2620 | ) | |
2625 |
except |
|
2621 | except FileNotFoundError: | |
2626 | if err.errno != errno.ENOENT: |
|
2622 | pass | |
2627 | raise |
|
|||
2628 | return times |
|
2623 | return times | |
2629 |
|
2624 | |||
2630 |
|
2625 | |||
@@ -2979,9 +2974,7 def sorttests(testdescs, previoustimes, | |||||
2979 | except KeyError: |
|
2974 | except KeyError: | |
2980 | try: |
|
2975 | try: | |
2981 | val = -os.stat(f).st_size |
|
2976 | val = -os.stat(f).st_size | |
2982 |
except |
|
2977 | except FileNotFoundError: | |
2983 | if e.errno != errno.ENOENT: |
|
|||
2984 | raise |
|
|||
2985 | perf[f] = -1e9 # file does not exist, tell early |
|
2978 | perf[f] = -1e9 # file does not exist, tell early | |
2986 | return -1e9 |
|
2979 | return -1e9 | |
2987 | for kw, mul in slow.items(): |
|
2980 | for kw, mul in slow.items(): | |
@@ -3584,9 +3577,8 class TestRunner: | |||||
3584 | if os.readlink(mypython) == sysexecutable: |
|
3577 | if os.readlink(mypython) == sysexecutable: | |
3585 | continue |
|
3578 | continue | |
3586 | os.unlink(mypython) |
|
3579 | os.unlink(mypython) | |
3587 |
except |
|
3580 | except FileNotFoundError: | |
3588 | if err.errno != errno.ENOENT: |
|
3581 | pass | |
3589 | raise |
|
|||
3590 | if self._findprogram(pyexename) != sysexecutable: |
|
3582 | if self._findprogram(pyexename) != sysexecutable: | |
3591 | try: |
|
3583 | try: | |
3592 | os.symlink(sysexecutable, mypython) |
|
3584 | os.symlink(sysexecutable, mypython) | |
@@ -3714,9 +3706,8 class TestRunner: | |||||
3714 | if not self.options.verbose: |
|
3706 | if not self.options.verbose: | |
3715 | try: |
|
3707 | try: | |
3716 | os.remove(installerrs) |
|
3708 | os.remove(installerrs) | |
3717 |
except |
|
3709 | except FileNotFoundError: | |
3718 | if e.errno != errno.ENOENT: |
|
3710 | pass | |
3719 | raise |
|
|||
3720 | else: |
|
3711 | else: | |
3721 | with open(installerrs, 'rb') as f: |
|
3712 | with open(installerrs, 'rb') as f: | |
3722 | for line in f: |
|
3713 | for line in f: |
@@ -58,9 +58,8 A set of extension and shell functions e | |||||
58 | > def delete(): |
|
58 | > def delete(): | |
59 | > try: |
|
59 | > try: | |
60 | > os.unlink(watchpath) |
|
60 | > os.unlink(watchpath) | |
61 |
> except |
|
61 | > except FileNotFoundError: | |
62 | > if exc.errno != errno.ENOENT: |
|
62 | > pass | |
63 | > raise |
|
|||
64 | > ui.atexit(delete) |
|
63 | > ui.atexit(delete) | |
65 | > return orig(pushop) |
|
64 | > return orig(pushop) | |
66 | > |
|
65 | > |
General Comments 0
You need to be logged in to leave comments.
Login now