3 import hashsplit, git, options
7 bup split [-tcb] [-n name] [--bench] [filenames...]
9 r,remote= remote repository path
10 b,blobs output a series of blob ids
11 t,tree output a tree id
12 c,commit output a commit id
13 n,name= name of backup set to update (if any)
14 v,verbose increase log output (can be used more than once)
15 bench print benchmark timings to stderr
17 o = options.Options('bup split', optspec)
18 (opt, flags, extra) = o.parse(sys.argv[1:])
20 git.check_repo_or_die()
21 if not (opt.blobs or opt.tree or opt.commit or opt.name):
22 log("bup split: use one or more of -b, -t, -c, -n\n")
25 hashsplit.split_verbosely = opt.verbose
27 git.verbose = opt.verbose - 1
30 start_time = time.time()
32 def server_connect(remote):
33 rs = remote.split(':', 1)
35 p = subprocess.Popen(['bup', 'server', '-d', opt.remote],
36 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
39 p = subprocess.Popen(['ssh', host, '--', 'bup', 'server'],
40 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
41 dir = re.sub(r'[\r\n]', ' ', dir)
42 p.stdin.write('set-dir\n%s\n' % dir)
46 p = server_connect(opt.remote)
47 p.stdin.write('receive-objects\n')
48 w = git.PackWriter_Remote(p.stdin)
52 (shalist,tree) = hashsplit.split_to_tree(w, hashsplit.autofiles(extra))
57 for (mode,name,bin) in shalist:
58 print bin.encode('hex')
60 print tree.encode('hex')
61 if opt.commit or opt.name:
62 msg = 'bup split\n\nGenerated by command:\n%r' % sys.argv
63 ref = opt.name and ('refs/heads/%s' % opt.name) or None
64 commit = w.new_commit(ref, tree, msg)
66 print commit.encode('hex')
70 p.stdin.write('quit\n')
73 secs = time.time() - start_time
74 size = hashsplit.total_split
76 log('\nbup: %.2fkbytes in %.2f secs = %.2f kbytes/sec\n'
77 % (size/1024., secs, size/1024./secs))