Example #1
0
 def make_commits(self, commit_spec, **kwargs):
     times = kwargs.pop('times', [])
     attrs = kwargs.pop('attrs', {})
     for i, t in enumerate(times):
         attrs.setdefault(i + 1, {})['commit_time'] = t
     return build_commit_graph(self.store, commit_spec, attrs=attrs,
                               **kwargs)
Example #2
0
 def test_commit_time(self):
     c1, c2, c3 = build_commit_graph(self.store, [[1], [2, 1], [3, 2]],
                                     attrs={1: {'commit_time': 124},
                                            2: {'commit_time': 123}})
     self.assertEqual(124, c1.commit_time)
     self.assertEqual(123, c2.commit_time)
     self.assertTrue(c2.commit_time < c1.commit_time < c3.commit_time)
Example #3
0
 def make_commits(self, commit_spec, **kwargs):
     times = kwargs.pop('times', [])
     attrs = kwargs.pop('attrs', {})
     for i, t in enumerate(times):
         attrs.setdefault(i + 1, {})['commit_time'] = t
     return build_commit_graph(self.store, commit_spec, attrs=attrs,
                               **kwargs)
    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]")
Example #5
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
        ]
Example #6
0
 def test_commit_time(self):
     c1, c2, c3 = build_commit_graph(self.store, [[1], [2, 1], [3, 2]],
                                     attrs={1: {'commit_time': 124},
                                            2: {'commit_time': 123}})
     self.assertEqual(124, c1.commit_time)
     self.assertEqual(123, c2.commit_time)
     self.assertTrue(c2.commit_time < c1.commit_time < c3.commit_time)
Example #7
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]")
Example #8
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'])
Example #9
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'])
Example #10
0
 def test_linear(self):
     c1, c2 = build_commit_graph(self.store, [[1], [2, 1]])
     for obj_id in [c1.id, c2.id, c1.tree, c2.tree]:
         self.assertTrue(obj_id in self.store)
     self.assertEqual([], c1.parents)
     self.assertEqual([c1.id], c2.parents)
     self.assertEqual(c1.tree, c2.tree)
     self.assertEqual([], list(self.store[c1.tree].iteritems()))
     self.assertTrue(c2.commit_time > c1.commit_time)
Example #11
0
 def test_linear(self):
     c1, c2 = build_commit_graph(self.store, [[1], [2, 1]])
     for obj_id in [c1.id, c2.id, c1.tree, c2.tree]:
         self.assertTrue(obj_id in self.store)
     self.assertEqual([], c1.parents)
     self.assertEqual([c1.id], c2.parents)
     self.assertEqual(c1.tree, c2.tree)
     self.assertEqual([], list(self.store[c1.tree].iteritems()))
     self.assertTrue(c2.commit_time > c1.commit_time)
Example #12
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]
Example #13
0
 def test_attrs(self):
     c1, c2 = build_commit_graph(self.store, [[1], [2, 1]],
                                 attrs={1: {'message': 'Hooray!'}})
     self.assertEqual('Hooray!', c1.message)
     self.assertEqual('Commit 2', c2.message)
Example #14
0
 def test_merge(self):
     c1, c2, c3, c4 = build_commit_graph(self.store,
                                         [[1], [2, 1], [3, 1], [4, 2, 3]])
     self.assertEqual([c2.id, c3.id], c4.parents)
     self.assertTrue(c4.commit_time > c2.commit_time)
     self.assertTrue(c4.commit_time > c3.commit_time)
Example #15
0
 def test_attrs(self):
     c1, c2 = build_commit_graph(self.store, [[1], [2, 1]],
                                 attrs={1: {'message': 'Hooray!'}})
     self.assertEqual('Hooray!', c1.message)
     self.assertEqual('Commit 2', c2.message)
Example #16
0
 def test_merge(self):
     c1, c2, c3, c4 = build_commit_graph(self.store,
                                         [[1], [2, 1], [3, 1], [4, 2, 3]])
     self.assertEqual([c2.id, c3.id], c4.parents)
     self.assertTrue(c4.commit_time > c2.commit_time)
     self.assertTrue(c4.commit_time > c3.commit_time)