X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fjoin-cmd.py;h=68c31eedcb7e24f7d54927d40017f5dedfc20c77;hb=c40b3dd5fd74e72024fbaad3daf5a958aefa1c54;hp=042b4023de5af8ad4cd8425e96292d7346d6fc36;hpb=cf86321f17487240e1ffaf3a54b7302ba277b1ec;p=bup.git diff --git a/cmd/join-cmd.py b/cmd/join-cmd.py index 042b402..68c31ee 100755 --- a/cmd/join-cmd.py +++ b/cmd/join-cmd.py @@ -1,7 +1,16 @@ -#!/usr/bin/env python +#!/bin/sh +"""": # -*-python-*- +bup_python="$(dirname "$0")/bup-python" || exit $? +exec "$bup_python" "$0" ${1+"$@"} +""" +# end of bup preamble + +from __future__ import absolute_import import sys -from bup import git, options, client -from bup.helpers import * + +from bup import git, options +from bup.helpers import linereader, log +from bup.repo import LocalRepo, RemoteRepo optspec = """ @@ -19,24 +28,18 @@ if not extra: extra = linereader(sys.stdin) ret = 0 - -if opt.remote: - cli = client.Client(opt.remote) - cat = cli.cat -else: - cp = git.CatPipe() - cat = cp.join +repo = RemoteRepo(opt.remote) if opt.remote else LocalRepo() if opt.o: outfile = open(opt.o, 'wb') else: outfile = sys.stdout -for id in extra: +for ref in extra: try: - for blob in cat(id): + for blob in repo.join(ref): outfile.write(blob) - except KeyError, e: + except KeyError as e: outfile.flush() log('error: %s\n' % e) ret = 1