/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 bzrlib/tests/blackbox/test_too_much.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
from bzrlib.branch import Branch
44
44
import bzrlib.bzrdir as bzrdir
45
45
from bzrlib.errors import BzrCommandError
46
 
from bzrlib.osutils import has_symlinks, pathjoin, rmtree
 
46
from bzrlib.osutils import (
 
47
    has_symlinks,
 
48
    pathjoin,
 
49
    rmtree,
 
50
    terminal_width,
 
51
    )
47
52
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
48
53
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
49
54
from bzrlib.tests.blackbox import ExternalBase
98
103
        self.runbzr("--pants off", retcode=3)
99
104
        self.runbzr("diff --message foo", retcode=3)
100
105
 
101
 
    def test_remove_deleted(self):
102
 
        self.runbzr("init")
103
 
        self.build_tree(['a'])
104
 
        self.runbzr(['add', 'a'])
105
 
        self.runbzr(['commit', '-m', 'added a'])
106
 
        os.unlink('a')
107
 
        self.runbzr(['remove', 'a'])
108
 
 
109
106
    def test_ignore_patterns(self):
110
107
        self.runbzr('init')
111
108
        self.assertEquals(self.capture('unknowns'), '')
271
268
        zf = ZipFile('../first-zip')
272
269
        self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
273
270
 
274
 
    def test_branch(self):
275
 
        """Branch from one branch to another."""
276
 
        os.mkdir('a')
277
 
        os.chdir('a')
278
 
        self.example_branch()
279
 
        os.chdir('..')
280
 
        self.runbzr('branch a b')
281
 
        b = bzrlib.branch.Branch.open('b')
282
 
        self.assertEqual('b\n', b.control_files.get_utf8('branch-name').read())
283
 
        self.runbzr('branch a c -r 1')
284
 
        os.chdir('b')
285
 
        self.runbzr('commit -m foo --unchanged')
286
 
        os.chdir('..')
287
 
 
288
 
    def test_branch_basis(self):
289
 
        # ensure that basis really does grab from the basis by having incomplete source
290
 
        tree = self.make_branch_and_tree('commit_tree')
291
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
292
 
        tree.add('foo')
293
 
        tree.commit('revision 1', rev_id='1')
294
 
        source = self.make_branch_and_tree('source')
295
 
        # this gives us an incomplete repository
296
 
        tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
297
 
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
298
 
        tree.bzrdir.open_branch().copy_content_into(source.branch)
299
 
        tree.copy_content_into(source)
300
 
        self.assertFalse(source.branch.repository.has_revision('2'))
301
 
        dir = source.bzrdir
302
 
        self.runbzr('branch source target --basis commit_tree')
303
 
        target = bzrdir.BzrDir.open('target')
304
 
        self.assertEqual('2', target.open_branch().last_revision())
305
 
        self.assertEqual('2', target.open_workingtree().last_revision())
306
 
        self.assertTrue(target.open_branch().repository.has_revision('2'))
307
 
 
308
271
    def test_inventory(self):
309
272
        bzr = self.runbzr
310
273
        def output_equals(value, *args):
499
462
        self.runbzr('pull ../a --remember')
500
463
        self.runbzr('pull')
501
464
        
502
 
    def test_add_reports(self):
503
 
        """add command prints the names of added files."""
504
 
        self.runbzr('init')
505
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
506
 
        out = self.run_bzr_captured(['add'], retcode=0)[0]
507
 
        # the ordering is not defined at the moment
508
 
        results = sorted(out.rstrip('\n').split('\n'))
509
 
        self.assertEquals(['If you wish to add some of these files, please'\
510
 
                           ' add them by name.',
511
 
                           'added dir',
512
 
                           'added dir/sub.txt',
513
 
                           'added top.txt',
514
 
                           'ignored 1 file(s) matching "CVS"'],
515
 
                          results)
516
 
        out = self.run_bzr_captured(['add', '-v'], retcode=0)[0]
517
 
        results = sorted(out.rstrip('\n').split('\n'))
518
 
        self.assertEquals(['If you wish to add some of these files, please'\
519
 
                           ' add them by name.',
520
 
                           'ignored CVS matching "CVS"'],
521
 
                          results)
522
 
 
523
 
    def test_add_quiet_is(self):
524
 
        """add -q does not print the names of added files."""
525
 
        self.runbzr('init')
526
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
527
 
        out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
528
 
        # the ordering is not defined at the moment
529
 
        results = sorted(out.rstrip('\n').split('\n'))
530
 
        self.assertEquals([''], results)
531
 
 
532
 
    def test_add_in_unversioned(self):
533
 
        """Try to add a file in an unversioned directory.
534
 
 
535
 
        "bzr add" should add the parent(s) as necessary.
536
 
        """
537
 
        self.runbzr('init')
538
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
539
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
540
 
        self.run_bzr('add', 'inertiatic/esp')
541
 
        self.assertEquals(self.capture('unknowns'), '')
542
 
 
543
 
        # Multiple unversioned parents
544
 
        self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
545
 
        self.assertEquals(self.capture('unknowns'), 'veil\n')
546
 
        self.run_bzr('add', 'veil/cerpin/taxt')
547
 
        self.assertEquals(self.capture('unknowns'), '')
548
 
 
549
 
        # Check whacky paths work
550
 
        self.build_tree(['cicatriz/', 'cicatriz/esp'])
551
 
        self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
552
 
        self.run_bzr('add', 'inertiatic/../cicatriz/esp')
553
 
        self.assertEquals(self.capture('unknowns'), '')
554
 
 
555
 
    def test_add_in_versioned(self):
556
 
        """Try to add a file in a versioned directory.
557
 
 
558
 
        "bzr add" should do this happily.
559
 
        """
560
 
        self.runbzr('init')
561
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
562
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
563
 
        self.run_bzr('add', '--no-recurse', 'inertiatic')
564
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
565
 
        self.run_bzr('add', 'inertiatic/esp')
566
 
        self.assertEquals(self.capture('unknowns'), '')
567
 
 
568
 
    def test_subdir_add(self):
569
 
        """Add in subdirectory should add only things from there down"""
570
 
        from bzrlib.workingtree import WorkingTree
571
 
        
572
 
        eq = self.assertEqual
573
 
        ass = self.assert_
574
 
        chdir = os.chdir
575
 
        
576
 
        t = self.make_branch_and_tree('.')
577
 
        b = t.branch
578
 
        self.build_tree(['src/', 'README'])
579
 
        
580
 
        eq(sorted(t.unknowns()),
581
 
           ['README', 'src'])
582
 
        
583
 
        self.run_bzr('add', 'src')
584
 
        
585
 
        self.build_tree(['src/foo.c'])
586
 
        
587
 
        chdir('src')
588
 
        self.run_bzr('add')
589
 
        
590
 
        self.assertEquals(self.capture('unknowns'), 'README\n')
591
 
        eq(len(t.read_working_inventory()), 3)
592
 
                
593
 
        chdir('..')
594
 
        self.run_bzr('add')
595
 
        self.assertEquals(self.capture('unknowns'), '')
596
 
        self.run_bzr('check')
597
 
 
598
465
    def test_unknown_command(self):
599
466
        """Handling of unknown command."""
600
467
        out, err = self.run_bzr_captured(['fluffy-badger'],
952
819
        self.assert_('revision-id' in capture('log --show-ids -m commit'))
953
820
 
954
821
        log_out = capture('log --line')
 
822
        # determine the widest line we want
 
823
        max_width = terminal_width() - 1
955
824
        for line in log_out.splitlines():
956
 
            self.assert_(len(line) <= 79, len(line))
 
825
            self.assert_(len(line) <= max_width, len(line))
957
826
        self.assert_("this is my new commit and" in log_out)
958
827
 
959
 
 
960
828
        progress("file with spaces in name")
961
829
        mkdir('sub directory')
962
830
        file('sub directory/file with spaces ', 'wt').write('see how this works\n')