~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Dirty merge of the mainline

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
 
from bzrlib.clone import copy_branch
45
44
from bzrlib.errors import BzrCommandError
46
45
from bzrlib.osutils import has_symlinks, pathjoin
47
46
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
48
47
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
49
48
from bzrlib.tests.blackbox import ExternalBase
50
49
 
 
50
 
51
51
class TestCommands(ExternalBase):
52
52
 
53
53
    def test_help_commands(self):
346
346
        zf = ZipFile('../first-zip')
347
347
        self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
348
348
 
349
 
    def test_diff(self):
350
 
        self.example_branch()
351
 
        file('hello', 'wt').write('hello world!')
352
 
        self.runbzr('commit -m fixing hello')
353
 
        output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
354
 
        self.assert_('\n+hello world!' in output)
355
 
        output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
356
 
        self.assert_('\n+baz' in output)
357
 
        file('moo', 'wb').write('moo')
358
 
        self.runbzr('add moo')
359
 
        os.unlink('moo')
360
 
        self.runbzr('diff')
361
 
 
362
 
    def test_diff_branches(self):
363
 
        self.build_tree(['branch1/', 'branch1/file', 'branch2/'], line_endings='binary')
364
 
        branch = Branch.initialize('branch1')
365
 
        branch.working_tree().add(['file'])
366
 
        branch.working_tree().commit('add file')
367
 
        copy_branch(branch, 'branch2')
368
 
        print >> open('branch2/file', 'wb'), 'new content'
369
 
        branch2 = Branch.open('branch2')
370
 
        branch2.working_tree().commit('update file')
371
 
        # should open branch1 and diff against branch2, 
372
 
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
373
 
                                        'branch1'],
374
 
                                       retcode=1)
375
 
        self.assertEquals(("=== modified file 'file'\n"
376
 
                           "--- file\t\n"
377
 
                           "+++ file\t\n"
378
 
                           "@@ -1,1 +1,1 @@\n"
379
 
                           "-new content\n"
380
 
                           "+contents of branch1/file\n"
381
 
                           "\n", ''), output)
382
 
        output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
383
 
                                       retcode=1)
384
 
        self.assertEqualDiff(("=== modified file 'file'\n"
385
 
                              "--- file\t\n"
386
 
                              "+++ file\t\n"
387
 
                              "@@ -1,1 +1,1 @@\n"
388
 
                              "-new content\n"
389
 
                              "+contents of branch1/file\n"
390
 
                              "\n", ''), output)
391
 
 
392
 
 
393
349
    def test_branch(self):
394
350
        """Branch from one branch to another."""
395
351
        os.mkdir('a')
439
395
        # Merging a branch pulls its revision into the tree
440
396
        a = Branch.open('.')
441
397
        b = Branch.open('../b')
442
 
        a.get_revision_xml(b.last_revision())
 
398
        a.repository.get_revision_xml(b.last_revision())
443
399
        self.log('pending merges: %s', a.working_tree().pending_merges())
444
400
        self.assertEquals(a.working_tree().pending_merges(),
445
401
                          [b.last_revision()])
598
554
                  'subdir/b\n'
599
555
                  , '--versioned')
600
556
 
 
557
    def test_cat(self):
 
558
        self.runbzr('init')
 
559
        file("myfile", "wb").write("My contents\n")
 
560
        self.runbzr('add')
 
561
        self.runbzr('commit -m myfile')
 
562
        self.run_bzr_captured('cat -r 1 myfile'.split(' '))
 
563
 
601
564
    def test_pull_verbose(self):
602
565
        """Pull changes from one branch to another and watch the output."""
603
566
 
825
788
        self.runbzr('commit -m done',)
826
789
        self.runbzr('remerge', retcode=3)
827
790
 
 
791
    def test_status(self):
 
792
        os.mkdir('branch1')
 
793
        os.chdir('branch1')
 
794
        self.runbzr('init')
 
795
        self.runbzr('commit --unchanged --message f')
 
796
        self.runbzr('branch . ../branch2')
 
797
        self.runbzr('branch . ../branch3')
 
798
        self.runbzr('commit --unchanged --message peter')
 
799
        os.chdir('../branch2')
 
800
        self.runbzr('merge ../branch1')
 
801
        self.runbzr('commit --unchanged --message pumpkin')
 
802
        os.chdir('../branch3')
 
803
        self.runbzr('merge ../branch2')
 
804
        message = self.capture('status')
 
805
 
828
806
 
829
807
    def test_conflicts(self):
830
808
        """Handling of merge conflicts"""
866
844
            from bzrlib.testament import Testament
867
845
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
868
846
            self.runbzr('re-sign -r revid:A')
869
 
            self.assertEqual(Testament.from_revision(branch,'A').as_short_text(),
870
 
                             branch.revision_store.get('A', 'sig').read())
 
847
            self.assertEqual(Testament.from_revision(branch.repository,
 
848
                             'A').as_short_text(),
 
849
                             branch.repository.revision_store.get('A', 
 
850
                             'sig').read())
871
851
        finally:
872
852
            bzrlib.gpg.GPGStrategy = oldstrategy
873
853
            
883
863
            from bzrlib.testament import Testament
884
864
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
885
865
            self.runbzr('re-sign -r 1..')
886
 
            self.assertEqual(Testament.from_revision(branch,'A').as_short_text(),
887
 
                             branch.revision_store.get('A', 'sig').read())
888
 
            self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
889
 
                             branch.revision_store.get('B', 'sig').read())
890
 
            self.assertEqual(Testament.from_revision(branch,'C').as_short_text(),
891
 
                             branch.revision_store.get('C', 'sig').read())
 
866
            self.assertEqual(
 
867
                Testament.from_revision(branch.repository,'A').as_short_text(),
 
868
                branch.repository.revision_store.get('A', 'sig').read())
 
869
            self.assertEqual(
 
870
                Testament.from_revision(branch.repository,'B').as_short_text(),
 
871
                branch.repository.revision_store.get('B', 'sig').read())
 
872
            self.assertEqual(Testament.from_revision(branch.repository,
 
873
                             'C').as_short_text(),
 
874
                             branch.repository.revision_store.get('C', 
 
875
                             'sig').read())
892
876
        finally:
893
877
            bzrlib.gpg.GPGStrategy = oldstrategy
894
878
 
1287
1271
        url = self.get_remote_url('branch/file')
1288
1272
        output = self.capture('log %s' % url)
1289
1273
        self.assertEqual(8, len(output.split('\n')))
 
1274
        # FIXME: rbc 20051128 what is the remainder of this test testing?
 
1275
        # - it does not seem to be http specific.
 
1276
        copy = branch.clone('branch2')
 
1277
        branch.working_tree().commit(message='empty commit')
 
1278
        os.chdir('branch2')
 
1279
        self.run_bzr('merge', '../branch')
 
1280
        copy.working_tree().commit(message='merge')
 
1281
        output = self.capture('log')
1290
1282
        
1291
1283
    def test_check(self):
1292
1284
        self.build_tree(['branch/', 'branch/file'])