from __future__ import print_function
from collections import namedtuple
+from errno import ELOOP
from io import BytesIO
from os import environ, symlink
from stat import S_IFDIR, S_IFREG, S_ISDIR, S_ISREG
ex((bup_path, 'index', '-v', data_path))
ex((bup_path, 'save', '-d', '100000', '-tvvn', 'test', '--strip',
data_path))
- wvexcept(vfs.Loop, resolve, repo, '/test/latest/loop')
+ try:
+ resolve(repo, '/test/latest/loop')
+ except vfs.IOError as res_ex:
+ wvpasseq(ELOOP, res_ex.errno)
+ wvpasseq(['', 'test', 'latest', 'loop'],
+ [name for name, item in res_ex.terminus])
@wvtest
def test_contents_with_mismatched_bupm_git_ordering():
class IOError(exceptions.IOError):
- def __init__(self, errno, message):
+ def __init__(self, errno, message, terminus=None):
exceptions.IOError.__init__(self, errno, message)
-
-class Loop(IOError):
- def __init__(self, message, terminus=None):
- IOError.__init__(self, ELOOP, message)
self.terminus = terminus
default_file_mode = S_IFREG | 0o644
future.extend(target_future)
hops += 1
if hops > 100:
- raise Loop('too many symlinks encountered while resolving %r%s'
- % (path,
- 'relative to %r' % parent if parent else ''))
+ raise IOError(ELOOP,
+ 'too many symlinks encountered while resolving %r%s'
+ % (path, 'relative to %r' % parent if parent else ''),
+ terminus=tuple(past + [(segment, item)]))
def lresolve(repo, path, parent=None, want_meta=True):
"""Perform exactly the same function as resolve(), except if the
item, and that item in the result will be None.
Any symlinks along the path, including at the end, will be
- resolved. A Loop exception will be raised if too many symlinks
- are traversed whiile following the path. raised if too many
- symlinks are traversed while following the path. That exception
- is effectively like a normal ELOOP IOError exception, but will
- include a terminus element describing the location of the failure,
- which will be a tuple of (name, info) elements.
+ resolved. A VFS IOError with the errno attribute set to ELOOP
+ will be raised if too many symlinks are traversed while following
+ the path. That exception is effectively like a normal
+ ELOOP IOError exception, but will include a terminus element
+ describing the location of the failure, which will be a tuple of
+ (name, info) elements.
Currently, a path ending in '/' will still resolve if it exists,
even if not a directory. The parent, if specified, must be a