/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_branch.py

  • Committer: Michael Hudson
  • Date: 2010-02-17 02:04:25 UTC
  • mto: (0.200.721 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: michael.hudson@canonical.com-20100217020425-1i19smhkatqsrg3v
this works for my tests, but i'm pretty sure it's wrong in general

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
    def test_open_existing(self):
58
58
        GitRepo.init('.')
59
 
        d = BzrDir.open('.')
60
 
        thebranch = d.create_branch()
 
59
 
 
60
        thebranch = Branch.open('.')
61
61
        self.assertIsInstance(thebranch, branch.GitBranch)
62
62
 
63
63
    def test_repr(self):
64
64
        GitRepo.init('.')
65
 
        d = BzrDir.open('.')
66
 
        thebranch = d.create_branch()
67
 
        self.assertEquals("<LocalGitBranch('file://%s/', 'refs/heads/master')>" % self.test_dir, repr(thebranch))
 
65
        thebranch = Branch.open('.')
 
66
        self.assertEquals("LocalGitBranch('file://%s/', 'HEAD')" % self.test_dir, repr(thebranch))
68
67
 
69
68
    def test_last_revision_is_null(self):
70
69
        GitRepo.init('.')
71
 
        thedir = BzrDir.open('.')
72
 
        thebranch = thedir.create_branch()
 
70
 
 
71
        thebranch = Branch.open('.')
73
72
        self.assertEqual(revision.NULL_REVISION, thebranch.last_revision())
74
73
        self.assertEqual((0, revision.NULL_REVISION),
75
74
                         thebranch.last_revision_info())
83
82
    def test_last_revision_is_valid(self):
84
83
        self.simple_commit_a()
85
84
        head = tests.run_git('rev-parse', 'HEAD').strip()
 
85
 
86
86
        thebranch = Branch.open('.')
87
87
        self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head),
88
88
                         thebranch.last_revision())
122
122
    def setUp(self):
123
123
        tests.TestCaseWithTransport.setUp(self)
124
124
        dulwich.repo.Repo.create(self.test_dir)
125
 
        d = BzrDir.open(self.test_dir)
126
 
        self.git_branch = d.create_branch()
 
125
        self.git_branch = Branch.open(self.test_dir)
127
126
 
128
127
    def test_get_parent(self):
129
128
        self.assertIs(None, self.git_branch.get_parent())
204
203
        inter_branch.pull()
205
204
        self.assertEquals(revid2, newbranch.last_revision())
206
205
 
207
 
    def test_interbranch_pull_noop(self):
208
 
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
209
 
        oldrepo = Repository.open(path)
210
 
        revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
211
 
        newbranch = self.make_branch('g')
212
 
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
213
 
        inter_branch.pull()
214
 
        # This is basically "assertNotRaises"
215
 
        inter_branch.pull()
216
 
        self.assertEquals(revid2, newbranch.last_revision())
217
 
 
218
 
    def test_interbranch_pull_stop_revision(self):
219
 
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
220
 
        oldrepo = Repository.open(path)
221
 
        revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
222
 
        newbranch = self.make_branch('g')
223
 
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
224
 
        inter_branch.pull(stop_revision=revid1)
225
 
        self.assertEquals(revid1, newbranch.last_revision())
226
 
 
227
206
    def test_interbranch_limited_pull(self):
228
207
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
229
208
        oldrepo = Repository.open(path)
240
219
class ForeignTestsBranchFactory(object):
241
220
 
242
221
    def make_empty_branch(self, transport):
243
 
        d = LocalGitBzrDirFormat().initialize_on_transport(transport)
244
 
        return d.create_branch()
 
222
        return LocalGitBzrDirFormat().initialize_on_transport(transport).open_branch()
245
223
 
246
224
    make_branch = make_empty_branch
247
 
 
248
 
 
249