/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: Jan Balster
  • Date: 2006-08-15 12:39:42 UTC
  • mfrom: (1923 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: jan@merlinux.de-20060815123942-22c388c6e9a8ac91
merge bzr.dev 1923

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
 
 
 
3
#
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
6
6
# the Free Software Foundation; either version 2 of the License, or
7
7
# (at your option) any later version.
8
 
 
 
8
#
9
9
# This program is distributed in the hope that it will be useful,
10
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
12
# GNU General Public License for more details.
13
 
 
 
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
57
57
 
58
58
class TestCommands(ExternalBase):
59
59
 
60
 
    def test_whoami(self):
61
 
        # this should always identify something, if only "john@localhost"
62
 
        self.runbzr("whoami")
63
 
        self.runbzr("whoami --email")
64
 
 
65
 
        self.assertEquals(self.runbzr("whoami --email",
66
 
                                      backtick=True).count('@'), 1)
67
 
        
68
 
    def test_whoami_branch(self):
69
 
        """branch specific user identity works."""
70
 
        self.runbzr('init')
71
 
        b = bzrlib.branch.Branch.open('.')
72
 
        b.control_files.put_utf8('email', 'Branch Identity <branch@identi.ty>')
73
 
        bzr_email = os.environ.get('BZREMAIL')
74
 
        if bzr_email is not None:
75
 
            del os.environ['BZREMAIL']
76
 
        whoami = self.runbzr("whoami",backtick=True)
77
 
        whoami_email = self.runbzr("whoami --email",backtick=True)
78
 
        self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
79
 
        self.assertTrue(whoami_email.startswith('branch@identi.ty'))
80
 
        # Verify that the environment variable overrides the value 
81
 
        # in the file
82
 
        os.environ['BZREMAIL'] = 'Different ID <other@environ.ment>'
83
 
        whoami = self.runbzr("whoami",backtick=True)
84
 
        whoami_email = self.runbzr("whoami --email",backtick=True)
85
 
        self.assertTrue(whoami.startswith('Different ID <other@environ.ment>'))
86
 
        self.assertTrue(whoami_email.startswith('other@environ.ment'))
87
 
        if bzr_email is not None:
88
 
            os.environ['BZREMAIL'] = bzr_email
89
 
 
90
60
    def test_nick_command(self):
91
61
        """bzr nick for viewing, setting nicknames"""
92
62
        os.mkdir('me.dev')
103
73
        self.runbzr("--pants off", retcode=3)
104
74
        self.runbzr("diff --message foo", retcode=3)
105
75
 
106
 
    def test_ignore_patterns(self):
107
 
        self.runbzr('init')
108
 
        self.assertEquals(self.capture('unknowns'), '')
109
 
 
110
 
        file('foo.tmp', 'wt').write('tmp files are ignored')
111
 
        self.assertEquals(self.capture('unknowns'), '')
112
 
 
113
 
        file('foo.c', 'wt').write('int main() {}')
114
 
        self.assertEquals(self.capture('unknowns'), 'foo.c\n')
115
 
 
116
 
        self.runbzr(['add', 'foo.c'])
117
 
        self.assertEquals(self.capture('unknowns'), '')
118
 
 
119
 
        # 'ignore' works when creating the .bzignore file
120
 
        file('foo.blah', 'wt').write('blah')
121
 
        self.assertEquals(self.capture('unknowns'), 'foo.blah\n')
122
 
        self.runbzr('ignore *.blah')
123
 
        self.assertEquals(self.capture('unknowns'), '')
124
 
        self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\n')
125
 
 
126
 
        # 'ignore' works when then .bzrignore file already exists
127
 
        file('garh', 'wt').write('garh')
128
 
        self.assertEquals(self.capture('unknowns'), 'garh\n')
129
 
        self.runbzr('ignore garh')
130
 
        self.assertEquals(self.capture('unknowns'), '')
131
 
        self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\ngarh\n')
132
 
 
133
76
    def test_revert(self):
134
77
        self.runbzr('init')
135
78
 
180
123
        self.runbzr('revert')
181
124
        os.chdir('..')
182
125
 
183
 
    def test_mv_modes(self):
184
 
        """Test two modes of operation for mv"""
185
 
        self.runbzr('init')
186
 
        self.build_tree(['a', 'c', 'subdir/'])
187
 
        self.run_bzr_captured(['add', self.test_dir])
188
 
        self.run_bzr_captured(['mv', 'a', 'b'])
189
 
        self.run_bzr_captured(['mv', 'b', 'subdir'])
190
 
        self.run_bzr_captured(['mv', 'subdir/b', 'a'])
191
 
        self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
192
 
        self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
193
 
 
194
126
    def test_main_version(self):
195
127
        """Check output from version command and master option is reasonable"""
196
128
        # output is intentionally passed through to stdout so that we
198
130
        output = self.runbzr('version', backtick=1)
199
131
        self.log('bzr version output:')
200
132
        self.log(output)
201
 
        self.assert_(output.startswith('bzr (bazaar-ng) '))
 
133
        self.assert_(output.startswith('Bazaar (bzr) '))
202
134
        self.assertNotEqual(output.index('Canonical'), -1)
203
135
        # make sure --version is consistent
204
136
        tmp_output = self.runbzr('--version', backtick=1)
282
214
        bzr('commit -m add')
283
215
 
284
216
        output_equals('a\n', '--kind', 'file')
285
 
        output_equals('b\n', '--kind', 'directory')        
286
 
 
287
 
    def test_ls(self):
288
 
        """Test the abilities of 'bzr ls'"""
289
 
        bzr = self.runbzr
290
 
        def bzrout(*args, **kwargs):
291
 
            kwargs['backtick'] = True
292
 
            return self.runbzr(*args, **kwargs)
293
 
 
294
 
        def ls_equals(value, *args):
295
 
            out = self.runbzr(['ls'] + list(args), backtick=True)
296
 
            self.assertEquals(out, value)
297
 
 
298
 
        bzr('init')
299
 
        open('a', 'wb').write('hello\n')
300
 
 
301
 
        # Can't supply both
302
 
        bzr('ls --verbose --null', retcode=3)
303
 
 
304
 
        ls_equals('a\n')
305
 
        ls_equals('?        a\n', '--verbose')
306
 
        ls_equals('a\n', '--unknown')
307
 
        ls_equals('', '--ignored')
308
 
        ls_equals('', '--versioned')
309
 
        ls_equals('a\n', '--unknown', '--ignored', '--versioned')
310
 
        ls_equals('', '--ignored', '--versioned')
311
 
        ls_equals('a\0', '--null')
312
 
 
313
 
        bzr('add a')
314
 
        ls_equals('V        a\n', '--verbose')
315
 
        bzr('commit -m add')
316
 
        
317
 
        os.mkdir('subdir')
318
 
        ls_equals('V        a\n'
319
 
                  '?        subdir/\n'
320
 
                  , '--verbose')
321
 
        open('subdir/b', 'wb').write('b\n')
322
 
        bzr('add')
323
 
        ls_equals('V        a\n'
324
 
                  'V        subdir/\n'
325
 
                  'V        subdir/b\n'
326
 
                  , '--verbose')
327
 
        bzr('commit -m subdir')
328
 
 
329
 
        ls_equals('a\n'
330
 
                  'subdir\n'
331
 
                  , '--non-recursive')
332
 
 
333
 
        ls_equals('V        a\n'
334
 
                  'V        subdir/\n'
335
 
                  , '--verbose', '--non-recursive')
336
 
 
337
 
        # Check what happens in a sub-directory
338
 
        os.chdir('subdir')
339
 
        ls_equals('b\n')
340
 
        ls_equals('b\0'
341
 
                  , '--null')
342
 
        ls_equals('a\n'
343
 
                  'subdir\n'
344
 
                  'subdir/b\n'
345
 
                  , '--from-root')
346
 
        ls_equals('a\0'
347
 
                  'subdir\0'
348
 
                  'subdir/b\0'
349
 
                  , '--from-root', '--null')
350
 
        ls_equals('a\n'
351
 
                  'subdir\n'
352
 
                  , '--from-root', '--non-recursive')
353
 
 
354
 
        os.chdir('..')
355
 
 
356
 
        # Check what happens when we supply a specific revision
357
 
        ls_equals('a\n', '--revision', '1')
358
 
        ls_equals('V        a\n'
359
 
                  , '--verbose', '--revision', '1')
360
 
 
361
 
        os.chdir('subdir')
362
 
        ls_equals('', '--revision', '1')
363
 
 
364
 
        # Now try to do ignored files.
365
 
        os.chdir('..')
366
 
        open('blah.py', 'wb').write('unknown\n')
367
 
        open('blah.pyo', 'wb').write('ignored\n')
368
 
        ls_equals('a\n'
369
 
                  'blah.py\n'
370
 
                  'blah.pyo\n'
371
 
                  'subdir\n'
372
 
                  'subdir/b\n')
373
 
        ls_equals('V        a\n'
374
 
                  '?        blah.py\n'
375
 
                  'I        blah.pyo\n'
376
 
                  'V        subdir/\n'
377
 
                  'V        subdir/b\n'
378
 
                  , '--verbose')
379
 
        ls_equals('blah.pyo\n'
380
 
                  , '--ignored')
381
 
        ls_equals('blah.py\n'
382
 
                  , '--unknown')
383
 
        ls_equals('a\n'
384
 
                  'subdir\n'
385
 
                  'subdir/b\n'
386
 
                  , '--versioned')
387
 
 
388
 
    def test_cat(self):
389
 
        self.runbzr('init')
390
 
        file("myfile", "wb").write("My contents\n")
391
 
        self.runbzr('add')
392
 
        self.runbzr('commit -m myfile')
393
 
        self.run_bzr_captured('cat -r 1 myfile'.split(' '))
 
217
        output_equals('b\n', '--kind', 'directory')
394
218
 
395
219
    def test_pull_verbose(self):
396
220
        """Pull changes from one branch to another and watch the output."""
491
315
                                   "times nine?")
492
316
        self.runbzr('commit -m this')
493
317
 
494
 
    def test_remerge(self):
495
 
        """Remerge command works as expected"""
496
 
        self.create_conflicts()
497
 
        self.runbzr('merge ../other --show-base', retcode=1)
498
 
        conflict_text = file('hello').read()
499
 
        assert '|||||||' in conflict_text
500
 
        assert 'hi world' in conflict_text
501
 
        self.runbzr('remerge', retcode=1)
502
 
        conflict_text = file('hello').read()
503
 
        assert '|||||||' not in conflict_text
504
 
        assert 'hi world' not in conflict_text
505
 
        os.unlink('hello.OTHER')
506
 
        os.unlink('question.OTHER')
507
 
        self.runbzr('remerge jello --merge-type weave', retcode=3)
508
 
        self.runbzr('remerge hello --merge-type weave', retcode=1)
509
 
        assert os.path.exists('hello.OTHER')
510
 
        self.assertIs(False, os.path.exists('question.OTHER'))
511
 
        file_id = self.runbzr('file-id hello')
512
 
        file_id = self.runbzr('file-id hello.THIS', retcode=3)
513
 
        self.runbzr('remerge --merge-type weave', retcode=1)
514
 
        assert os.path.exists('hello.OTHER')
515
 
        assert not os.path.exists('hello.BASE')
516
 
        assert '|||||||' not in conflict_text
517
 
        assert 'hi world' not in conflict_text
518
 
        self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
519
 
        self.runbzr('remerge . --show-base --reprocess', retcode=3)
520
 
        self.runbzr('remerge . --merge-type weave --reprocess', retcode=1)
521
 
        self.runbzr('remerge hello --show-base', retcode=1)
522
 
        self.runbzr('remerge hello --reprocess', retcode=1)
523
 
        self.runbzr('resolve --all')
524
 
        self.runbzr('commit -m done',)
525
 
        self.runbzr('remerge', retcode=3)
526
 
 
527
318
    def test_status(self):
528
319
        os.mkdir('branch1')
529
320
        os.chdir('branch1')
724
515
        out = capture("help ci")
725
516
        out.index('aliases: ')
726
517
 
727
 
        progress("can't rename unversioned file")
728
 
        runbzr("rename test.txt new-test.txt", 3)
729
 
 
730
 
        progress("adding a file")
731
 
 
732
 
        runbzr("add test.txt")
733
 
        self.assertEquals(capture("unknowns"), '')
734
 
 
735
 
        progress("rename newly-added file")
736
 
        runbzr("rename test.txt hello.txt")
737
 
        self.assert_(os.path.exists("hello.txt"))
738
 
        self.assert_(not os.path.exists("test.txt"))
739
 
 
740
 
        self.assertEquals(capture("revno"), '0\n')
741
 
 
742
 
        progress("add first revision")
743
 
        runbzr(['commit', '-m', 'add first revision'])
744
 
 
745
 
        progress("more complex renames")
746
 
        os.mkdir("sub1")
747
 
        runbzr("rename hello.txt sub1", 3)
748
 
        runbzr("rename hello.txt sub1/hello.txt", 3)
749
 
        runbzr("move hello.txt sub1", 3)
750
 
 
751
 
        runbzr("add sub1")
752
 
        runbzr("rename sub1 sub2")
753
 
        runbzr("move hello.txt sub2")
754
 
        self.assertEqual(capture("relpath sub2/hello.txt"),
755
 
                         pathjoin("sub2", "hello.txt\n"))
756
 
 
757
 
        self.assert_(exists("sub2"))
758
 
        self.assert_(exists("sub2/hello.txt"))
759
 
        self.assert_(not exists("sub1"))
760
 
        self.assert_(not exists("hello.txt"))
761
 
 
762
 
        runbzr(['commit', '-m', 'commit with some things moved to subdirs'])
763
 
 
764
 
        mkdir("sub1")
765
 
        runbzr('add sub1')
766
 
        runbzr('move sub2/hello.txt sub1')
767
 
        self.assert_(not exists('sub2/hello.txt'))
768
 
        self.assert_(exists('sub1/hello.txt'))
769
 
        runbzr('move sub2 sub1')
770
 
        self.assert_(not exists('sub2'))
771
 
        self.assert_(exists('sub1/sub2'))
772
 
 
773
 
        runbzr(['commit', '-m', 'rename nested subdirectories'])
774
 
 
775
 
        chdir('sub1/sub2')
776
 
        self.assertEquals(capture('root')[:-1],
777
 
                          pathjoin(self.test_dir, 'branch1'))
778
 
        runbzr('move ../hello.txt .')
779
 
        self.assert_(exists('./hello.txt'))
780
 
        self.assertEquals(capture('relpath hello.txt'),
781
 
                          pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
782
 
        self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
783
 
        runbzr(['commit', '-m', 'move to parent directory'])
784
 
        chdir('..')
785
 
        self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
786
 
 
787
 
        runbzr('move sub2/hello.txt .')
788
 
        self.assert_(exists('hello.txt'))
789
 
 
790
518
        f = file('hello.txt', 'wt')
791
519
        f.write('some nice new content\n')
792
520
        f.close()
793
521
 
 
522
        runbzr("add hello.txt")
 
523
        
794
524
        f = file('msg.tmp', 'wt')
795
525
        f.write('this is my new commit\nand it has multiple lines, for fun')
796
526
        f.close()
797
527
 
798
528
        runbzr('commit -F msg.tmp')
799
529
 
800
 
        self.assertEquals(capture('revno'), '5\n')
801
 
        runbzr('export -r 5 export-5.tmp')
 
530
        self.assertEquals(capture('revno'), '1\n')
 
531
        runbzr('export -r 1 export-1.tmp')
802
532
        runbzr('export export.tmp')
803
533
 
804
534
        runbzr('log')