~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import bzrlib.errors as errors
23
23
from bzrlib.errors import NoSuchRevision, UnlistableBranch, NotBranchError
24
24
import bzrlib.gpg
25
 
from bzrlib.selftest import TestCase, TestCaseInTempDir
26
 
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
 
25
from bzrlib.tests import TestCase, TestCaseInTempDir
 
26
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
27
27
from bzrlib.trace import mutter
28
28
import bzrlib.transactions as transactions
29
29
from bzrlib.revision import NULL_REVISION
36
36
 
37
37
    def test_append_revisions(self):
38
38
        """Test appending more than one revision"""
39
 
        br = Branch.initialize(".")
 
39
        br = Branch.initialize(u".")
40
40
        br.append_revision("rev1")
41
41
        self.assertEquals(br.revision_history(), ["rev1",])
42
42
        br.append_revision("rev2", "rev3")
50
50
        b1 = Branch.initialize('b1')
51
51
        b2 = Branch.initialize('b2')
52
52
        file(os.sep.join(['b1', 'foo']), 'w').write('hello')
53
 
        b1.add(['foo'], ['foo-id'])
 
53
        b1.working_tree().add(['foo'], ['foo-id'])
54
54
        b1.working_tree().commit('lala!', rev_id='revision-1', allow_pointless=False)
55
55
 
56
56
        mutter('start fetch')
64
64
        eq(tree.get_file_text('foo-id'), 'hello')
65
65
 
66
66
    def test_revision_tree(self):
67
 
        b1 = Branch.initialize('.')
 
67
        b1 = Branch.initialize(u'.')
68
68
        b1.working_tree().commit('lala!', rev_id='revision-1', allow_pointless=True)
69
69
        tree = b1.revision_tree('revision-1')
70
70
        tree = b1.revision_tree(None)
77
77
        os.mkdir('a')
78
78
        br_a = Branch.initialize("a")
79
79
        file('a/b', 'wb').write('b')
80
 
        br_a.add('b')
 
80
        br_a.working_tree().add('b')
81
81
        commit(br_a, "silly commit", rev_id='A')
82
82
        os.mkdir('b')
83
83
        br_b = Branch.initialize("b")
116
116
        """Copy only part of the history of a branch."""
117
117
        self.build_tree(['a/', 'a/one'])
118
118
        br_a = Branch.initialize('a')
119
 
        br_a.add(['one'])
 
119
        br_a.working_tree().add(['one'])
120
120
        br_a.working_tree().commit('commit one', rev_id='u@d-1')
121
121
        self.build_tree(['a/two'])
122
 
        br_a.add(['two'])
 
122
        br_a.working_tree().add(['two'])
123
123
        br_a.working_tree().commit('commit two', rev_id='u@d-2')
124
124
        br_b = copy_branch(br_a, 'b', revision='u@d-1')
125
125
        self.assertEqual(br_b.last_revision(), 'u@d-1')
128
128
        
129
129
    def test_record_initial_ghost_merge(self):
130
130
        """A pending merge with no revision present is still a merge."""
131
 
        branch = Branch.initialize('.')
 
131
        branch = Branch.initialize(u'.')
132
132
        branch.working_tree().add_pending_merge('non:existent@rev--ision--0--2')
133
133
        branch.working_tree().commit('pretend to merge nonexistent-revision', rev_id='first')
134
134
        rev = branch.get_revision(branch.last_revision())
138
138
        self.assertEqual(rev.parent_ids[0], 'non:existent@rev--ision--0--2')
139
139
 
140
140
    def test_bad_revision(self):
141
 
        branch = Branch.initialize('.')
 
141
        branch = Branch.initialize(u'.')
142
142
        self.assertRaises(errors.InvalidRevisionId, branch.get_revision, None)
143
143
 
144
144
# TODO 20051003 RBC:
148
148
        
149
149
    def test_pending_merges(self):
150
150
        """Tracking pending-merged revisions."""
151
 
        b = Branch.initialize('.')
 
151
        b = Branch.initialize(u'.')
152
152
        wt = b.working_tree()
153
153
        self.assertEquals(wt.pending_merges(), [])
154
154
        wt.add_pending_merge('foo@azkhazan-123123-abcabc')
170
170
        self.assertEquals(wt.pending_merges(), [])
171
171
 
172
172
    def test_sign_existing_revision(self):
173
 
        branch = Branch.initialize('.')
 
173
        branch = Branch.initialize(u'.')
174
174
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
175
175
        from bzrlib.testament import Testament
176
176
        branch.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
178
178
                         branch.revision_store.get('A', 'sig').read())
179
179
 
180
180
    def test_store_signature(self):
181
 
        branch = Branch.initialize('.')
 
181
        branch = Branch.initialize(u'.')
182
182
        branch.store_revision_signature(bzrlib.gpg.LoopbackGPGStrategy(None),
183
183
                                        'FOO', 'A')
184
184
        self.assertEqual('FOO', branch.revision_store.get('A', 'sig').read())
185
185
 
186
186
    def test__relcontrolfilename(self):
187
 
        branch = Branch.initialize('.')
 
187
        branch = Branch.initialize(u'.')
188
188
        self.assertEqual('.bzr/%25', branch._rel_controlfilename('%'))
189
189
        
190
190
    def test__relcontrolfilename_empty(self):
191
 
        branch = Branch.initialize('.')
 
191
        branch = Branch.initialize(u'.')
192
192
        self.assertEqual('.bzr', branch._rel_controlfilename(''))
193
193
 
194
194
    def test_nicks(self):
227
227
                          self.get_remote_url(''))
228
228
        self.assertRaises(NotBranchError, Branch.open_containing,
229
229
                          self.get_remote_url('g/p/q'))
230
 
        b = Branch.initialize('.')
 
230
        b = Branch.initialize(u'.')
231
231
        branch, relpath = Branch.open_containing(self.get_remote_url(''))
232
232
        self.assertEqual('', relpath)
233
233
        branch, relpath = Branch.open_containing(self.get_remote_url('g/p/q'))
237
237
#         >>> from bzrlib.commit import commit
238
238
#         >>> bzrlib.trace.silent = True
239
239
#         >>> br1 = ScratchBranch(files=['foo', 'bar'])
240
 
#         >>> br1.add('foo')
241
 
#         >>> br1.add('bar')
 
240
#         >>> br1.working_tree().add('foo')
 
241
#         >>> br1.working_tree().add('bar')
242
242
#         >>> commit(br1, "lala!", rev_id="REVISION-ID-1", verbose=False)
243
243
#         >>> br2 = ScratchBranch()
244
244
#         >>> br2.update_revisions(br1)
319
319
 
320
320
    def setUp(self):
321
321
        super(TestBranchTransaction, self).setUp()
322
 
        self.branch = Branch.initialize('.')
 
322
        self.branch = Branch.initialize(u'.')
323
323
        
324
324
    def test_default_get_transaction(self):
325
325
        """branch.get_transaction on a new branch should give a PassThrough."""
368
368
 
369
369
    def setUp(self):
370
370
        super(TestBranchPushLocations, self).setUp()
371
 
        self.branch = Branch.initialize('.')
 
371
        self.branch = Branch.initialize(u'.')
372
372
        
373
373
    def test_get_push_location_unset(self):
374
374
        self.assertEqual(None, self.branch.get_push_location())