]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/cmd/get.py
pylint: enable inconsistent-return-statements
[bup.git] / lib / bup / cmd / get.py
index 8844544c0f7b0ae34a0fd4cbdb23fe39bb8a09ee..599dcc6b489c1aee2f5a128e087c2ca1a2abe197 100755 (executable)
@@ -2,22 +2,20 @@
 from __future__ import absolute_import, print_function
 from binascii import hexlify, unhexlify
 from collections import namedtuple
-from functools import partial
 from stat import S_ISDIR
 import os, sys, textwrap, time
 
-from bup import compat, git, client, helpers, vfs
+from bup import compat, git, client, vfs
 from bup.compat import (
     argv_bytes,
     bytes_from_byte,
     environ,
     hexstr,
     items,
-    wrap_main
 )
 from bup.git import get_cat_data, parse_commit, walk_object
-from bup.helpers import add_error, debug1, handle_ctrl_c, log, saved_errors
-from bup.helpers import hostname, shstr, tty_width
+from bup.helpers import add_error, debug1, log, saved_errors
+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
@@ -166,7 +164,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
@@ -231,7 +229,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'
@@ -250,7 +248,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:
@@ -283,11 +281,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
 
 
@@ -372,6 +370,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):
@@ -421,7 +421,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/'):
@@ -483,7 +483,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'):