コード例 #1
0
    def test_clone(self):
        t1 = self.eg.root
        left = t1.new_tree('left')

        left_blob = left.new_blob('blob')
        left_blob.data = 'left_blob orig data'
        left_tree = left.new_tree('tree')
        left_tree_blob = left_tree.new_blob('blob')
        left_tree_blob.data = 'left_tree_blob orig data'

        right = t1.new_tree('right')
        right_blob = right.clone(left_blob, 'blob')
        left_blob.data = 'left_blob other data'
        right_tree = right.clone(left_tree, 'tree')
        left_tree_blob.data = 'left_tree_blob other data'

        self.assertEqual(left_blob.data, 'left_blob other data')
        self.assertEqual(right_blob.data, 'left_blob orig data')
        self.assertEqual(left_tree_blob.data, 'left_tree_blob other data')
        self.assertEqual(right_tree['blob'].data, 'left_tree_blob orig data')

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="test commit")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['left']['blob'].data, 'left_blob other data')
        self.assertEqual(eg2.root['right']['blob'].data, 'left_blob orig data')
        self.assertEqual(eg2.root['left']['tree']['blob'].data,
                         'left_tree_blob other data')
        self.assertEqual(eg2.root['right']['tree']['blob'].data,
                         'left_tree_blob orig data')
コード例 #2
0
    def setUp(self):
        self.repo_path = tempfile.mkdtemp()
        git = dulwich.repo.Repo.init_bare(self.repo_path)
        git_t1 = dulwich.objects.Tree()
        git_t2 = dulwich.objects.Tree()
        git_b1 = dulwich.objects.Blob.from_string('b1 data')
        git_b2 = dulwich.objects.Blob.from_string('b2 data')
        git.object_store.add_object(git_b1)
        git.object_store.add_object(git_b2)
        git_t2['b2'] = (0100644, git_b2.id)
        git.object_store.add_object(git_t2)
        git_t1['b1'] = (0100644, git_b1.id)
        git_t1['t2'] = (040000, git_t2.id)
        git.object_store.add_object(git_t1)

        commit_time = int(time())
        git_c = dulwich.objects.Commit()
        git_c.commit_time = commit_time
        git_c.author_time = commit_time
        git_c.commit_timezone = 2 * 60 * 60
        git_c.author_timezone = 2 * 60 * 60
        git_c.author = "Spaghetti User <*****@*****.**>"
        git_c.committer = git_c.author
        git_c.message = "test fixture"
        git_c.encoding = "UTF-8"
        git_c.tree = git_t1.id
        git.object_store.add_object(git_c)
        git.refs['refs/heads/master'] = git_c.id

        self.eg = EasyGit.open_repo(self.repo_path)
コード例 #3
0
    def test_modify_multiple(self):
        with self.eg.root as root:
            root['t2']['b2'].data = 'new b2'
            with root.new_tree('t3') as t3:
                t3.new_blob('b3').data = 'new b3'
                t3.new_blob('b4').data = 'new b4'
            with root.new_tree('t4') as t4:
                t4.new_blob('b5').data = 'new b5'
            root.new_blob('b6').data = 'new b6'
        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="multiple changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        root2 = eg2.root
        self.assertEqual(set(root2.keys()), set(['b1', 't2', 't3', 't4',
                                                 'b6']))
        self.assertEqual(root2['b1'].data, 'b1 data')
        self.assertEqual(set(root2['t2'].keys()), set(['b2']))
        self.assertEqual(root2['t2']['b2'].data, 'new b2')
        self.assertEqual(set(root2['t3'].keys()), set(['b3', 'b4']))
        self.assertEqual(root2['t3']['b3'].data, 'new b3')
        self.assertEqual(root2['t3']['b4'].data, 'new b4')
        self.assertEqual(set(root2['t4'].keys()), set(['b5']))
        self.assertEqual(root2['t4']['b5'].data, 'new b5')
        self.assertEqual(root2['b6'].data, 'new b6')
コード例 #4
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def test_modify_multiple(self):
        with self.eg.root as root:
            root['t2']['b2'].data = 'new b2'
            with root.new_tree('t3') as t3:
                t3.new_blob('b3').data = 'new b3'
                t3.new_blob('b4').data = 'new b4'
            with root.new_tree('t4') as t4:
                t4.new_blob('b5').data = 'new b5'
            root.new_blob('b6').data = 'new b6'
        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="multiple changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        root2 = eg2.root
        self.assertEqual(set(root2.keys()),
                         set(['b1', 't2', 't3', 't4', 'b6']))
        self.assertEqual(root2['b1'].data, 'b1 data')
        self.assertEqual(set(root2['t2'].keys()), set(['b2']))
        self.assertEqual(root2['t2']['b2'].data, 'new b2')
        self.assertEqual(set(root2['t3'].keys()), set(['b3', 'b4']))
        self.assertEqual(root2['t3']['b3'].data, 'new b3')
        self.assertEqual(root2['t3']['b4'].data, 'new b4')
        self.assertEqual(set(root2['t4'].keys()), set(['b5']))
        self.assertEqual(root2['t4']['b5'].data, 'new b5')
        self.assertEqual(root2['b6'].data, 'new b6')
コード例 #5
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def test_clone(self):
        t1 = self.eg.root
        left = t1.new_tree('left')

        left_blob = left.new_blob('blob')
        left_blob.data = 'left_blob orig data'
        left_tree = left.new_tree('tree')
        left_tree_blob = left_tree.new_blob('blob')
        left_tree_blob.data = 'left_tree_blob orig data'

        right = t1.new_tree('right')
        right_blob = right.clone(left_blob, 'blob')
        left_blob.data = 'left_blob other data'
        right_tree = right.clone(left_tree, 'tree')
        left_tree_blob.data = 'left_tree_blob other data'

        self.assertEqual(left_blob.data, 'left_blob other data')
        self.assertEqual(right_blob.data, 'left_blob orig data')
        self.assertEqual(left_tree_blob.data, 'left_tree_blob other data')
        self.assertEqual(right_tree['blob'].data, 'left_tree_blob orig data')

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="test commit")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['left']['blob'].data, 'left_blob other data')
        self.assertEqual(eg2.root['right']['blob'].data, 'left_blob orig data')
        self.assertEqual(eg2.root['left']['tree']['blob'].data,
                         'left_tree_blob other data')
        self.assertEqual(eg2.root['right']['tree']['blob'].data,
                         'left_tree_blob orig data')
コード例 #6
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def setUp(self):
        self.repo_path = tempfile.mkdtemp()
        git = dulwich.repo.Repo.init_bare(self.repo_path)
        git_t1 = dulwich.objects.Tree()
        git_t2 = dulwich.objects.Tree()
        git_b1 = dulwich.objects.Blob.from_string('b1 data')
        git_b2 = dulwich.objects.Blob.from_string('b2 data')
        git.object_store.add_object(git_b1)
        git.object_store.add_object(git_b2)
        git_t2['b2'] = (0100644, git_b2.id)
        git.object_store.add_object(git_t2)
        git_t1['b1'] = (0100644, git_b1.id)
        git_t1['t2'] = (040000, git_t2.id)
        git.object_store.add_object(git_t1)

        commit_time = int(time())
        git_c = dulwich.objects.Commit()
        git_c.commit_time = commit_time
        git_c.author_time = commit_time
        git_c.commit_timezone = 2*60*60
        git_c.author_timezone = 2*60*60
        git_c.author = "Spaghetti User <*****@*****.**>"
        git_c.committer = git_c.author
        git_c.message = "test fixture"
        git_c.encoding = "UTF-8"
        git_c.tree = git_t1.id
        git.object_store.add_object(git_c)
        git.refs['refs/heads/master'] = git_c.id

        self.eg = EasyGit.open_repo(self.repo_path)
コード例 #7
0
    def test_self_remove_entry(self):
        with self.eg.root as t1:
            t1['t2'].remove()
            t1['b1'].remove()

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="removing entries")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root.keys(), [])
コード例 #8
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def test_self_remove_entry(self):
        with self.eg.root as t1:
            t1['t2'].remove()
            t1['b1'].remove()

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="removing entries")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root.keys(), [])
コード例 #9
0
    def test_modify_tree(self):
        t1 = self.eg.root
        with t1['t2'] as t2:
            b3 = t2.new_blob('b3')
            with b3:
                b3.data = 'asdf'
            self.assertEqual(set(t2.keys()), set(['b2', 'b3']))
            self.assertEqual(t2['b3'].data, 'asdf')
        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="propagating changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['t2']['b3'].data, 'asdf')
コード例 #10
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def test_modify_tree(self):
        t1 = self.eg.root
        with t1['t2'] as t2:
            b3 = t2.new_blob('b3')
            with b3:
                b3.data = 'asdf'
            self.assertEqual(set(t2.keys()), set(['b2', 'b3']))
            self.assertEqual(t2['b3'].data, 'asdf')
        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="propagating changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['t2']['b3'].data, 'asdf')
コード例 #11
0
    def test_modify_blob(self):
        t1 = self.eg.root
        with t1['t2']['b2'] as b2:
            self.assertNotEqual(b2.data, 'qwer')
            b2.data = 'qwer'
            self.assertEqual(b2.data, 'qwer')

        with t1['t2']['b2'] as b2:
            self.assertEqual(b2.data, 'qwer')

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="propagating changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['t2']['b2'].data, 'qwer')
コード例 #12
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
    def test_modify_blob(self):
        t1 = self.eg.root
        with t1['t2']['b2'] as b2:
            self.assertNotEqual(b2.data, 'qwer')
            b2.data = 'qwer'
            self.assertEqual(b2.data, 'qwer')

        with t1['t2']['b2'] as b2:
            self.assertEqual(b2.data, 'qwer')

        self.eg.commit(author="Spaghetti User <*****@*****.**>",
                       message="propagating changes")

        eg2 = EasyGit.open_repo(self.repo_path)
        self.assertEqual(eg2.root['t2']['b2'].data, 'qwer')
コード例 #13
0
ファイル: test_treetree.py プロジェクト: zsaur/SpaghettiFS
 def setUp(self):
     self.repo_path = tempfile.mkdtemp()
     self.eg = EasyGit.new_repo(self.repo_path, bare=True)
     self.tt = TreeTree(self.eg.root.new_tree('tt'))
コード例 #14
0
 def setUp(self):
     self.repo_path = tempfile.mkdtemp()
     self.eg = EasyGit.new_repo(self.repo_path, bare=True)
コード例 #15
0
ファイル: test_easygit.py プロジェクト: bradparks/SpaghettiFS
 def setUp(self):
     self.repo_path = tempfile.mkdtemp()
     self.eg = EasyGit.new_repo(self.repo_path, bare=True)