Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master, master-1, and master-0

Merge upstream

Changeset 17f51f416b19

Parents 8acce018fc41

Parents cc8a271a821a

by John Carr

Changes to 4 files · Browse files at 17f51f416b19 Showing diff from parent 8acce018fc41 cc8a271a821a Diff from another changeset...

Change 1 of 1 Show Entire File bin/​dulwich Stacked
 
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
102
103
 
104
 
105
106
107
 
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
@@ -98,10 +98,73 @@
  except ApplyDeltaError, e:   print "\t%s: Unable to apply delta: %r" % (name, e)   +def cmd_init(args): + from dulwich.repo import Repo + import os + import sys + opts, args = getopt(args, "", ["--bare"]) + opts = dict(opts) + + if args == []: + path = os.getcwd() + else: + path = args[0] + + if not os.path.exists(path): + os.mkdir(path) + + if "--bare" in opts: + Repo.init_bare(path) + else: + Repo.init(path) + + +def cmd_clone(args): + from dulwich.client import TCPGitClient, SimpleFetchGraphWalker + from dulwich.repo import Repo + import os + import sys + opts, args = getopt(args, "", []) + opts = dict(opts) + + if args == []: + print "usage: dulwich clone host:path [PATH]" + sys.exit(1) + + if not ":" in args[0]: + print "Usage: dulwich clone host:path [PATH]" + sys.exit(1) + (host, host_path) = args.pop(0).split(":", 1) + client = TCPGitClient(host) + + if len(args) > 0: + path = args.pop(0) + else: + path = host_path.split("/")[-1] + + if not os.path.exists(path): + os.mkdir(path) + Repo.init(path) + r = Repo(path) + determine_wants = lambda x: [y for y in x.values() if not y in r.object_store] + graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents) + f, commit = r.object_store.add_pack() + try: + client.fetch_pack(host_path, determine_wants, graphwalker, f.write, + sys.stdout.write) + f.close() + commit() + except: + f.close() + raise + +  commands = {   "fetch-pack": cmd_fetch_pack,   "dump-pack": cmd_dump_pack, + "init": cmd_init,   "log": cmd_log, + "clone": cmd_clone,   }    if len(sys.argv) < 2:
 
26
27
28
 
29
30
31
 
112
113
114
 
 
 
 
 
 
 
 
26
27
28
29
30
31
32
 
113
114
115
116
117
118
119
120
121
122
@@ -26,6 +26,7 @@
  write_pack_index_v2,   PackData,   ) +import tempfile  PACKDIR = 'pack'    class ObjectStore(object): @@ -112,3 +113,10 @@
  if os.path.getsize(path) > 0:   self.move_in_pack(path)   return f, commit + + def add_objects(self, objects): + if len(objects) == 0: + return + f, commit = self.add_pack() + write_pack_data(f, objects, len(objects)) + commit()
Change 1 of 1 Show Entire File dulwich/​repo.py Stacked
 
268
269
270
 
 
 
 
 
 
271
272
273
 
268
269
270
271
272
273
274
275
276
277
278
279
@@ -268,6 +268,12 @@
  return "<Repo at %r>" % self.path     @classmethod + def init(cls, path, mkdir=True): + controldir = os.path.join(path, ".git") + os.mkdir(controldir) + cls.init_bare(controldir) + + @classmethod   def init_bare(cls, path, mkdir=True):   for d in [["objects"],   ["objects", "info"],
 
29
30
31
 
 
 
32
33
 
 
 
 
 
 
29
30
31
32
33
34
35
 
36
37
38
39
40
@@ -29,5 +29,12 @@
  o = ObjectStore("foo")   self.assertEquals([], o.packs)   + def test_add_objects_empty(self): + o = ObjectStore("foo") + o.add_objects([])   - + def test_add_commit(self): + o = ObjectStore("foo") + # TODO: Argh, no way to construct Git commit objects without + # access to a serialized form. + o.add_objects([])