~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_too_much.py

[merge] robertc's integration branch: add BzrDir, and checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
import sys
42
42
 
43
43
from bzrlib.branch import Branch
 
44
import bzrlib.bzrdir as bzrdir
44
45
from bzrlib.errors import BzrCommandError
45
46
from bzrlib.osutils import has_symlinks, pathjoin
46
47
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
117
118
        nick = self.runbzr("nick",backtick=True)
118
119
        self.assertEqual(nick, 'moo\n')
119
120
 
120
 
 
121
121
    def test_invalid_commands(self):
122
122
        self.runbzr("pants", retcode=3)
123
123
        self.runbzr("--pants off", retcode=3)
124
124
        self.runbzr("diff --message foo", retcode=3)
125
125
 
126
 
    def test_empty_commit(self):
127
 
        self.runbzr("init")
128
 
        self.build_tree(['hello.txt'])
129
 
        self.runbzr("commit -m empty", retcode=3)
130
 
        self.runbzr("add hello.txt")
131
 
        self.runbzr("commit -m added")       
132
 
 
133
 
    def test_empty_commit_message(self):
134
 
        self.runbzr("init")
135
 
        file('foo.c', 'wt').write('int main() {}')
136
 
        self.runbzr(['add', 'foo.c'])
137
 
        self.runbzr(["commit", "-m", ""] , retcode=3) 
138
 
 
139
126
    def test_remove_deleted(self):
140
127
        self.runbzr("init")
141
128
        self.build_tree(['a'])
144
131
        os.unlink('a')
145
132
        self.runbzr(['remove', 'a'])
146
133
 
147
 
    def test_other_branch_commit(self):
148
 
        # this branch is to ensure consistent behaviour, whether we're run
149
 
        # inside a branch, or not.
150
 
        os.mkdir('empty_branch')
151
 
        os.chdir('empty_branch')
152
 
        self.runbzr('init')
153
 
        os.mkdir('branch')
154
 
        os.chdir('branch')
155
 
        self.runbzr('init')
156
 
        file('foo.c', 'wt').write('int main() {}')
157
 
        file('bar.c', 'wt').write('int main() {}')
158
 
        os.chdir('..')
159
 
        self.runbzr(['add', 'branch/foo.c'])
160
 
        self.runbzr(['add', 'branch'])
161
 
        # can't commit files in different trees; sane error
162
 
        self.runbzr('commit -m newstuff branch/foo.c .', retcode=3)
163
 
        self.runbzr('commit -m newstuff branch/foo.c')
164
 
        self.runbzr('commit -m newstuff branch')
165
 
        self.runbzr('commit -m newstuff branch', retcode=3)
166
 
 
167
134
    def test_ignore_patterns(self):
168
135
        self.runbzr('init')
169
136
        self.assertEquals(self.capture('unknowns'), '')
341
308
        os.chdir('b')
342
309
        self.runbzr('commit -m foo --unchanged')
343
310
        os.chdir('..')
344
 
        # naughty - abstraction violations RBC 20050928  
345
 
        print "test_branch used to delete the stores, how is this meant to work ?"
346
 
        #shutil.rmtree('a/.bzr/revision-store')
347
 
        #shutil.rmtree('a/.bzr/inventory-store', ignore_errors=True)
348
 
        #shutil.rmtree('a/.bzr/text-store', ignore_errors=True)
349
 
        self.runbzr('branch a d --basis b')
 
311
 
 
312
    def test_branch_basis(self):
 
313
        # ensure that basis really does grab from the basis by having incomplete source
 
314
        tree = self.make_branch_and_tree('commit_tree')
 
315
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
316
        tree.add('foo')
 
317
        tree.commit('revision 1', rev_id='1')
 
318
        source = self.make_branch_and_tree('source')
 
319
        # this gives us an incomplete repository
 
320
        tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
 
321
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
 
322
        tree.bzrdir.open_branch().copy_content_into(source.branch)
 
323
        tree.copy_content_into(source)
 
324
        self.assertFalse(source.branch.repository.has_revision('2'))
 
325
        dir = source.bzrdir
 
326
        self.runbzr('branch source target --basis commit_tree')
 
327
        target = bzrdir.BzrDir.open('target')
 
328
        self.assertEqual('2', target.open_branch().last_revision())
 
329
        self.assertEqual('2', target.open_workingtree().last_revision())
 
330
        self.assertTrue(target.open_branch().repository.has_revision('2'))
350
331
 
351
332
    def test_merge(self):
352
333
        from bzrlib.branch import Branch
376
357
        self.runbzr('merge ../b -r last:1')
377
358
        self.check_file_contents('goodbye', 'quux')
378
359
        # Merging a branch pulls its revision into the tree
379
 
        a = Branch.open('.')
 
360
        a = WorkingTree.open('.')
380
361
        b = Branch.open('../b')
381
 
        a.repository.get_revision_xml(b.last_revision())
382
 
        self.log('pending merges: %s', a.working_tree().pending_merges())
383
 
        self.assertEquals(a.working_tree().pending_merges(),
 
362
        a.branch.repository.get_revision_xml(b.last_revision())
 
363
        self.log('pending merges: %s', a.pending_merges())
 
364
        self.assertEquals(a.pending_merges(),
384
365
                          [b.last_revision()])
385
366
        self.runbzr('commit -m merged')
386
367
        self.runbzr('merge ../b -r last:1')
387
 
        self.assertEqual(Branch.open('.').working_tree().pending_merges(), [])
 
368
        self.assertEqual(a.pending_merges(), [])
388
369
 
389
370
    def test_merge_with_missing_file(self):
390
371
        """Merge handles missing file conflicts"""
688
669
        ass = self.assert_
689
670
        chdir = os.chdir
690
671
        
691
 
        t = WorkingTree.create_standalone('.')
 
672
        t = self.make_branch_and_tree('.')
692
673
        b = t.branch
693
674
        self.build_tree(['src/', 'README'])
694
675
        
1194
1175
 
1195
1176
    def test_branch(self):
1196
1177
        os.mkdir('from')
1197
 
        wt = WorkingTree.create_standalone('from')
 
1178
        wt = self.make_branch_and_tree('from')
1198
1179
        branch = wt.branch
1199
1180
        wt.commit('empty commit for nonsense', allow_pointless=True)
1200
 
        url = self.get_remote_url('from')
 
1181
        url = self.get_readonly_url('from')
1201
1182
        self.run_bzr('branch', url, 'to')
1202
1183
        branch = Branch.open('to')
1203
1184
        self.assertEqual(1, len(branch.revision_history()))
 
1185
        # the branch should be set in to to from
 
1186
        self.assertEqual(url + '/', branch.get_parent())
1204
1187
 
1205
1188
    def test_log(self):
1206
1189
        self.build_tree(['branch/', 'branch/file'])
1207
1190
        self.capture('init branch')
1208
1191
        self.capture('add branch/file')
1209
1192
        self.capture('commit -m foo branch')
1210
 
        url = self.get_remote_url('branch/file')
 
1193
        url = self.get_readonly_url('branch/file')
1211
1194
        output = self.capture('log %s' % url)
1212
1195
        self.assertEqual(8, len(output.split('\n')))
1213
1196
        
1216
1199
        self.capture('init branch')
1217
1200
        self.capture('add branch/file')
1218
1201
        self.capture('commit -m foo branch')
1219
 
        url = self.get_remote_url('branch/')
 
1202
        url = self.get_readonly_url('branch/')
1220
1203
        self.run_bzr('check', url)
1221
1204
    
1222
1205