]> arthur.barton.de Git - bup.git/blobdiff - cmd/split-cmd.py
cmd/{split,save}: support any compression level using the new -# feature.
[bup.git] / cmd / split-cmd.py
index 363896f792381f3b85d34cc3ab98339af0458d2d..438fe40aaa73599938742d14fb77d77d1d522406 100755 (executable)
@@ -26,6 +26,7 @@ max-pack-size=  maximum bytes in a single pack
 max-pack-objects=  maximum number of objects in a single pack
 fanout=    maximum number of blobs in a single tree
 bwlimit=   maximum bytes/sec to transmit to server
+#,compress=  set compression level to # (0-9, 9 is highest) [1]
 """
 o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
@@ -47,9 +48,9 @@ if opt.verbose >= 2:
     git.verbose = opt.verbose - 1
     opt.bench = 1
 if opt.max_pack_size:
-    hashsplit.max_pack_size = parse_num(opt.max_pack_size)
+    git.max_pack_size = parse_num(opt.max_pack_size)
 if opt.max_pack_objects:
-    hashsplit.max_pack_objects = parse_num(opt.max_pack_objects)
+    git.max_pack_objects = parse_num(opt.max_pack_objects)
 if opt.fanout:
     hashsplit.fanout = parse_num(opt.fanout)
 if opt.blobs:
@@ -61,7 +62,6 @@ if opt.date:
 else:
     date = time.time()
 
-
 total_bytes = 0
 def prog(filenum, nbytes):
     global total_bytes
@@ -84,13 +84,13 @@ refname = opt.name and 'refs/heads/%s' % opt.name or None
 if opt.noop or opt.copy:
     cli = pack_writer = oldref = None
 elif opt.remote or is_reverse:
-    cli = client.Client(opt.remote)
+    cli = client.Client(opt.remote, compression_level=opt.compress)
     oldref = refname and cli.read_ref(refname) or None
     pack_writer = cli.new_packwriter()
 else:
     cli = None
     oldref = refname and git.read_ref(refname) or None
-    pack_writer = git.PackWriter()
+    pack_writer = git.PackWriter(compression_level=opt.compress)
 
 if opt.git_ids:
     # the input is actually a series of git object ids that we should retrieve
@@ -128,14 +128,16 @@ else:
     files = extra and (open(fn) for fn in extra) or [sys.stdin]
 
 if pack_writer and opt.blobs:
-    shalist = hashsplit.split_to_blobs(pack_writer, files,
+    shalist = hashsplit.split_to_blobs(pack_writer.new_blob, files,
                                        keep_boundaries=opt.keep_boundaries,
                                        progress=prog)
     for (sha, size, level) in shalist:
         print sha.encode('hex')
         reprogress()
 elif pack_writer:  # tree or commit or name
-    shalist = hashsplit.split_to_shalist(pack_writer, files,
+    shalist = hashsplit.split_to_shalist(pack_writer.new_blob,
+                                         pack_writer.new_tree,
+                                         files,
                                          keep_boundaries=opt.keep_boundaries,
                                          progress=prog)
     tree = pack_writer.new_tree(shalist)