123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/usr/bin/python
- # dul-daemon - Simple git smart server client
- # Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; version 2
- # or (at your option) a later version of the License.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- from dulwich.client import TCPGitClient, SimpleFetchGraphWalker
- from dulwich.repo import Repo
- import sys
- from getopt import getopt
- opts, args = getopt(sys.argv[1:], "", ["all"])
- opts = dict(opts)
- if args == []:
- print "Usage: dul-fetch-pack host:path"
- sys.exit(1)
- if not ":" in args[0]:
- print "Usage: dul-fetch-pack host:path"
- sys.exit(1)
- (host, path) = args.pop(0).split(":", 1)
- client = TCPGitClient(host)
- if "--all" in opts:
- determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
- else:
- determine_wants = lambda x: [y for y in args if not y in r.object_store]
- r = Repo(".")
- # FIXME: Will just fetch everything..
- graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)
- f, commit = r.object_store.add_pack()
- try:
- client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
- f.close()
- commit()
- except:
- f.close()
- raise
|