def simple_commit(self): # Create a git repository with a revision. tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('a', 'text for a\n', False) builder.commit('Joe Foo <*****@*****.**>', u'<The commit message>') builder.finish()
def test_last_revision_is_null(self): tests.run_git('init') thebranch = Branch.open('.') self.assertEqual(revision.NULL_REVISION, thebranch.last_revision()) self.assertEqual((0, revision.NULL_REVISION), thebranch.last_revision_info())
def simple_commit(self): # Create a git repository with a revision. tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('a', 'text for a\n', False) builder.commit('Joe Foo <*****@*****.**>', u'<The commit message>') builder.finish()
def test_tags(self): self.simple_commit() tests.run_git("tag", "foo") output, error = self.run_bzr(['tags']) self.assertEquals(error, '') self.assertEquals(output, "foo 1\n")
def test_tags(self): self.simple_commit() tests.run_git("tag", "foo") output, error = self.run_bzr(['tags']) self.assertEquals(error, '') self.assertEquals(output, "foo 1\n")
def test_create_real_branch(self): tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file(u'foo', 'contents\nfoo\n', False) r1 = builder.commit('Joe Foo <*****@*****.**>', u'first', timestamp=1194586400) mapping = builder.finish() self.assertEqual({1:'44411e8e9202177dd19b6599d7a7991059fa3cb4', 2: 'b0b62e674f67306fddcf72fa888c3b56df100d64', }, mapping)
def test_tags(self): self.simple_commit_a() reva = tests.run_git('rev-parse', 'HEAD').strip() tests.run_git('tag', '-a', '-m', 'add tag', 'foo') newid = open('.git/refs/tags/foo').read().rstrip() thebranch = Branch.open('.') self.assertEquals( {"foo": default_mapping.revision_id_foreign_to_bzr(newid)}, thebranch.tags.get_tag_dict())
def test_branch(self): os.mkdir("gitbranch") os.chdir("gitbranch") tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('a', 'text for a\n', False) builder.commit('Joe Foo <*****@*****.**>', u'<The commit message>') builder.finish() os.chdir("..") output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch']) self.assertEqual(error, 'Branched 1 revision(s).\n') self.assertEqual(output, 'git: counting objects: 3\r\n')
def simple_commit(self): # Create a git repository with some interesting files in a revision. tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('data', 'text\n', False) builder.set_file('executable', 'content', True) builder.set_link('link', 'broken') builder.set_file('subdir/subfile', 'subdir text\n', False) commit_handle = builder.commit('Joe Foo <*****@*****.**>', u'message', timestamp=1205433193) mapping = builder.finish() return mapping[commit_handle]
def test_branch(self): os.mkdir("gitbranch") os.chdir("gitbranch") tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('a', 'text for a\n', False) builder.commit('Joe Foo <*****@*****.**>', u'<The commit message>') builder.finish() os.chdir("..") output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch']) self.assertEqual(error, 'Branched 1 revision(s).\n') self.assertEqual(output, 'git: counting objects: 3\r\n')
def test_create_real_branch(self): tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file(u'foo', 'contents\nfoo\n', False) r1 = builder.commit('Joe Foo <*****@*****.**>', u'first', timestamp=1194586400) mapping = builder.finish() self.assertEqual( { 1: '44411e8e9202177dd19b6599d7a7991059fa3cb4', 2: 'b0b62e674f67306fddcf72fa888c3b56df100d64', }, mapping)
def test_last_revision_is_valid(self): self.simple_commit_a() head = tests.run_git('rev-parse', 'HEAD').strip() thebranch = Branch.open('.') self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head), thebranch.last_revision())
def test_get_revision(self): # GitRepository.get_revision gives a Revision object. # Create a git repository with a revision. tests.run_git('init') builder = tests.GitBranchBuilder() builder.set_file('a', 'text for a\n', False) commit_handle = builder.commit('Joe Foo <*****@*****.**>', u'message') mapping = builder.finish() commit_id = mapping[commit_handle] # Get the corresponding Revision object. revid = default_mapping.revision_id_foreign_to_bzr(commit_id) repo = Repository.open('.') rev = repo.get_revision(revid) self.assertIsInstance(rev, revision.Revision)
def test_revision_history(self): self.simple_commit_a() reva = tests.run_git('rev-parse', 'HEAD').strip() self.build_tree(['b']) tests.run_git('add', 'b') tests.run_git('commit', '-m', 'b') revb = tests.run_git('rev-parse', 'HEAD').strip() thebranch = Branch.open('.') self.assertEqual([ default_mapping.revision_id_foreign_to_bzr(r) for r in (reva, revb) ], thebranch.revision_history())
def test_get_revision_unknown(self): tests.run_git('init') repo = Repository.open('.') self.assertRaises(errors.NoSuchRevision, repo.get_revision, "bla")
def simple_commit_a(self): tests.run_git('init') self.build_tree(['a']) tests.run_git('add', 'a') tests.run_git('commit', '-m', 'a')
def test_open_existing(self): tests.run_git('init') gd = bzrdir.BzrDir.open('.') self.assertIsInstance(gd, dir.LocalGitDir)
def test_open_existing(self): tests.run_git('init') thebranch = Branch.open('.') self.assertIsInstance(thebranch, branch.GitBranch)
def test_open_workingtree(self): tests.run_git('init') gd = bzrdir.BzrDir.open('.') wt = gd.open_workingtree() self.assertIsInstance(wt, workingtree.GitWorkingTree)
def test_open_workingtree_bare(self): tests.run_git('--bare', 'init') gd = bzrdir.BzrDir.open('.') self.assertRaises(errors.NoWorkingTree, gd.open_workingtree)
def test_has_git_repo(self): tests.run_git('init') repo = Repository.open('.') self.assertIsInstance(repo._git, git.repo.Repo)
def test_open_existing(self): tests.run_git('init') repo = Repository.open('.') self.assertIsInstance(repo, repository.GitRepository)