equal
deleted
inserted
replaced
5 # |
5 # |
6 # This software may be used and distributed according to the terms of the |
6 # This software may be used and distributed according to the terms of the |
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 |
14 import sys |
13 import sys |
15 import time |
14 import time |
515 |
514 |
516 def _readrequires(vfs, allowmissing): |
515 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 ENOENT if raised""" |
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, |
524 # which means very old repositories may not have one. We assume |
523 # which means very old repositories may not have one. We assume |
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 IOError as e: |
527 except FileNotFoundError: |
529 if not (allowmissing and e.errno == errno.ENOENT): |
528 if not allowmissing: |
530 raise |
529 raise |
531 requirements = set() |
530 requirements = set() |
532 return requirements |
531 return requirements |
533 |
532 |
534 |
533 |
581 # The .hg/ path should exist and should be a directory. All other |
580 # The .hg/ path should exist and should be a directory. All other |
582 # cases are errors. |
581 # cases are errors. |
583 if not hgvfs.isdir(): |
582 if not hgvfs.isdir(): |
584 try: |
583 try: |
585 hgvfs.stat() |
584 hgvfs.stat() |
586 except OSError as e: |
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( |
592 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e)) |
590 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e)) |
593 ) |
591 ) |
3501 # leaving both src and dest on disk. delete dest to make sure |
3499 # leaving both src and dest on disk. delete dest to make sure |
3502 # the rename couldn't be such a no-op. |
3500 # the rename couldn't be such a no-op. |
3503 vfs.tryunlink(dest) |
3501 vfs.tryunlink(dest) |
3504 try: |
3502 try: |
3505 vfs.rename(src, dest) |
3503 vfs.rename(src, dest) |
3506 except OSError as exc: # journal file does not yet exist |
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 |
3512 |
3509 |
3513 def undoname(fn): |
3510 def undoname(fn): |