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

Support packed refs.

Changeset 2643a6b8935e

Parent f0e86324e0f4

by Jelmer Vernooij

Changes to one file · Browse files at 2643a6b8935e Showing diff from parent f0e86324e0f4 Diff from another changeset...

Change 1 of 3 Show Entire File dulwich/​repo.py Stacked
 
66
67
68
 
 
 
 
 
 
 
 
 
 
69
70
71
 
192
193
194
 
 
 
195
196
197
 
202
203
204
 
205
 
 
 
 
 
 
 
 
 
 
 
 
 
206
207
208
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
202
203
204
205
206
207
208
209
210
 
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@@ -66,6 +66,16 @@
  yield k, self[k]     +def read_packed_refs(f): + l = f.readline() + assert l == "# pack-refs with: peeled \n" + for l in f.readlines(): + if l[0] == "^": + # FIXME: Return somehow + continue + yield tuple(l.rstrip("\n").split(" ", 2)) + +  class MissingObjectFinder(object):     def __init__(self, object_store, wants, graph_walker, progress=None): @@ -192,6 +202,9 @@
  file = os.path.join(self.controldir(), dir, name)   if os.path.exists(file):   return self._get_ref(file) + packed_refs = self.get_packed_refs() + if name in packed_refs: + return packed_refs[name]     def get_refs(self):   ret = {} @@ -202,7 +215,21 @@
  path = os.path.join(self.controldir(), dir, name)   if os.path.isfile(path):   ret["/".join([dir, name])] = self._get_ref(path) + ret.update(self.get_packed_refs())   return ret + + def get_packed_refs(self): + path = os.path.join(self.controldir(), 'packed-refs') + if not os.path.exists(path): + return {} + ret = {} + f = open(path, 'r') + try: + for entry in read_packed_refs(f): + ret[entry[1]] = entry[0] + return ret + finally: + f.close()     def set_ref(self, name, value):   file = os.path.join(self.controldir(), name)