/usr/bin/dulwich is in python-dulwich 0.9.4-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | #! /usr/bin/python -u
#
# dulwich - Simple command-line interface to Dulwich
# Copyright (C) 2008-2011 Jelmer Vernooij <jelmer@samba.org>
# vim: expandtab
#
# 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.
"""Simple command-line interface to Dulwich>
This is a very simple command-line wrapper for Dulwich. It is by
no means intended to be a full-blown Git command-line interface but just
a way to test Dulwich.
"""
import os
import sys
from getopt import getopt
from dulwich import porcelain
from dulwich.client import get_transport_and_path
from dulwich.errors import ApplyDeltaError
from dulwich.index import Index
from dulwich.pack import Pack, sha_to_hex
from dulwich.patch import write_tree_diff
from dulwich.repo import Repo
def cmd_archive(args):
opts, args = getopt(args, "", [])
client, path = get_transport_and_path(args.pop(0))
location = args.pop(0)
committish = args.pop(0)
porcelain.archive(location, committish, outstream=sys.stdout,
errstream=sys.stderr)
def cmd_add(args):
opts, args = getopt(args, "", [])
porcelain.add(".", paths=args)
def cmd_rm(args):
opts, args = getopt(args, "", [])
porcelain.rm(".", paths=args)
def cmd_fetch_pack(args):
opts, args = getopt(args, "", ["all"])
opts = dict(opts)
client, path = get_transport_and_path(args.pop(0))
r = Repo(".")
if "--all" in opts:
determine_wants = r.object_store.determine_wants_all
else:
determine_wants = lambda x: [y for y in args if not y in r.object_store]
client.fetch(path, r, determine_wants)
def cmd_fetch(args):
opts, args = getopt(args, "", [])
opts = dict(opts)
client, path = get_transport_and_path(args.pop(0))
r = Repo(".")
if "--all" in opts:
determine_wants = r.object_store.determine_wants_all
refs = client.fetch(path, r, progress=sys.stdout.write)
print "Remote refs:"
for item in refs.iteritems():
print "%s -> %s" % item
def cmd_log(args):
opts, args = getopt(args, "", [])
if len(args) > 0:
path = args.pop(0)
else:
path = "."
porcelain.log(repo=path, outstream=sys.stdout)
def cmd_diff(args):
opts, args = getopt(args, "", [])
if args == []:
print "Usage: dulwich diff COMMITID"
sys.exit(1)
r = Repo(".")
commit_id = args[0]
commit = r[commit_id]
parent_commit = r[commit.parents[0]]
write_tree_diff(sys.stdout, r.object_store, parent_commit.tree, commit.tree)
def cmd_dump_pack(args):
opts, args = getopt(args, "", [])
if args == []:
print "Usage: dulwich dump-pack FILENAME"
sys.exit(1)
basename, _ = os.path.splitext(args[0])
x = Pack(basename)
print "Object names checksum: %s" % x.name()
print "Checksum: %s" % sha_to_hex(x.get_stored_checksum())
if not x.check():
print "CHECKSUM DOES NOT MATCH"
print "Length: %d" % len(x)
for name in x:
try:
print "\t%s" % x[name]
except KeyError, k:
print "\t%s: Unable to resolve base %s" % (name, k)
except ApplyDeltaError, e:
print "\t%s: Unable to apply delta: %r" % (name, e)
def cmd_dump_index(args):
opts, args = getopt(args, "", [])
if args == []:
print "Usage: dulwich dump-index FILENAME"
sys.exit(1)
filename = args[0]
idx = Index(filename)
for o in idx:
print o, idx[o]
def cmd_init(args):
opts, args = getopt(args, "", ["bare"])
opts = dict(opts)
if args == []:
path = os.getcwd()
else:
path = args[0]
porcelain.init(path, bare=("--bare" in opts))
def cmd_clone(args):
opts, args = getopt(args, "", ["bare"])
opts = dict(opts)
if args == []:
print "usage: dulwich clone host:path [PATH]"
sys.exit(1)
source = args.pop(0)
if len(args) > 0:
target = args.pop(0)
else:
target = None
porcelain.clone(source, target, bare=("--bare" in opts))
def cmd_commit(args):
opts, args = getopt(args, "", ["message"])
opts = dict(opts)
porcelain.commit(".", message=opts["--message"])
def cmd_commit_tree(args):
opts, args = getopt(args, "", ["message"])
if args == []:
print "usage: dulwich commit-tree tree"
sys.exit(1)
opts = dict(opts)
porcelain.commit_tree(".", tree=args[0], message=opts["--message"])
def cmd_update_server_info(args):
porcelain.update_server_info(".")
def cmd_symbolic_ref(args):
opts, args = getopt(args, "", ["ref-name", "force"])
if not args:
print "Usage: dulwich symbolic-ref REF_NAME [--force]"
sys.exit(1)
ref_name = args.pop(0)
porcelain.symbolic_ref(".", ref_name=ref_name, force='--force' in args)
def cmd_show(args):
opts, args = getopt(args, "", [])
porcelain.show(".")
def cmd_diff_tree(args):
opts, args = getopt(args, "", [])
if len(args) < 2:
print "Usage: dulwich diff-tree OLD-TREE NEW-TREE"
sys.exit(1)
porcelain.diff_tree(".", args[0], args[1])
def cmd_rev_list(args):
opts, args = getopt(args, "", [])
porcelain.rev_list(".", args)
commands = {
"commit": cmd_commit,
"commit-tree": cmd_commit_tree,
"diff-tree": cmd_diff_tree,
"fetch-pack": cmd_fetch_pack,
"fetch": cmd_fetch,
"dump-pack": cmd_dump_pack,
"dump-index": cmd_dump_index,
"init": cmd_init,
"log": cmd_log,
"clone": cmd_clone,
"archive": cmd_archive,
"update-server-info": cmd_update_server_info,
"symbolic-ref": cmd_symbolic_ref,
"diff": cmd_diff,
"add": cmd_add,
"rm": cmd_rm,
"show": cmd_show,
"rev-list": cmd_rev_list,
}
if len(sys.argv) < 2:
print "Usage: %s <%s> [OPTIONS...]" % (sys.argv[0], "|".join(commands.keys()))
sys.exit(1)
cmd = sys.argv[1]
if not cmd in commands:
print "No such subcommand: %s" % cmd
sys.exit(1)
commands[cmd](sys.argv[2:])
|