]> arthur.barton.de Git - bup.git/blobdiff - cmd/restore-cmd.py
tvfs: accommodate python 3 and test there
[bup.git] / cmd / restore-cmd.py
index a9dbd3df78a715b70f7d2b9c7042e593d08d8611..0edbdefff1395dff0ca101efdb8f3728bae306c7 100755 (executable)
@@ -5,7 +5,7 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 from stat import S_ISDIR
 import copy, errno, os, sys, stat, re
 
@@ -246,10 +246,21 @@ def main():
             add_error("path %r doesn't include a branch and revision" % path)
             continue
         try:
-            resolved = vfs.lresolve(repo, path, want_meta=True)
+            resolved = vfs.resolve(repo, path, want_meta=True, follow=False)
         except vfs.IOError as e:
             add_error(e)
             continue
+        if len(resolved) == 3 and resolved[2][0] == 'latest':
+            # Follow latest symlink to the actual save
+            try:
+                resolved = vfs.resolve(repo, 'latest', parent=resolved[:-1],
+                                       want_meta=True)
+            except vfs.IOError as e:
+                add_error(e)
+                continue
+            # Rename it back to 'latest'
+            resolved = tuple(elt if i != 2 else ('latest',) + elt[1:]
+                             for i, elt in enumerate(resolved))
         path_parent, path_name = os.path.split(path)
         leaf_name, leaf_item = resolved[-1]
         if not leaf_item: