]> arthur.barton.de Git - bup.git/commitdiff
vfs2: drop custom Loop error; just use ELOOP IOError
authorRob Browning <rlb@defaultvalue.org>
Sat, 9 Dec 2017 19:41:36 +0000 (13:41 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 16 Dec 2017 23:29:23 +0000 (17:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/t/tvfs.py
lib/bup/vfs2.py

index d850dc85148775f3b036495d9a96630d041471a9..7cbd9467a6ad381bfa15751d2dece79e13c36ed2 100644 (file)
@@ -1,6 +1,7 @@
 
 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
@@ -346,7 +347,12 @@ def test_resolve_loop():
             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():
index 49f0c4a114eb79967cce577fe3757fdfcbe7d4e3..3ec956b20816e3b8110f44645864a16c96f1676b 100644 (file)
@@ -62,12 +62,8 @@ from bup.repo import LocalRepo, RemoteRepo
 
 
 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
@@ -739,9 +735,10 @@ def _resolve_path(repo, path, parent=None, want_meta=True, deref=False):
                     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
@@ -761,12 +758,12 @@ def resolve(repo, path, parent=None, want_meta=True):
     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