当前位置: 首页>>代码示例>>Python>>正文


Python utils.build_pack函数代码示例

本文整理汇总了Python中utils.build_pack函数的典型用法代码示例。如果您正苦于以下问题:Python build_pack函数的具体用法?Python build_pack怎么用?Python build_pack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了build_pack函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    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]
开发者ID:ChipJust,项目名称:dulwich,代码行数:32,代码来源:test_pack.py

示例2: test_read_objects_buffered

 def test_read_objects_buffered(self):
     f = StringIO()
     build_pack(f, [
       (Blob.type_num, 'blob'),
       (OFS_DELTA, (0, 'blob1')),
       ])
     reader = PackStreamReader(f.read, zlib_bufsize=4)
     self.assertEqual(2, len(list(reader.read_objects())))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例3: test_read_objects

    def test_read_objects(self):
        f = StringIO()
        entries = build_pack(f, [
          (Blob.type_num, 'blob'),
          (OFS_DELTA, (0, 'blob1')),
          ])
        reader = PackStreamReader(f.read)
        objects = list(reader.read_objects(compute_crc32=True))
        self.assertEqual(2, len(objects))

        unpacked_blob, unpacked_delta = objects

        self.assertEqual(entries[0][0], unpacked_blob.offset)
        self.assertEqual(Blob.type_num, unpacked_blob.pack_type_num)
        self.assertEqual(Blob.type_num, unpacked_blob.obj_type_num)
        self.assertEqual(None, unpacked_blob.delta_base)
        self.assertEqual('blob', ''.join(unpacked_blob.decomp_chunks))
        self.assertEqual(entries[0][4], unpacked_blob.crc32)

        self.assertEqual(entries[1][0], unpacked_delta.offset)
        self.assertEqual(OFS_DELTA, unpacked_delta.pack_type_num)
        self.assertEqual(None, unpacked_delta.obj_type_num)
        self.assertEqual(unpacked_delta.offset - unpacked_blob.offset,
                         unpacked_delta.delta_base)
        delta = create_delta('blob', 'blob1')
        self.assertEqual(delta, ''.join(unpacked_delta.decomp_chunks))
        self.assertEqual(entries[1][4], unpacked_delta.crc32)
开发者ID:yifanzhang,项目名称:dulwich,代码行数:27,代码来源:test_pack.py

示例4: test_ext_ref

 def test_ext_ref(self):
     blob, = self.store_blobs(['blob'])
     f = StringIO()
     entries = build_pack(f, [(REF_DELTA, (blob.id, 'blob1'))],
                          store=self.store)
     pack_iter = self.make_pack_iter(f)
     self.assertEntriesMatch([0], entries, pack_iter)
     self.assertEqual([hex_to_sha(blob.id)], pack_iter.ext_refs())
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例5: test_branchy_chain

 def test_branchy_chain(self):
     n = 100
     objects_spec = [(Blob.type_num, 'blob')]
     for i in xrange(n):
         objects_spec.append((OFS_DELTA, (0, 'blob%i' % i)))
     f = StringIO()
     entries = build_pack(f, objects_spec)
     self.assertEntriesMatch(xrange(n + 1), entries, self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例6: test_ref_deltas_chain

 def test_ref_deltas_chain(self):
     f = StringIO()
     entries = build_pack(f, [
       (REF_DELTA, (2, 'blob1')),
       (Blob.type_num, ('blob')),
       (REF_DELTA, (1, 'blob2')),
       ])
     self.assertEntriesMatch([1, 2, 0], entries, self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例7: test_ofs_deltas_chain

 def test_ofs_deltas_chain(self):
     f = StringIO()
     entries = build_pack(f, [
       (Blob.type_num, 'blob'),
       (OFS_DELTA, (0, 'blob1')),
       (OFS_DELTA, (1, 'blob2')),
       ])
     self.assertEntriesMatch([0, 1, 2], entries, self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例8: test_no_deltas

 def test_no_deltas(self):
     f = StringIO()
     entries = build_pack(f, [
       (Commit.type_num, 'commit'),
       (Blob.type_num, 'blob'),
       (Tree.type_num, 'tree'),
       ])
     self.assertEntriesMatch([0, 1, 2], entries, self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例9: test_ofs_and_ref_deltas

 def test_ofs_and_ref_deltas(self):
     # Deltas pending on this offset are popped before deltas depending on
     # this ref.
     f = StringIO()
     entries = build_pack(f, [
       (REF_DELTA, (1, 'blob1')),
       (Blob.type_num, ('blob')),
       (OFS_DELTA, (1, 'blob2')),
       ])
     self.assertEntriesMatch([1, 2, 0], entries, self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:10,代码来源:test_pack.py

示例10: test_bad_ext_ref_non_thin_pack

 def test_bad_ext_ref_non_thin_pack(self):
     blob, = self.store_blobs(['blob'])
     f = StringIO()
     entries = build_pack(f, [(REF_DELTA, (blob.id, 'blob1'))],
                          store=self.store)
     pack_iter = self.make_pack_iter(f, thin=False)
     try:
         list(pack_iter._walk_all_chains())
         self.fail()
     except KeyError, e:
         self.assertEqual(([blob.id],), e.args)
开发者ID:yifanzhang,项目名称:dulwich,代码行数:11,代码来源:test_pack.py

示例11: test_multiple_ext_refs

 def test_multiple_ext_refs(self):
     b1, b2 = self.store_blobs(['foo', 'bar'])
     f = StringIO()
     entries = build_pack(f, [
       (REF_DELTA, (b1.id, 'foo1')),
       (REF_DELTA, (b2.id, 'bar2')),
       ], store=self.store)
     pack_iter = self.make_pack_iter(f)
     self.assertEntriesMatch([0, 1], entries, pack_iter)
     self.assertEqual([hex_to_sha(b1.id), hex_to_sha(b2.id)],
                      pack_iter.ext_refs())
开发者ID:yifanzhang,项目名称:dulwich,代码行数:11,代码来源:test_pack.py

示例12: test_mixed_chain

 def test_mixed_chain(self):
     f = StringIO()
     entries = build_pack(f, [
       (Blob.type_num, 'blob'),
       (REF_DELTA, (2, 'blob2')),
       (OFS_DELTA, (0, 'blob1')),
       (OFS_DELTA, (1, 'blob3')),
       (OFS_DELTA, (0, 'bob')),
       ])
     self.assertEntriesMatch([0, 2, 1, 3, 4], entries,
                             self.make_pack_iter(f))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:11,代码来源:test_pack.py

示例13: test_bad_ext_ref_thin_pack

 def test_bad_ext_ref_thin_pack(self):
     b1, b2, b3 = self.store_blobs(['foo', 'bar', 'baz'])
     f = StringIO()
     entries = build_pack(f, [
       (REF_DELTA, (1, 'foo99')),
       (REF_DELTA, (b1.id, 'foo1')),
       (REF_DELTA, (b2.id, 'bar2')),
       (REF_DELTA, (b3.id, 'baz3')),
       ], store=self.store)
     del self.store[b2.id]
     del self.store[b3.id]
     pack_iter = self.make_pack_iter(f)
     try:
         list(pack_iter._walk_all_chains())
         self.fail()
     except KeyError, e:
         self.assertEqual((sorted([b2.id, b3.id]),), e.args)
开发者ID:yifanzhang,项目名称:dulwich,代码行数:17,代码来源:test_pack.py

示例14: test_read_objects_emtpy

 def test_read_objects_emtpy(self):
     f = StringIO()
     build_pack(f, [])
     reader = PackStreamReader(f.read)
     self.assertEqual(0, len(list(reader.read_objects())))
开发者ID:yifanzhang,项目名称:dulwich,代码行数:5,代码来源:test_pack.py


注:本文中的utils.build_pack函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。