/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bin/dulwich

  • Committer: Jelmer Vernooij
  • Date: 2009-01-14 18:24:38 UTC
  • mto: (0.222.3 dulwich)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090114182438-c0tn5eczyupi4ztn
Fix download url, add version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
                except ApplyDeltaError, e:
99
99
                        print "\t%s: Unable to apply delta: %r" % (name, e)
100
100
 
 
101
 
 
102
def cmd_dump_index(args):
 
103
        from dulwich.index import Index
 
104
 
 
105
        opts, args = getopt(args, "", [])
 
106
 
 
107
        if args == []:
 
108
                print "Usage: dulwich dump-pack FILENAME"
 
109
                sys.exit(1)
 
110
 
 
111
        filename = args[0]
 
112
        idx = Index(filename)
 
113
 
 
114
        for o in idx:
 
115
                print o[0]
 
116
 
 
117
 
 
118
def cmd_init(args):
 
119
        from dulwich.repo import Repo
 
120
        import os
 
121
        import sys
 
122
        opts, args = getopt(args, "", ["--bare"])
 
123
        opts = dict(opts)
 
124
 
 
125
        if args == []:
 
126
                path = os.getcwd()
 
127
        else:
 
128
                path = args[0]
 
129
 
 
130
        if not os.path.exists(path):
 
131
                os.mkdir(path)
 
132
 
 
133
        if "--bare" in opts:
 
134
                Repo.init_bare(path)
 
135
        else:
 
136
                Repo.init(path)
 
137
 
 
138
 
 
139
def cmd_clone(args):
 
140
        from dulwich.client import TCPGitClient, SimpleFetchGraphWalker
 
141
        from dulwich.repo import Repo
 
142
        import os
 
143
        import sys
 
144
        opts, args = getopt(args, "", [])
 
145
        opts = dict(opts)
 
146
 
 
147
        if args == []:
 
148
                print "usage: dulwich clone host:path [PATH]"
 
149
                sys.exit(1)
 
150
 
 
151
        if not ":" in args[0]:
 
152
                print "Usage: dulwich clone host:path [PATH]"
 
153
                sys.exit(1)
 
154
        (host, host_path) = args.pop(0).split(":", 1)
 
155
        client = TCPGitClient(host)
 
156
 
 
157
        if len(args) > 0:
 
158
                path = args.pop(0)
 
159
        else:
 
160
                path = host_path.split("/")[-1]
 
161
 
 
162
        if not os.path.exists(path):
 
163
                os.mkdir(path)
 
164
        Repo.init(path)
 
165
        r = Repo(path)
 
166
        determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
 
167
        graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)
 
168
        f, commit = r.object_store.add_pack()
 
169
        try:
 
170
                client.fetch_pack(host_path, determine_wants, graphwalker, f.write, 
 
171
                                          sys.stdout.write)
 
172
                f.close()
 
173
                commit()
 
174
        except:
 
175
                f.close()
 
176
                raise
 
177
 
 
178
 
101
179
commands = {
102
180
        "fetch-pack": cmd_fetch_pack,
103
181
        "dump-pack": cmd_dump_pack,
 
182
        "dump-index": cmd_dump_index,
 
183
        "init": cmd_init,
104
184
        "log": cmd_log,
 
185
        "clone": cmd_clone,
105
186
        }
106
187
 
107
188
if len(sys.argv) < 2: