-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
import sys
+
from bup import git, options, client
-from bup.helpers import *
+from bup.helpers import linereader, log
optspec = """
bup join [-r host:path] [refs or hashes...]
--
r,remote= remote repository path
+o= output filename
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
cp = git.CatPipe()
cat = cp.join
+if opt.o:
+ outfile = open(opt.o, 'wb')
+else:
+ outfile = sys.stdout
+
for id in extra:
try:
for blob in cat(id):
- sys.stdout.write(blob)
- except KeyError, e:
- sys.stdout.flush()
+ outfile.write(blob)
+ except KeyError as e:
+ outfile.flush()
log('error: %s\n' % e)
ret = 1