~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
import shutil
41
41
import sys
42
42
 
 
43
import bzrlib
43
44
from bzrlib.branch import Branch
44
45
import bzrlib.bzrdir as bzrdir
45
46
from bzrlib.errors import BzrCommandError
52
53
 
53
54
class TestCommands(ExternalBase):
54
55
 
55
 
    def test_init_branch(self):
56
 
        self.runbzr(['init'])
57
 
 
58
 
        # Can it handle subdirectories as well?
59
 
        self.runbzr('init subdir1')
60
 
        self.assert_(os.path.exists('subdir1'))
61
 
        self.assert_(os.path.exists('subdir1/.bzr'))
62
 
 
63
 
        self.runbzr('init subdir2/nothere', retcode=3)
64
 
        
65
 
        os.mkdir('subdir2')
66
 
        self.runbzr('init subdir2')
67
 
        self.runbzr('init subdir2', retcode=3)
68
 
 
69
 
        self.runbzr('init subdir2/subsubdir1')
70
 
        self.assert_(os.path.exists('subdir2/subsubdir1/.bzr'))
71
 
 
72
56
    def test_whoami(self):
73
57
        # this should always identify something, if only "john@localhost"
74
58
        self.runbzr("whoami")
80
64
    def test_whoami_branch(self):
81
65
        """branch specific user identity works."""
82
66
        self.runbzr('init')
83
 
        f = file('.bzr/email', 'wt')
84
 
        f.write('Branch Identity <branch@identi.ty>')
85
 
        f.close()
 
67
        b = bzrlib.branch.Branch.open('.')
 
68
        b.control_files.put_utf8('email', 'Branch Identity <branch@identi.ty>')
86
69
        bzr_email = os.environ.get('BZREMAIL')
87
70
        if bzr_email is not None:
88
71
            del os.environ['BZREMAIL']
296
279
        self.example_branch()
297
280
        os.chdir('..')
298
281
        self.runbzr('branch a b')
299
 
        self.assertFileEqual('b\n', 'b/.bzr/branch-name')
 
282
        b = bzrlib.branch.Branch.open('b')
 
283
        self.assertEqual('b\n', b.control_files.get_utf8('branch-name').read())
300
284
        self.runbzr('branch a c -r 1')
301
285
        os.chdir('b')
302
286
        self.runbzr('commit -m foo --unchanged')
322
306
        self.assertEqual('2', target.open_workingtree().last_revision())
323
307
        self.assertTrue(target.open_branch().repository.has_revision('2'))
324
308
 
325
 
    def test_merge(self):
326
 
        from bzrlib.branch import Branch
327
 
        
328
 
        os.mkdir('a')
329
 
        os.chdir('a')
330
 
        self.example_branch()
331
 
        os.chdir('..')
332
 
        self.runbzr('branch a b')
333
 
        os.chdir('b')
334
 
        file('goodbye', 'wt').write('quux')
335
 
        self.runbzr(['commit',  '-m',  "more u's are always good"])
336
 
 
337
 
        os.chdir('../a')
338
 
        file('hello', 'wt').write('quuux')
339
 
        # We can't merge when there are in-tree changes
340
 
        self.runbzr('merge ../b', retcode=3)
341
 
        self.runbzr(['commit', '-m', "Like an epidemic of u's"])
342
 
        self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
343
 
                    retcode=3)
344
 
        self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
345
 
        self.runbzr('revert --no-backup')
346
 
        self.runbzr('merge ../b -r last:1..last:1 --merge-type weave')
347
 
        self.runbzr('revert --no-backup')
348
 
        self.runbzr('merge ../b -r last:1..last:1 --reprocess')
349
 
        self.runbzr('revert --no-backup')
350
 
        self.runbzr('merge ../b -r last:1')
351
 
        self.check_file_contents('goodbye', 'quux')
352
 
        # Merging a branch pulls its revision into the tree
353
 
        a = WorkingTree.open('.')
354
 
        b = Branch.open('../b')
355
 
        a.branch.repository.get_revision_xml(b.last_revision())
356
 
        self.log('pending merges: %s', a.pending_merges())
357
 
        self.assertEquals(a.pending_merges(),
358
 
                          [b.last_revision()])
359
 
        self.runbzr('commit -m merged')
360
 
        self.runbzr('merge ../b -r last:1')
361
 
        self.assertEqual(a.pending_merges(), [])
362
 
 
363
 
    def test_merge_with_missing_file(self):
364
 
        """Merge handles missing file conflicts"""
365
 
        os.mkdir('a')
366
 
        os.chdir('a')
367
 
        os.mkdir('sub')
368
 
        print >> file('sub/a.txt', 'wb'), "hello"
369
 
        print >> file('b.txt', 'wb'), "hello"
370
 
        print >> file('sub/c.txt', 'wb'), "hello"
371
 
        self.runbzr('init')
372
 
        self.runbzr('add')
373
 
        self.runbzr(('commit', '-m', 'added a'))
374
 
        self.runbzr('branch . ../b')
375
 
        print >> file('sub/a.txt', 'ab'), "there"
376
 
        print >> file('b.txt', 'ab'), "there"
377
 
        print >> file('sub/c.txt', 'ab'), "there"
378
 
        self.runbzr(('commit', '-m', 'Added there'))
379
 
        os.unlink('sub/a.txt')
380
 
        os.unlink('sub/c.txt')
381
 
        os.rmdir('sub')
382
 
        os.unlink('b.txt')
383
 
        self.runbzr(('commit', '-m', 'Removed a.txt'))
384
 
        os.chdir('../b')
385
 
        print >> file('sub/a.txt', 'ab'), "something"
386
 
        print >> file('b.txt', 'ab'), "something"
387
 
        print >> file('sub/c.txt', 'ab'), "something"
388
 
        self.runbzr(('commit', '-m', 'Modified a.txt'))
389
 
        self.runbzr('merge ../a/', retcode=1)
390
 
        self.assert_(os.path.exists('sub/a.txt.THIS'))
391
 
        self.assert_(os.path.exists('sub/a.txt.BASE'))
392
 
        os.chdir('../a')
393
 
        self.runbzr('merge ../b/', retcode=1)
394
 
        self.assert_(os.path.exists('sub/a.txt.OTHER'))
395
 
        self.assert_(os.path.exists('sub/a.txt.BASE'))
396
 
 
397
309
    def test_inventory(self):
398
310
        bzr = self.runbzr
399
311
        def output_equals(value, *args):
738
650
        assert '|||||||' not in conflict_text
739
651
        assert 'hi world' not in conflict_text
740
652
        self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
741
 
        self.runbzr('remerge . --merge-type weave --reprocess', retcode=3)
742
653
        self.runbzr('remerge . --show-base --reprocess', retcode=3)
 
654
        self.runbzr('remerge . --merge-type weave --reprocess', retcode=1)
743
655
        self.runbzr('remerge hello --show-base', retcode=1)
744
656
        self.runbzr('remerge hello --reprocess', retcode=1)
745
657
        self.runbzr('resolve --all')
779
691
        self.assert_('|||||||' not in conflict_text)
780
692
        self.assert_('hi world' not in conflict_text)
781
693
        result = self.runbzr('conflicts', backtick=1)
782
 
        self.assertEquals(result, "hello\nquestion\n")
 
694
        self.assertEquals(result, "Text conflict in hello\nText conflict in"
 
695
                                  " question\n")
783
696
        result = self.runbzr('status', backtick=1)
784
 
        self.assert_("conflicts:\n  hello\n  question\n" in result, result)
 
697
        self.assert_("conflicts:\n  Text conflict in hello\n"
 
698
                     "  Text conflict in question\n" in result, result)
785
699
        self.runbzr('resolve hello')
786
700
        result = self.runbzr('conflicts', backtick=1)
787
 
        self.assertEquals(result, "question\n")
 
701
        self.assertEquals(result, "Text conflict in question\n")
788
702
        self.runbzr('commit -m conflicts', retcode=3)
789
703
        self.runbzr('resolve --all')
790
704
        result = self.runbzr('conflicts', backtick=1)