def add_error(e):
saved_errors.append(e)
- log('%s\n' % e)
+ log('\n%s\n' % e)
def direxpand(names):
for n in names:
- log('%s\n' % n)
try:
for sub in os.listdir(n):
subfull = os.path.join(n, sub)
t,tree output a tree id
c,commit output a commit id
n,name= name of backup set to update (if any)
+v,verbose increase log output (can be used more than once)
"""
o = options.Options('bup save', optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
log("bup save: use one or more of -t, -c, -n\n")
o.usage()
+if opt.verbose >= 2:
+ git.verbose = opt.verbose - 1
+ hashsplit.split_verbosely = opt.verbose - 1
+
root = Tree(None, '')
for fn in direxpand(extra):
+ if opt.verbose:
+ log('\n%s ' % fn)
try:
# FIXME: symlinks etc.
f = open(fn)
(mode, id) = hashsplit.split_to_blob_or_tree([f])
root.addfile(mode, fn, id)
tree = root.gen_tree()
+if opt.verbose:
+ log('\n')
if opt.tree:
- print tree
+ print tree.encode('hex')
if opt.commit or opt.name:
msg = 'bup save\n\nGenerated by command:\n%r' % sys.argv
ref = opt.name and ('refs/heads/%s' % opt.name) or None
commit = git.gen_commit_easy(ref, tree, msg)
if opt.commit:
- print commit
+ print commit.encode('hex')
git.flush_pack()
userline = '%s <%s@%s>' % (userfullname(), username(), hostname())
oldref = ref and _read_ref('.git', ref) or None
commit = gen_commit(tree, oldref, userline, now, userline, now, msg)
+ flush_pack()
if ref:
- _update_ref('.git', ref, commit, oldref)
+ _update_ref('.git', ref, commit.encode('hex'), oldref)
return commit