本文整理汇总了Python中dulwich.pack.PackData.pack方法的典型用法代码示例。如果您正苦于以下问题:Python PackData.pack方法的具体用法?Python PackData.pack怎么用?Python PackData.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.pack.PackData
的用法示例。
在下文中一共展示了PackData.pack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import pack [as 别名]
def setUp(self):
super(TestThinPack, self).setUp()
self.store = MemoryObjectStore()
self.blobs = {}
for blob in ('foo', 'bar', 'foo1234', 'bar2468'):
self.blobs[blob] = make_object(Blob, data=blob)
self.store.add_object(self.blobs['foo'])
self.store.add_object(self.blobs['bar'])
# Build a thin pack. 'foo' is as an external reference, 'bar' an
# internal reference.
self.pack_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.pack_dir)
self.pack_prefix = os.path.join(self.pack_dir, 'pack')
f = open(self.pack_prefix + '.pack', 'wb')
try:
build_pack(f, [
(REF_DELTA, (self.blobs['foo'].id, 'foo1234')),
(Blob.type_num, 'bar'),
(REF_DELTA, (self.blobs['bar'].id, 'bar2468'))],
store=self.store)
finally:
f.close()
# Index the new pack.
pack = self.make_pack(True)
data = PackData(pack._data_path)
data.pack = pack
data.create_index(self.pack_prefix + '.idx')
del self.store[self.blobs['bar'].id]