示例#1
0
    def setUp(self):
        super(MOFLinearRepoTest, self).setUp()
        f1_1 = make_object(Blob, data='f1')  # present in 1, removed in 3
        f2_1 = make_object(
            Blob, data='f2')  # present in all revisions, changed in 2 and 3
        f2_2 = make_object(Blob, data='f2-changed')
        f2_3 = make_object(Blob, data='f2-changed-again')
        f3_2 = make_object(Blob, data='f3')  # added in 2, left unmodified in 3

        commit_spec = [[1], [2, 1], [3, 2]]
        trees = {
            1: [('f1', f1_1), ('f2', f2_1)],
            2: [('f1', f1_1), ('f2', f2_2), ('f3', f3_2)],
            3: [('f2', f2_3), ('f3', f3_2)]
        }
        # commit 1: f1 and f2
        # commit 2: f3 added, f2 changed. Missing shall report commit id and a
        # tree referenced by commit
        # commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
        # be reported as modified
        self.commits = build_commit_graph(self.store, commit_spec, trees)
        self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
        self.missing_2_3 = [self.cmt(3).id, self.cmt(3).tree, f2_3.id]
        self.missing_1_3 = [
            self.cmt(2).id,
            self.cmt(3).id,
            self.cmt(2).tree,
            self.cmt(3).tree, f2_2.id, f3_2.id, f2_3.id
        ]
示例#2
0
    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
0
    def test_paths(self):
        blob_a1 = make_object(Blob, data='a1')
        blob_b2 = make_object(Blob, data='b2')
        blob_a3 = make_object(Blob, data='a3')
        blob_b3 = make_object(Blob, data='b3')
        c1, c2, c3 = self.make_linear_commits(3,
                                              trees={
                                                  1: [('a', blob_a1)],
                                                  2: [('a', blob_a1),
                                                      ('x/b', blob_b2)],
                                                  3: [('a', blob_a3),
                                                      ('x/b', blob_b3)]
                                              })

        self.assertWalkYields([c3, c2, c1], [c3.id])
        self.assertWalkYields([c3, c1], [c3.id], paths=['a'])
        self.assertWalkYields([c3, c2], [c3.id], paths=['x/b'])

        # All changes are included, not just for requested paths.
        changes = [
            TreeChange(CHANGE_MODIFY, ('a', F, blob_a1.id),
                       ('a', F, blob_a3.id)),
            TreeChange(CHANGE_MODIFY, ('x/b', F, blob_b2.id),
                       ('x/b', F, blob_b3.id)),
        ]
        self.assertWalkYields([TestWalkEntry(c3, changes)], [c3.id],
                              max_entries=1,
                              paths=['a'])
示例#4
0
    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 <*****@*****.**>',
                           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)
示例#5
0
 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'])
示例#6
0
 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)
示例#7
0
 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'])
示例#8
0
 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)
示例#9
0
 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'])
示例#10
0
 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())
示例#11
0
 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'])
示例#12
0
 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"])
示例#13
0
 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'])
示例#14
0
 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])
示例#15
0
 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])
示例#16
0
 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'])
示例#17
0
 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"])
示例#18
0
    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]")
示例#19
0
    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]")
示例#20
0
 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])
示例#21
0
 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])
示例#22
0
    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 <*****@*****.**>",
            message=default_message)
        commit = self.make_commit(mergetag=[tag])

        self.assertEqual("""tree d80c186a03f423a81b39df39dc87fd269736ca86
parent ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd
parent 4cffe90e0a41ad3f5190079d7c8f036bde29cbe6
author James Westby <*****@*****.**> 1174773719 +0000
committer James Westby <*****@*****.**> 1174773719 +0000
mergetag object a38d6181ff27824c79fc7df825164a212eff6a3f
 type commit
 tag v2.6.22-rc7
 tagger Linus Torvalds <*****@*****.**> 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())
示例#23
0
 def store_blobs(self, blobs_data):
     blobs = []
     for data in blobs_data:
         blob = make_object(Blob, data=data)
         blobs.append(blob)
         self.store.add_object(blob)
     return blobs
示例#24
0
 def make_tag(self, name, obj):
     tag = make_object(Tag, name=name, message='',
                       tag_time=12345, tag_timezone=0,
                       tagger='Test Tagger <*****@*****.**>',
                       object=(object_class(obj.type_name), obj.id))
     self.store.add_object(tag)
     return tag
示例#25
0
 def store_blobs(self, blobs_data):
     blobs = []
     for data in blobs_data:
         blob = make_object(Blob, data=data)
         blobs.append(blob)
         self.store.add_object(blob)
     return blobs
示例#26
0
文件: test_pack.py 项目: zbal/dulwich
    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]
示例#27
0
    def setUp(self):
        TestCase.setUp(self)
        self.store = MemoryObjectStore()
        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),
          ('ad/c', blob_c.id, 0100644),
          ('c', blob_c.id, 0100644),
          ]
        self.tree_id = commit_tree(self.store, blobs)
示例#28
0
    def test_iter_tree_contents(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),
          ('ad/c', blob_c.id, 0100644),
          ('c', blob_c.id, 0100644),
          ]
        tree_id = commit_tree(self.store, blobs)
        self.assertEquals([(p, m, h) for (p, h, m) in blobs],
                          list(self.store.iter_tree_contents(tree_id)))
示例#29
0
 def test_get_loose_object(self):
     blob = make_object(Blob, data='foo')
     backend = _test_backend([blob])
     mat = re.search('^(..)(.{38})$', blob.id)
     output = ''.join(get_loose_object(self._req, backend, mat))
     self.assertEquals(blob.as_legacy_object(), output)
     self.assertEquals(HTTP_OK, self._status)
     self.assertContentTypeEquals('application/x-git-loose-object')
     self.assertTrue(self._req.cached)
示例#30
0
    def test_paths(self):
        blob_a1 = make_object(Blob, data="a1")
        blob_b2 = make_object(Blob, data="b2")
        blob_a3 = make_object(Blob, data="a3")
        blob_b3 = make_object(Blob, data="b3")
        c1, c2, c3 = self.make_linear_commits(
            3, trees={1: [("a", blob_a1)], 2: [("a", blob_a1), ("x/b", blob_b2)], 3: [("a", blob_a3), ("x/b", blob_b3)]}
        )

        self.assertWalkYields([c3, c2, c1], [c3.id])
        self.assertWalkYields([c3, c1], [c3.id], paths=["a"])
        self.assertWalkYields([c3, c2], [c3.id], paths=["x/b"])

        # All changes are included, not just for requested paths.
        changes = [
            TreeChange(CHANGE_MODIFY, ("a", F, blob_a1.id), ("a", F, blob_a3.id)),
            TreeChange(CHANGE_MODIFY, ("x/b", F, blob_b2.id), ("x/b", F, blob_b3.id)),
        ]
        self.assertWalkYields([TestWalkEntry(c3, changes)], [c3.id], max_entries=1, paths=["a"])
示例#31
0
    def test_get_loose_object_error(self):
        blob = make_object(Blob, data='foo')
        backend = _test_backend([blob])
        mat = re.search('^(..)(.{38})$', blob.id)

        def as_legacy_object_error():
            raise IOError

        blob.as_legacy_object = as_legacy_object_error
        list(get_loose_object(self._req, backend, mat))
        self.assertEquals(HTTP_ERROR, self._status)
示例#32
0
 def test_changes_with_renames(self):
     blob = make_object(Blob, data="blob")
     c1, c2 = self.make_linear_commits(2, trees={1: [("a", blob)], 2: [("b", blob)]})
     entry_a = ("a", F, blob.id)
     entry_b = ("b", F, blob.id)
     changes_without_renames = [TreeChange.delete(entry_a), TreeChange.add(entry_b)]
     changes_with_renames = [TreeChange(CHANGE_RENAME, entry_a, entry_b)]
     self.assertWalkYields([TestWalkEntry(c2, changes_without_renames)], [c2.id], max_entries=1)
     detector = RenameDetector(self.store)
     self.assertWalkYields(
         [TestWalkEntry(c2, changes_with_renames)], [c2.id], max_entries=1, rename_detector=detector
     )
示例#33
0
    def test_follow_rename(self):
        blob = make_object(Blob, data='blob')
        names = ['a', 'a', 'b', 'b', 'c', 'c']

        trees = dict((i + 1, [(n, blob, F)]) for i, n in enumerate(names))
        c1, c2, c3, c4, c5, c6 = self.make_linear_commits(6, trees=trees)
        self.assertWalkYields([c5], [c6.id], paths=['c'])

        e = lambda n: (n, F, blob.id)
        self.assertWalkYields(
          [TestWalkEntry(c5, [TreeChange(CHANGE_RENAME, e('b'), e('c'))]),
           TestWalkEntry(c3, [TreeChange(CHANGE_RENAME, e('a'), e('b'))]),
           TestWalkEntry(c1, [TreeChange.add(e('a'))])],
          [c6.id], paths=['c'], follow=True)
示例#34
0
    def test_deserialize_mergetags(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 <*****@*****.**>",
            message=default_message)
        commit = self.make_commit(mergetag=[tag, tag])

        d = Commit()
        d._deserialize(commit.as_raw_chunks())
        self.assertEquals(commit, d)
示例#35
0
    def test_follow_rename(self):
        blob = make_object(Blob, data='blob')
        names = ['a', 'a', 'b', 'b', 'c', 'c']

        trees = dict((i + 1, [(n, blob, F)]) for i, n in enumerate(names))
        c1, c2, c3, c4, c5, c6 = self.make_linear_commits(6, trees=trees)
        self.assertWalkYields([c5], [c6.id], paths=['c'])

        e = lambda n: (n, F, blob.id)
        self.assertWalkYields(
          [TestWalkEntry(c5, [TreeChange(CHANGE_RENAME, e('b'), e('c'))]),
           TestWalkEntry(c3, [TreeChange(CHANGE_RENAME, e('a'), e('b'))]),
           TestWalkEntry(c1, [TreeChange.add(e('a'))])],
          [c6.id], paths=['c'], follow=True)
示例#36
0
 def test_changes_with_renames(self):
     blob = make_object(Blob, data='blob')
     c1, c2 = self.make_linear_commits(
       2, trees={1: [('a', blob)], 2: [('b', blob)]})
     entry_a = ('a', F, blob.id)
     entry_b = ('b', F, blob.id)
     changes_without_renames = [TreeChange.delete(entry_a),
                                TreeChange.add(entry_b)]
     changes_with_renames = [TreeChange(CHANGE_RENAME, entry_a, entry_b)]
     self.assertWalkYields(
       [TestWalkEntry(c2, changes_without_renames)], [c2.id], max_entries=1)
     detector = RenameDetector(self.store)
     self.assertWalkYields(
       [TestWalkEntry(c2, changes_with_renames)], [c2.id], max_entries=1,
       rename_detector=detector)
示例#37
0
 def test_serialize_simple(self):
     x = make_object(Tag,
                     tagger='Jelmer Vernooij <*****@*****.**>',
                     name='0.1',
                     message='Tag 0.1',
                     object=(Blob, 'd80c186a03f423a81b39df39dc87fd269736ca86'),
                     tag_time=423423423,
                     tag_timezone=0)
     self.assertEqual(('object d80c186a03f423a81b39df39dc87fd269736ca86\n'
                        'type blob\n'
                        'tag 0.1\n'
                        'tagger Jelmer Vernooij <*****@*****.**> '
                        '423423423 +0000\n'
                        '\n'
                        'Tag 0.1'), x.as_raw_string())
示例#38
0
 def test_serialize_simple(self):
     x = make_object(Tag,
                     tagger='Jelmer Vernooij <*****@*****.**>',
                     name='0.1',
                     message='Tag 0.1',
                     object=(Blob, 'd80c186a03f423a81b39df39dc87fd269736ca86'),
                     tag_time=423423423,
                     tag_timezone=0)
     self.assertEquals(('object d80c186a03f423a81b39df39dc87fd269736ca86\n'
                        'type blob\n'
                        'tag 0.1\n'
                        'tagger Jelmer Vernooij <*****@*****.**> '
                        '423423423 +0000\n'
                        '\n'
                        'Tag 0.1'), x.as_raw_string())
示例#39
0
    def setUp(self):
        super(MOFLinearRepoTest, self).setUp()
        f1_1 = make_object(Blob, data='f1') # present in 1, removed in 3
        f2_1 = make_object(Blob, data='f2') # present in all revisions, changed in 2 and 3
        f2_2 = make_object(Blob, data='f2-changed')
        f2_3 = make_object(Blob, data='f2-changed-again')
        f3_2 = make_object(Blob, data='f3') # added in 2, left unmodified in 3

        commit_spec = [[1], [2, 1], [3, 2]]
        trees = {1: [('f1', f1_1), ('f2', f2_1)],
                2: [('f1', f1_1), ('f2', f2_2), ('f3', f3_2)],
                3: [('f2', f2_3), ('f3', f3_2)] }
        # commit 1: f1 and f2
        # commit 2: f3 added, f2 changed. Missing shall report commit id and a
        # tree referenced by commit
        # commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
        # be reported as modified
        self.commits = build_commit_graph(self.store, commit_spec, trees)
        self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
        self.missing_2_3 = [self.cmt(3).id, self.cmt(3).tree, f2_3.id]
        self.missing_1_3 = [
            self.cmt(2).id, self.cmt(3).id,
            self.cmt(2).tree, self.cmt(3).tree,
            f2_2.id, f3_2.id, f2_3.id]
示例#40
0
    def test_follow_rename_remove_path(self):
        blob = make_object(Blob, data='blob')
        _, _, _, c4, c5, c6 = self.make_linear_commits(
          6, trees={1: [('a', blob), ('c', blob)],
                    2: [],
                    3: [],
                    4: [('b', blob)],
                    5: [('a', blob)],
                    6: [('c', blob)]})

        e = lambda n: (n, F, blob.id)
        # Once the path changes to b, we aren't interested in a or c anymore.
        self.assertWalkYields(
          [TestWalkEntry(c6, [TreeChange(CHANGE_RENAME, e('a'), e('c'))]),
           TestWalkEntry(c5, [TreeChange(CHANGE_RENAME, e('b'), e('a'))]),
           TestWalkEntry(c4, [TreeChange.add(e('b'))])],
          [c6.id], paths=['c'], follow=True)
示例#41
0
    def test_follow_rename_remove_path(self):
        blob = make_object(Blob, data='blob')
        _, _, _, c4, c5, c6 = self.make_linear_commits(
          6, trees={1: [('a', blob), ('c', blob)],
                    2: [],
                    3: [],
                    4: [('b', blob)],
                    5: [('a', blob)],
                    6: [('c', blob)]})

        e = lambda n: (n, F, blob.id)
        # Once the path changes to b, we aren't interested in a or c anymore.
        self.assertWalkYields(
          [TestWalkEntry(c6, [TreeChange(CHANGE_RENAME, e('a'), e('c'))]),
           TestWalkEntry(c5, [TreeChange(CHANGE_RENAME, e('b'), e('a'))]),
           TestWalkEntry(c4, [TreeChange.add(e('b'))])],
          [c6.id], paths=['c'], follow=True)
示例#42
0
    def test_follow_rename(self):
        blob = make_object(Blob, data="blob")
        names = ["a", "a", "b", "b", "c", "c"]

        trees = dict((i + 1, [(n, blob, F)]) for i, n in enumerate(names))
        c1, c2, c3, c4, c5, c6 = self.make_linear_commits(6, trees=trees)
        self.assertWalkYields([c5], [c6.id], paths=["c"])

        e = lambda n: (n, F, blob.id)
        self.assertWalkYields(
            [
                TestWalkEntry(c5, [TreeChange(CHANGE_RENAME, e("b"), e("c"))]),
                TestWalkEntry(c3, [TreeChange(CHANGE_RENAME, e("a"), e("b"))]),
                TestWalkEntry(c1, [TreeChange.add(e("a"))]),
            ],
            [c6.id],
            paths=["c"],
            follow=True,
        )
示例#43
0
 def test_serialize_simple(self):
     x = make_object(
         Tag,
         tagger="Jelmer Vernooij <*****@*****.**>",
         name="0.1",
         message="Tag 0.1",
         object=(Blob, "d80c186a03f423a81b39df39dc87fd269736ca86"),
         tag_time=423423423,
         tag_timezone=0,
     )
     self.assertEqual(
         (
             "object d80c186a03f423a81b39df39dc87fd269736ca86\n"
             "type blob\n"
             "tag 0.1\n"
             "tagger Jelmer Vernooij <*****@*****.**> "
             "423423423 +0000\n"
             "\n"
             "Tag 0.1"
         ),
         x.as_raw_string(),
     )
示例#44
0
 def test_add_thin_pack(self):
     o = DiskObjectStore(self.store_dir)
     f, commit = o.add_thin_pack()
     b = make_object(Blob, data="more yummy data")
     write_pack_data(f, [(b, None)], 1)
     commit()