285
282
if self.transport.has(".git/%s" % OBJECTDIR):
286
283
self.bare = False
287
284
self._controltransport = self.transport.clone('.git')
288
elif self.transport.has_any(["info/refs", OBJECTDIR, REFSDIR]):
285
elif self.transport.has(OBJECTDIR) or self.transport.has(REFSDIR):
290
287
self._controltransport = self.transport
344
341
super(TransportObjectStore, self).__init__()
345
342
self.transport = transport
346
343
self.pack_transport = self.transport.clone(PACKDIR)
349
return "%s(%r)" % (self.__class__.__name__, self.transport)
351
345
def _pack_cache_stale(self):
352
346
return False # FIXME
449
443
self._add_known_pack(final_pack)
450
444
return final_pack
452
def add_thin_pack(self):
453
"""Add a new thin pack to this object store.
455
Thin packs are packs that contain deltas with parents that exist
458
from cStringIO import StringIO
461
if len(f.getvalue()) > 0:
462
return self.move_in_thin_pack(f)
467
def move_in_thin_pack(self, f):
468
"""Move a specific file containing a pack into the pack directory.
470
:note: The file should be on the same file system as the
473
:param path: Path to the pack file.
476
data = ThinPackData.from_file(self.get_raw, f, len(f.getvalue()))
477
idx = MemoryPackIndex(data.sorted_entries(), data.get_stored_checksum())
478
p = Pack.from_objects(data, idx)
480
pack_sha = idx.objects_sha1()
482
datafile = self.pack_transport.open_write_stream("pack-%s.pack" % pack_sha)
484
entries, data_sum = write_pack_data(datafile, ((o, None) for o in p.iterobjects()), len(p))
488
idxfile = self.pack_transport.open_write_stream("pack-%s.idx" % pack_sha)
490
write_pack_index_v2(idxfile, data.sorted_entries(), data_sum)
493
final_pack = Pack("pack-%s" % pack_sha)
494
self._add_known_pack(final_pack)
499
446
def add_pack(self):
500
447
"""Add a new pack to this object store.