Example #1
0
 def test_conflict_error_on_first_commit(self):
     from acidfs import ConflictError
     fs = self.make_one()
     fs.open('foo', 'wb').write(b'Hello!')
     open(os.path.join(self.tmp, 'foo'), 'wb').write(b'Howdy!')
     _check_output(['git', 'add', '.'], cwd=self.tmp)
     _check_output(['git', 'commit', '-m', 'Haha!  First!'], cwd=self.tmp)
     with self.assertRaises(ConflictError):
         transaction.commit()
Example #2
0
    def test_conflict_error_on_first_commit(self):
        from acidfs import ConflictError

        fs = self.make_one()
        fs.open("foo", "wb").write(b"Hello!")
        open(os.path.join(self.tmp, "foo"), "wb").write(b"Howdy!")
        _check_output(["git", "add", "."], cwd=self.tmp)
        _check_output(["git", "commit", "-m", "Haha!  First!"], cwd=self.tmp)
        with self.assertRaises(ConflictError):
            transaction.commit()
Example #3
0
    def test_merge_add_file(self):
        fs = self.make_one()
        fs.open("foo", "wb").write(b"Hello!\n")
        transaction.commit()

        fs.open("bar", "wb").write(b"Howdy!\n")
        open(os.path.join(self.tmp, "baz"), "wb").write(b"Ciao!\n")
        _check_output(["git", "add", "baz"], cwd=self.tmp)
        _check_output(["git", "commit", "-m", "haha"], cwd=self.tmp)
        transaction.commit()

        self.assertTrue(fs.exists("foo"))
        self.assertTrue(fs.exists("bar"))
        self.assertTrue(fs.exists("baz"))
Example #4
0
    def test_merge_add_file(self):
        fs = self.make_one()
        fs.open('foo', 'wb').write(b'Hello!\n')
        transaction.commit()

        fs.open('bar', 'wb').write(b'Howdy!\n')
        open(os.path.join(self.tmp, 'baz'), 'wb').write(b'Ciao!\n')
        _check_output(['git', 'add', 'baz'], cwd=self.tmp)
        _check_output(['git', 'commit', '-m', 'haha'], cwd=self.tmp)
        transaction.commit()

        self.assertTrue(fs.exists('foo'))
        self.assertTrue(fs.exists('bar'))
        self.assertTrue(fs.exists('baz'))
Example #5
0
    def test_merge_rm_file(self):
        fs = self.make_one(head="master")
        fs.open("foo", "wb").write(b"Hello\n")
        fs.open("bar", "wb").write(b"Grazie\n")
        fs.open("baz", "wb").write(b"Prego\n")
        transaction.commit()

        fs.rm("foo")
        _check_output(["git", "rm", "baz"], cwd=self.tmp)
        _check_output(["git", "commit", "-m", "gotcha"], cwd=self.tmp)
        transaction.commit()

        self.assertFalse(fs.exists("foo"))
        self.assertTrue(fs.exists("bar"))
        self.assertFalse(fs.exists("baz"))
Example #6
0
    def test_merge_rm_file(self):
        fs = self.make_one(head='master')
        fs.open('foo', 'wb').write(b'Hello\n')
        fs.open('bar', 'wb').write(b'Grazie\n')
        fs.open('baz', 'wb').write(b'Prego\n')
        transaction.commit()

        fs.rm('foo')
        _check_output(['git', 'rm', 'baz'], cwd=self.tmp)
        _check_output(['git', 'commit', '-m', 'gotcha'], cwd=self.tmp)
        transaction.commit()

        self.assertFalse(fs.exists('foo'))
        self.assertTrue(fs.exists('bar'))
        self.assertFalse(fs.exists('baz'))
Example #7
0
    def test_branch_and_then_merge(self):
        fs = self.make_one()
        fs.open("foo", "wb").write(b"Hello")
        transaction.commit()

        fs2 = self.make_one(head="abranch")
        fs2.set_base(fs.get_base())
        fs2.open("bar", "wb").write(b"Ciao")
        fs.open("baz", "wb").write(b"Hola")
        transaction.commit()

        fs.set_base("abranch")
        fs.open("beez", "wb").write(b"buzz")
        transaction.commit()

        self.assertTrue(fs.exists("foo"))
        self.assertTrue(fs.exists("bar"))
        self.assertTrue(fs.exists("baz"))
        self.assertTrue(fs.exists("beez"))
        self.assertTrue(fs2.exists("foo"))
        self.assertTrue(fs2.exists("bar"))
        self.assertFalse(fs2.exists("baz"))
        self.assertFalse(fs2.exists("beez"))

        # Expecting two parents for commit since it's a merge
        commit = _check_output(["git", "cat-file", "-p", "HEAD^{commit}"], cwd=self.tmp).decode("ascii").split("\n")
        self.assertTrue(commit[1].startswith("parent"))
        self.assertTrue(commit[2].startswith("parent"))
Example #8
0
    def test_branch_and_then_merge(self):
        fs = self.make_one()
        fs.open('foo', 'wb').write(b'Hello')
        transaction.commit()

        fs2 = self.make_one(head='abranch')
        fs2.set_base(fs.get_base())
        fs2.open('bar', 'wb').write(b'Ciao')
        fs.open('baz', 'wb').write(b'Hola')
        transaction.commit()

        fs.set_base('abranch')
        fs.open('beez', 'wb').write(b'buzz')
        transaction.commit()

        self.assertTrue(fs.exists('foo'))
        self.assertTrue(fs.exists('bar'))
        self.assertTrue(fs.exists('baz'))
        self.assertTrue(fs.exists('beez'))
        self.assertTrue(fs2.exists('foo'))
        self.assertTrue(fs2.exists('bar'))
        self.assertFalse(fs2.exists('baz'))
        self.assertFalse(fs2.exists('beez'))

        # Expecting two parents for commit since it's a merge
        commit = _check_output(
            ['git', 'cat-file', '-p', 'HEAD^{commit}'],
            cwd=self.tmp).decode('ascii').split('\n')
        self.assertTrue(commit[1].startswith('parent'))
        self.assertTrue(commit[2].startswith('parent'))
Example #9
0
def test_commit_metadata_extended_info_for_user(factory, tmp):
    fs = factory()
    tx = transaction.get()
    tx.note("A test commit.")
    tx.setExtendedInfo('user', 'Fred Flintstone')
    tx.setExtendedInfo('email', '*****@*****.**')
    fs.open('foo', 'wb').write(b'Howdy!')
    transaction.commit()

    output = _check_output(['git', 'log'], cwd=tmp)
    assert b'Author: Fred Flintstone <*****@*****.**>' in output
    assert b'A test commit.' in output
Example #10
0
    def test_commit_metadata_extended_info_for_user(self):
        fs = self.make_one()
        tx = transaction.get()
        tx.note("A test commit.")
        tx.setExtendedInfo("user", "Fred Flintstone")
        tx.setExtendedInfo("email", "*****@*****.**")
        fs.open("foo", "wb").write(b"Howdy!")
        transaction.commit()

        output = _check_output(["git", "log"], cwd=self.tmp)
        self.assertIn(b"Author: Fred Flintstone <*****@*****.**>", output)
        self.assertIn(b"A test commit.", output)
Example #11
0
def test_commit_metadata_extended_info_for_user(factory, tmp):
    fs = factory()
    tx = transaction.get()
    tx.note("A test commit.")
    tx.setExtendedInfo('user', 'Fred Flintstone')
    tx.setExtendedInfo('email', '*****@*****.**')
    fs.open('foo', 'wb').write(b'Howdy!')
    transaction.commit()

    output = _check_output(['git', 'log'], cwd=tmp)
    assert b'Author: Fred Flintstone <*****@*****.**>' in output
    assert b'A test commit.' in output
Example #12
0
    def test_commit_metadata_extended_info_for_user(self):
        fs = self.make_one()
        tx = transaction.get()
        tx.note("A test commit.")
        tx.setExtendedInfo('user', 'Fred Flintstone')
        tx.setExtendedInfo('email', '*****@*****.**')
        fs.open('foo', 'wb').write(b'Howdy!')
        transaction.commit()

        output = _check_output(['git', 'log'], cwd=self.tmp)
        self.assertIn(b'Author: Fred Flintstone <*****@*****.**>', output)
        self.assertIn(b'A test commit.', output)
Example #13
0
def test_commit_metadata_user_path_is_blank(factory, tmp):
    # pyramid_tm calls setUser with '' for path
    fs = factory()
    tx = transaction.get()
    tx.note("A test commit.")
    tx.setUser('Fred', '')
    tx.setExtendedInfo('email', '*****@*****.**')
    fs.open('foo', 'wb').write(b'Howdy!')
    transaction.commit()

    output = _check_output(['git', 'log'], cwd=tmp)
    assert b'Author: Fred <*****@*****.**>' in output
    assert b'A test commit.' in output
Example #14
0
def test_commit_metadata_user_path_is_blank(factory, tmp):
    # pyramid_tm calls setUser with '' for path
    fs = factory()
    tx = transaction.get()
    tx.note("A test commit.")
    tx.setUser('Fred', '')
    tx.setExtendedInfo('email', '*****@*****.**')
    fs.open('foo', 'wb').write(b'Howdy!')
    transaction.commit()

    output = _check_output(['git', 'log'], cwd=tmp)
    assert b'Author: Fred <*****@*****.**>' in output
    assert b'A test commit.' in output