]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/cmd/get.py
Drop vestigial compat.items
[bup.git] / lib / bup / cmd / get.py
index 6c9b8ed249d0f3f2e701d7f19233d312a3a9e91d..ca40430ced279b2eb1dcdbef02c5638908a3f7d9 100755 (executable)
@@ -10,12 +10,11 @@ from bup.compat import (
     argv_bytes,
     bytes_from_byte,
     environ,
-    hexstr,
-    items,
+    hexstr
 )
 from bup.git import get_cat_data, parse_commit, walk_object
 from bup.helpers import add_error, debug1, log, saved_errors
-from bup.helpers import hostname, tty_width
+from bup.helpers import hostname, tty_width, parse_num
 from bup.io import path_msg
 from bup.pwdgrp import userfullname, username
 from bup.repo import LocalRepo, RemoteRepo
@@ -164,7 +163,7 @@ def parse_args(args):
             opt.compress = int(opt.compress)
         elif arg == b'--bwlimit':
             (opt.bwlimit,), remaining = require_n_args_or_die(1, remaining)
-            opt.bwlimit = long(opt.bwlimit)
+            opt.bwlimit = int(opt.bwlimit)
         elif arg.startswith(b'-') and len(arg) > 2 and arg[1] != b'-':
             # Try to interpret this as -xyz, i.e. "-xyz -> -x -y -z".
             # We do this last so that --foo -bar is valid if --foo
@@ -229,7 +228,7 @@ def find_vfs_item(name, repo):
     elif kind == vfs.RevList:
         kind = 'branch'
     elif kind == vfs.Commit:
-        if len(res) > 1 and type(res[-2][1]) == vfs.RevList:
+        if len(res) > 1 and isinstance(res[-2][1], vfs.RevList):
             kind = 'save'
         else:
             kind = 'commit'
@@ -248,7 +247,7 @@ def find_vfs_item(name, repo):
                            follow=False, want_meta=False)
         leaf_name, leaf_item = res[-1]
         assert leaf_item
-        assert type(leaf_item) == vfs.Commit
+        assert isinstance(leaf_item, vfs.Commit)
         name = b'/'.join(x[0] for x in res)
         kind = 'save'
     else:
@@ -281,11 +280,11 @@ def cleanup_vfs_path(p):
     return b'/' + result
 
 
-def validate_vfs_path(p):
+def validate_vfs_path(p, spec):
     if p.startswith(b'/.') \
        and not p.startswith(b'/.tag/'):
         misuse('unsupported destination path %s in %s'
-               % (path_msg(dest.path), spec_msg(spec)))
+               % (path_msg(p), spec_msg(spec)))
     return p
 
 
@@ -370,6 +369,8 @@ def handle_ff(item, src_repo, writer, opt):
         return item.src.hash, unhexlify(commit_items.tree)
     misuse('destination is not an ancestor of source for %s'
            % spec_msg(item.spec))
+    # misuse() doesn't return
+    return None
 
 
 def resolve_append(spec, src_repo, dest_repo):
@@ -419,7 +420,7 @@ def resolve_pick(spec, src_repo, dest_repo):
         misuse('no destination provided for %s', spec_args)
     dest = find_vfs_item(spec.dest, dest_repo)
     if not dest:
-        cp = validate_vfs_path(cleanup_vfs_path(spec.dest))
+        cp = validate_vfs_path(cleanup_vfs_path(spec.dest), spec)
         dest = default_loc._replace(path=cp)
     else:
         if not dest.type == 'branch' and not dest.path.startswith(b'/.tag/'):
@@ -481,7 +482,7 @@ def resolve_replace(spec, src_repo, dest_repo):
             misuse('%s impossible; can only overwrite branch or tag'
                   % spec_args)
     else:
-        cp = validate_vfs_path(cleanup_vfs_path(spec.dest))
+        cp = validate_vfs_path(cleanup_vfs_path(spec.dest), spec)
         dest = default_loc._replace(path=cp)
     if not dest.path.startswith(b'/.tag/') \
        and not src.type in ('branch', 'save', 'commit'):
@@ -643,7 +644,7 @@ def main(argv):
         # Only update the refs at the very end, once the writer is
         # closed, so that if something goes wrong above, the old refs
         # will be undisturbed.
-        for ref_name, info in items(updated_refs):
+        for ref_name, info in updated_refs.items():
             orig_ref, new_ref = info
             try:
                 dest_repo.update_ref(ref_name, new_ref, orig_ref)