]> arthur.barton.de Git - bup.git/blobdiff - cmd/join-cmd.py
test-cat-file.sh: handle hashsplit bupm files
[bup.git] / cmd / join-cmd.py
index d2cc888cd3020a4404f62aaf37950d848d64077e..042b4023de5af8ad4cd8425e96292d7346d6fc36 100755 (executable)
@@ -8,8 +8,9 @@ optspec = """
 bup join [-r host:path] [refs or hashes...]
 --
 r,remote=  remote repository path
+o=         output filename
 """
-o = options.Options('bup join', optspec)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 git.check_repo_or_die()
@@ -20,23 +21,23 @@ if not extra:
 ret = 0
 
 if opt.remote:
-    if opt.remote and opt.remote.find(":") == -1:
-        o.fatal("--remote argument must contain a colon")
-    try:
-        cli = client.Client(opt.remote)
-    except client.ClientError:
-        o.fatal("server exited unexpectedly; see errors above")
+    cli = client.Client(opt.remote)
     cat = cli.cat
 else:
     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)
+            outfile.write(blob)
     except KeyError, e:
-        sys.stdout.flush()
+        outfile.flush()
         log('error: %s\n' % e)
         ret = 1