本文整理汇总了Python中utils.make_object函数的典型用法代码示例。如果您正苦于以下问题:Python make_object函数的具体用法?Python make_object怎么用?Python make_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_info_refs
def test_get_info_refs(self):
self._environ['QUERY_STRING'] = ''
blob1 = make_object(Blob, data='1')
blob2 = make_object(Blob, data='2')
blob3 = make_object(Blob, data='3')
tag1 = make_object(Tag, name='tag-tag',
tagger='Test <[email protected]>',
tag_time=12345,
tag_timezone=0,
message='message',
object=(Blob, blob2.id))
objects = [blob1, blob2, blob3, tag1]
refs = {
'HEAD': '000',
'refs/heads/master': blob1.id,
'refs/tags/tag-tag': tag1.id,
'refs/tags/blob-tag': blob3.id,
}
backend = _test_backend(objects, refs=refs)
mat = re.search('.*', '//info/refs')
self.assertEquals(['%s\trefs/heads/master\n' % blob1.id,
'%s\trefs/tags/blob-tag\n' % blob3.id,
'%s\trefs/tags/tag-tag\n' % tag1.id,
'%s\trefs/tags/tag-tag^{}\n' % blob2.id],
list(get_info_refs(self._req, backend, mat)))
self.assertEquals(HTTP_OK, self._status)
self.assertContentTypeEquals('text/plain')
self.assertFalse(self._req.cached)
示例2: test_iter_tree_contents_include_trees
def test_iter_tree_contents_include_trees(self):
blob_a = make_object(Blob, data='a')
blob_b = make_object(Blob, data='b')
blob_c = make_object(Blob, data='c')
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
('a', blob_a.id, 0100644),
('ad/b', blob_b.id, 0100644),
('ad/bd/c', blob_c.id, 0100755),
]
tree_id = commit_tree(self.store, blobs)
tree = self.store[tree_id]
tree_ad = self.store[tree['ad'][1]]
tree_bd = self.store[tree_ad['bd'][1]]
expected = [
('', 0040000, tree_id),
('a', 0100644, blob_a.id),
('ad', 0040000, tree_ad.id),
('ad/b', 0100644, blob_b.id),
('ad/bd', 0040000, tree_bd.id),
('ad/bd/c', 0100755, blob_c.id),
]
actual = self.store.iter_tree_contents(tree_id, include_trees=True)
self.assertEquals(expected, list(actual))
示例3: test_trees
def test_trees(self):
a1 = make_object(Blob, data='aaa1')
a2 = make_object(Blob, data='aaa2')
c1, c2 = build_commit_graph(self.store, [[1], [2, 1]],
trees={1: [('a', a1)],
2: [('a', a2, 0100644)]})
self.assertEqual((0100644, a1.id), self.store[c1.tree]['a'])
self.assertEqual((0100644, a2.id), self.store[c2.tree]['a'])
示例4: test_paths_max_entries
def test_paths_max_entries(self):
blob_a = make_object(Blob, data='a')
blob_b = make_object(Blob, data='b')
c1, c2 = self.make_linear_commits(
2, trees={1: [('a', blob_a)],
2: [('a', blob_a), ('b', blob_b)]})
self.assertWalkYields([c2], [c2.id], paths=['b'], max_entries=1)
self.assertWalkYields([c1], [c1.id], paths=['a'], max_entries=1)
示例5: test_paths_subtree
def test_paths_subtree(self):
blob_a = make_object(Blob, data='a')
blob_b = make_object(Blob, data='b')
c1, c2, c3 = self.make_linear_commits(
3, trees={1: [('x/a', blob_a)],
2: [('b', blob_b), ('x/a', blob_a)],
3: [('b', blob_b), ('x/a', blob_a), ('x/b', blob_b)]})
self.assertWalkYields([c2], [c3.id], paths=['b'])
self.assertWalkYields([c3, c1], [c3.id], paths=['x'])
示例6: test_pack_loose_objects
def test_pack_loose_objects(self):
b1 = make_object(Blob, data="yummy data")
self.store.add_object(b1)
b2 = make_object(Blob, data="more yummy data")
self.store.add_object(b2)
self.assertEquals([], self.store.packs)
self.assertEquals(2, self.store.pack_loose_objects())
self.assertNotEquals([], self.store.packs)
self.assertEquals(0, self.store.pack_loose_objects())
示例7: test_paths_merge
def test_paths_merge(self):
blob_a1 = make_object(Blob, data="a1")
blob_a2 = make_object(Blob, data="a2")
blob_a3 = make_object(Blob, data="a3")
x1, y2, m3, m4 = self.make_commits(
[[1], [2], [3, 1, 2], [4, 1, 2]],
trees={1: [("a", blob_a1)], 2: [("a", blob_a2)], 3: [("a", blob_a3)], 4: [("a", blob_a1)]},
) # Non-conflicting
self.assertWalkYields([m3, y2, x1], [m3.id], paths=["a"])
self.assertWalkYields([y2, x1], [m4.id], paths=["a"])
示例8: test_changes_one_parent
def test_changes_one_parent(self):
blob_a1 = make_object(Blob, data='a1')
blob_a2 = make_object(Blob, data='a2')
blob_b2 = make_object(Blob, data='b2')
c1, c2 = self.make_linear_commits(
2, trees={1: [('a', blob_a1)],
2: [('a', blob_a2), ('b', blob_b2)]})
e1 = TestWalkEntry(c1, [TreeChange.add(('a', F, blob_a1.id))])
e2 = TestWalkEntry(c2, [TreeChange(CHANGE_MODIFY, ('a', F, blob_a1.id),
('a', F, blob_a2.id)),
TreeChange.add(('b', F, blob_b2.id))])
self.assertWalkYields([e2, e1], [c2.id])
示例9: test_paths_merge
def test_paths_merge(self):
blob_a1 = make_object(Blob, data='a1')
blob_a2 = make_object(Blob, data='a2')
blob_a3 = make_object(Blob, data='a3')
x1, y2, m3, m4 = self.make_commits(
[[1], [2], [3, 1, 2], [4, 1, 2]],
trees={1: [('a', blob_a1)],
2: [('a', blob_a2)],
3: [('a', blob_a3)],
4: [('a', blob_a1)]}) # Non-conflicting
self.assertWalkYields([m3, y2, x1], [m3.id], paths=['a'])
self.assertWalkYields([y2, x1], [m4.id], paths=['a'])
示例10: test_paths_subtree
def test_paths_subtree(self):
blob_a = make_object(Blob, data="a")
blob_b = make_object(Blob, data="b")
c1, c2, c3 = self.make_linear_commits(
3,
trees={
1: [("x/a", blob_a)],
2: [("b", blob_b), ("x/a", blob_a)],
3: [("b", blob_b), ("x/a", blob_a), ("x/b", blob_b)],
},
)
self.assertWalkYields([c2], [c3.id], paths=["b"])
self.assertWalkYields([c3, c1], [c3.id], paths=["x"])
示例11: setUp
def setUp(self):
super(MOFMergeForkRepoTest, self).setUp()
f1_1 = make_object(Blob, data='f1')
f1_2 = make_object(Blob, data='f1-2')
f1_4 = make_object(Blob, data='f1-4')
f1_7 = make_object(Blob, data='f1-2') # same data as in rev 2
f2_1 = make_object(Blob, data='f2')
f2_3 = make_object(Blob, data='f2-3')
f3_3 = make_object(Blob, data='f3')
f3_5 = make_object(Blob, data='f3-5')
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {1: [('f1', f1_1), ('f2', f2_1)],
2: [('f1', f1_2), ('f2', f2_1)], # f1 changed
# f3 added, f2 changed
3: [('f1', f1_2), ('f2', f2_3), ('f3', f3_3)],
4: [('f1', f1_4), ('f2', f2_1)], # f1 changed
5: [('f1', f1_2), ('f3', f3_5)], # f2 removed, f3 changed
6: [('f1', f1_4), ('f2', f2_3), ('f3', f3_3)], # merged 3 and 4
# f1 changed to match rev2. f3 removed
7: [('f1', f1_7), ('f2', f2_3)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
self.f1_2_id = f1_2.id
self.f1_4_id = f1_4.id
self.f1_7_id = f1_7.id
self.f2_3_id = f2_3.id
self.f3_3_id = f3_3.id
self.assertEquals(f1_2.id, f1_7.id, "[sanity]")
示例12: test_changes_multiple_parents
def test_changes_multiple_parents(self):
blob_a1 = make_object(Blob, data='a1')
blob_b2 = make_object(Blob, data='b2')
blob_a3 = make_object(Blob, data='a3')
c1, c2, c3 = self.make_commits(
[[1], [2], [3, 1, 2]],
trees={1: [('a', blob_a1)], 2: [('b', blob_b2)],
3: [('a', blob_a3), ('b', blob_b2)]})
# a is a modify/add conflict and b is not conflicted.
changes = [[
TreeChange(CHANGE_MODIFY, ('a', F, blob_a1.id), ('a', F, blob_a3.id)),
TreeChange.add(('a', F, blob_a3.id)),
]]
self.assertWalkYields([TestWalkEntry(c3, changes)], [c3.id],
exclude=[c1.id, c2.id])
示例13: 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]
示例14: test_serialize_mergetag
def test_serialize_mergetag(self):
tag = make_object(
Tag, object=(Commit, "a38d6181ff27824c79fc7df825164a212eff6a3f"),
object_type_name="commit",
name="v2.6.22-rc7",
tag_time=1183319674,
tag_timezone=0,
tagger="Linus Torvalds <[email protected]>",
message=default_message)
commit = self.make_commit(mergetag=[tag])
self.assertEqual("""tree d80c186a03f423a81b39df39dc87fd269736ca86
parent ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd
parent 4cffe90e0a41ad3f5190079d7c8f036bde29cbe6
author James Westby <[email protected]> 1174773719 +0000
committer James Westby <[email protected]> 1174773719 +0000
mergetag object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7
tagger Linus Torvalds <[email protected]> 1183319674 +0000
Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
Merge ../b
""", commit.as_raw_string())
示例15: make_tag
def make_tag(self, name, obj):
tag = make_object(Tag, name=name, message='',
tag_time=12345, tag_timezone=0,
tagger='Test Tagger <[email protected]>',
object=(object_class(obj.type_name), obj.id))
self.store.add_object(tag)
return tag