/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2010-05-01 23:16:11 UTC
  • mfrom: (0.200.904 trunk)
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100501231611-t8hh69jq6krevlwi
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
    _test_needs_features = [tests.GitCommandFeature]
54
54
 
 
55
    def _do_commit(self):
 
56
        builder = tests.GitBranchBuilder()
 
57
        builder.set_file('a', 'text for a\n', False)
 
58
        commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
 
59
        mapping = builder.finish()
 
60
        return mapping[commit_handle]
 
61
 
55
62
    def test_open_existing(self):
56
63
        GitRepo.init(self.test_dir)
57
64
 
64
71
        repo = Repository.open('.')
65
72
        self.assertIsInstance(repo._git, dulwich.repo.Repo)
66
73
 
 
74
    def test_has_revision(self):
 
75
        GitRepo.init(self.test_dir)
 
76
        commit_id = self._do_commit()
 
77
        repo = Repository.open('.')
 
78
        self.assertFalse(repo.has_revision('foobar'))
 
79
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
 
80
        self.assertTrue(repo.has_revision(revid))
 
81
 
 
82
    def test_has_revisions(self):
 
83
        GitRepo.init(self.test_dir)
 
84
        commit_id = self._do_commit()
 
85
        repo = Repository.open('.')
 
86
        self.assertEquals(set(), repo.has_revisions(['foobar']))
 
87
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
 
88
        self.assertEquals(set([revid]), repo.has_revisions(['foobar', revid]))
 
89
 
67
90
    def test_get_revision(self):
68
91
        # GitRepository.get_revision gives a Revision object.
69
92
 
70
93
        # Create a git repository with a revision.
71
94
        GitRepo.init(self.test_dir)
72
 
        builder = tests.GitBranchBuilder()
73
 
        builder.set_file('a', 'text for a\n', False)
74
 
        commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
75
 
        mapping = builder.finish()
76
 
        commit_id = mapping[commit_handle]
 
95
        commit_id = self._do_commit()
77
96
 
78
97
        # Get the corresponding Revision object.
79
98
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)