]> arthur.barton.de Git - bup.git/blob - cmd/join-cmd.py
--remote parameter requires a colon
[bup.git] / cmd / join-cmd.py
1 #!/usr/bin/env python
2 import sys
3 from bup import git, options, client
4 from bup.helpers import *
5
6
7 optspec = """
8 bup join [-r host:path] [refs or hashes...]
9 --
10 r,remote=  remote repository path
11 """
12 o = options.Options('bup join', optspec)
13 (opt, flags, extra) = o.parse(sys.argv[1:])
14
15 git.check_repo_or_die()
16
17 if not extra:
18     extra = linereader(sys.stdin)
19
20 ret = 0
21
22 if opt.remote:
23     if opt.remote and opt.remote.find(":") == -1:
24         o.fatal("--remote argument must contain a colon")
25     try:
26         cli = client.Client(opt.remote)
27     except client.ClientError:
28         o.fatal("server exited unexpectedly; see errors above")
29     cat = cli.cat
30 else:
31     cp = git.CatPipe()
32     cat = cp.join
33
34 for id in extra:
35     try:
36         for blob in cat(id):
37             sys.stdout.write(blob)
38     except KeyError, e:
39         sys.stdout.flush()
40         log('error: %s\n' % e)
41         ret = 1
42
43 sys.exit(ret)