/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: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
2
 
# -*- coding: utf-8 -*-
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
3
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
40
39
import sys
41
40
 
42
41
import bzrlib
 
42
from bzrlib import (
 
43
    osutils,
 
44
    )
43
45
from bzrlib.branch import Branch
44
 
import bzrlib.bzrdir as bzrdir
45
46
from bzrlib.errors import BzrCommandError
46
47
from bzrlib.osutils import (
47
48
    has_symlinks,
48
49
    pathjoin,
49
 
    rmtree,
50
50
    terminal_width,
51
51
    )
52
52
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
57
57
 
58
58
class TestCommands(ExternalBase):
59
59
 
60
 
    def test_nick_command(self):
61
 
        """bzr nick for viewing, setting nicknames"""
62
 
        os.mkdir('me.dev')
63
 
        os.chdir('me.dev')
64
 
        self.runbzr('init')
65
 
        nick = self.runbzr("nick",backtick=True)
66
 
        self.assertEqual(nick, 'me.dev\n')
67
 
        nick = self.runbzr("nick moo")
68
 
        nick = self.runbzr("nick",backtick=True)
69
 
        self.assertEqual(nick, 'moo\n')
70
 
 
71
60
    def test_invalid_commands(self):
72
 
        self.runbzr("pants", retcode=3)
73
 
        self.runbzr("--pants off", retcode=3)
74
 
        self.runbzr("diff --message foo", retcode=3)
 
61
        self.run_bzr("pants", retcode=3)
 
62
        self.run_bzr("--pants off", retcode=3)
 
63
        self.run_bzr("diff --message foo", retcode=3)
75
64
 
76
65
    def test_revert(self):
77
 
        self.runbzr('init')
 
66
        self.run_bzr('init')
78
67
 
79
68
        file('hello', 'wt').write('foo')
80
 
        self.runbzr('add hello')
81
 
        self.runbzr('commit -m setup hello')
 
69
        self.run_bzr('add hello')
 
70
        self.run_bzr('commit -m setup hello')
82
71
 
83
72
        file('goodbye', 'wt').write('baz')
84
 
        self.runbzr('add goodbye')
85
 
        self.runbzr('commit -m setup goodbye')
 
73
        self.run_bzr('add goodbye')
 
74
        self.run_bzr('commit -m setup goodbye')
86
75
 
87
76
        file('hello', 'wt').write('bar')
88
77
        file('goodbye', 'wt').write('qux')
89
 
        self.runbzr('revert hello')
 
78
        self.run_bzr('revert hello')
90
79
        self.check_file_contents('hello', 'foo')
91
80
        self.check_file_contents('goodbye', 'qux')
92
 
        self.runbzr('revert')
 
81
        self.run_bzr('revert')
93
82
        self.check_file_contents('goodbye', 'baz')
94
83
 
95
84
        os.mkdir('revertdir')
96
 
        self.runbzr('add revertdir')
97
 
        self.runbzr('commit -m f')
 
85
        self.run_bzr('add revertdir')
 
86
        self.run_bzr('commit -m f')
98
87
        os.rmdir('revertdir')
99
 
        self.runbzr('revert')
 
88
        self.run_bzr('revert')
100
89
 
101
90
        if has_symlinks():
102
91
            os.symlink('/unlikely/to/exist', 'symlink')
103
 
            self.runbzr('add symlink')
104
 
            self.runbzr('commit -m f')
 
92
            self.run_bzr('add symlink')
 
93
            self.run_bzr('commit -m f')
105
94
            os.unlink('symlink')
106
 
            self.runbzr('revert')
 
95
            self.run_bzr('revert')
107
96
            self.failUnlessExists('symlink')
108
97
            os.unlink('symlink')
109
98
            os.symlink('a-different-path', 'symlink')
110
 
            self.runbzr('revert')
 
99
            self.run_bzr('revert')
111
100
            self.assertEqual('/unlikely/to/exist',
112
101
                             os.readlink('symlink'))
113
102
        else:
114
103
            self.log("skipping revert symlink tests")
115
104
        
116
105
        file('hello', 'wt').write('xyz')
117
 
        self.runbzr('commit -m xyz hello')
118
 
        self.runbzr('revert -r 1 hello')
 
106
        self.run_bzr('commit -m xyz hello')
 
107
        self.run_bzr('revert -r 1 hello')
119
108
        self.check_file_contents('hello', 'foo')
120
 
        self.runbzr('revert hello')
 
109
        self.run_bzr('revert hello')
121
110
        self.check_file_contents('hello', 'xyz')
122
111
        os.chdir('revertdir')
123
 
        self.runbzr('revert')
 
112
        self.run_bzr('revert')
124
113
        os.chdir('..')
125
114
 
126
115
    def test_main_version(self):
127
116
        """Check output from version command and master option is reasonable"""
128
117
        # output is intentionally passed through to stdout so that we
129
118
        # can see the version being tested
130
 
        output = self.runbzr('version', backtick=1)
 
119
        output = self.run_bzr(['version'])[0]
131
120
        self.log('bzr version output:')
132
121
        self.log(output)
133
122
        self.assert_(output.startswith('Bazaar (bzr) '))
134
123
        self.assertNotEqual(output.index('Canonical'), -1)
135
124
        # make sure --version is consistent
136
 
        tmp_output = self.runbzr('--version', backtick=1)
137
 
        self.log('bzr --version output:')
138
 
        self.log(tmp_output)
 
125
        tmp_output = self.run_bzr(['--version'])[0]
139
126
        self.assertEquals(output, tmp_output)
140
127
 
141
128
    def example_branch(test):
142
 
        test.runbzr('init')
 
129
        test.run_bzr('init')
143
130
        file('hello', 'wt').write('foo')
144
 
        test.runbzr('add hello')
145
 
        test.runbzr('commit -m setup hello')
 
131
        test.run_bzr('add hello')
 
132
        test.run_bzr('commit -m setup hello')
146
133
        file('goodbye', 'wt').write('baz')
147
 
        test.runbzr('add goodbye')
148
 
        test.runbzr('commit -m setup goodbye')
 
134
        test.run_bzr('add goodbye')
 
135
        test.run_bzr('commit -m setup goodbye')
149
136
 
150
137
    def test_pull_verbose(self):
151
138
        """Pull changes from one branch to another and watch the output."""
153
140
        os.mkdir('a')
154
141
        os.chdir('a')
155
142
 
156
 
        bzr = self.runbzr
157
143
        self.example_branch()
158
144
 
159
145
        os.chdir('..')
160
 
        bzr('branch a b')
 
146
        self.run_bzr('branch a b')
161
147
        os.chdir('b')
162
148
        open('b', 'wb').write('else\n')
163
 
        bzr('add b')
164
 
        bzr(['commit', '-m', 'added b'])
 
149
        self.run_bzr('add b')
 
150
        self.run_bzr(['commit', '-m', 'added b'])
165
151
 
166
152
        os.chdir('../a')
167
 
        out = bzr('pull --verbose ../b', backtick=True)
 
153
        out = self.run_bzr('pull --verbose ../b')[0]
168
154
        self.failIfEqual(out.find('Added Revisions:'), -1)
169
155
        self.failIfEqual(out.find('message:\n  added b'), -1)
170
156
        self.failIfEqual(out.find('added b'), -1)
171
157
 
172
158
        # Check that --overwrite --verbose prints out the removed entries
173
 
        bzr('commit -m foo --unchanged')
 
159
        self.run_bzr('commit -m foo --unchanged')
174
160
        os.chdir('../b')
175
 
        bzr('commit -m baz --unchanged')
176
 
        bzr('pull ../a', retcode=3)
177
 
        out = bzr('pull --overwrite --verbose ../a', backtick=1)
 
161
        self.run_bzr('commit -m baz --unchanged')
 
162
        self.run_bzr('pull ../a', retcode=3)
 
163
        out = self.run_bzr('pull --overwrite --verbose ../a')[0]
178
164
 
179
165
        remove_loc = out.find('Removed Revisions:')
180
166
        self.failIfEqual(remove_loc, -1)
193
179
        """Using and remembering different locations"""
194
180
        os.mkdir('a')
195
181
        os.chdir('a')
196
 
        self.runbzr('init')
197
 
        self.runbzr('commit -m unchanged --unchanged')
198
 
        self.runbzr('pull', retcode=3)
199
 
        self.runbzr('merge', retcode=3)
200
 
        self.runbzr('branch . ../b')
 
182
        self.run_bzr('init')
 
183
        self.run_bzr('commit -m unchanged --unchanged')
 
184
        self.run_bzr('pull', retcode=3)
 
185
        self.run_bzr('merge', retcode=3)
 
186
        self.run_bzr('branch . ../b')
201
187
        os.chdir('../b')
202
 
        self.runbzr('pull')
203
 
        self.runbzr('branch . ../c')
204
 
        self.runbzr('pull ../c')
205
 
        self.runbzr('merge')
 
188
        self.run_bzr('pull')
 
189
        self.run_bzr('branch . ../c')
 
190
        self.run_bzr('pull ../c')
 
191
        self.run_bzr('merge')
206
192
        os.chdir('../a')
207
 
        self.runbzr('pull ../b')
208
 
        self.runbzr('pull')
209
 
        self.runbzr('pull ../c')
210
 
        self.runbzr('branch ../c ../d')
211
 
        rmtree('../c')
212
 
        self.runbzr('pull')
 
193
        self.run_bzr('pull ../b')
 
194
        self.run_bzr('pull')
 
195
        self.run_bzr('pull ../c')
 
196
        self.run_bzr('branch ../c ../d')
 
197
        osutils.rmtree('../c')
 
198
        self.run_bzr('pull')
213
199
        os.chdir('../b')
214
 
        self.runbzr('pull')
 
200
        self.run_bzr('pull')
215
201
        os.chdir('../d')
216
 
        self.runbzr('pull', retcode=3)
217
 
        self.runbzr('pull ../a --remember')
218
 
        self.runbzr('pull')
 
202
        self.run_bzr('pull', retcode=3)
 
203
        self.run_bzr('pull ../a --remember')
 
204
        self.run_bzr('pull')
219
205
        
220
206
    def test_unknown_command(self):
221
207
        """Handling of unknown command."""
222
 
        out, err = self.run_bzr_captured(['fluffy-badger'],
 
208
        out, err = self.run_bzr(['fluffy-badger'],
223
209
                                         retcode=3)
224
210
        self.assertEquals(out, '')
225
211
        err.index('unknown command')
230
216
        os.chdir('base')
231
217
        file('hello', 'wb').write("hi world")
232
218
        file('answer', 'wb').write("42")
233
 
        self.runbzr('init')
234
 
        self.runbzr('add')
235
 
        self.runbzr('commit -m base')
236
 
        self.runbzr('branch . ../other')
237
 
        self.runbzr('branch . ../this')
 
219
        self.run_bzr('init')
 
220
        self.run_bzr('add')
 
221
        self.run_bzr('commit -m base')
 
222
        self.run_bzr('branch . ../other')
 
223
        self.run_bzr('branch . ../this')
238
224
        os.chdir('../other')
239
225
        file('hello', 'wb').write("Hello.")
240
226
        file('answer', 'wb').write("Is anyone there?")
241
 
        self.runbzr('commit -m other')
 
227
        self.run_bzr('commit -m other')
242
228
        os.chdir('../this')
243
229
        file('hello', 'wb').write("Hello, world")
244
 
        self.runbzr('mv answer question')
 
230
        self.run_bzr('mv answer question')
245
231
        file('question', 'wb').write("What do you get when you multiply six"
246
232
                                   "times nine?")
247
 
        self.runbzr('commit -m this')
 
233
        self.run_bzr('commit -m this')
248
234
 
249
235
    def test_status(self):
250
236
        os.mkdir('branch1')
251
237
        os.chdir('branch1')
252
 
        self.runbzr('init')
253
 
        self.runbzr('commit --unchanged --message f')
254
 
        self.runbzr('branch . ../branch2')
255
 
        self.runbzr('branch . ../branch3')
256
 
        self.runbzr('commit --unchanged --message peter')
 
238
        self.run_bzr('init')
 
239
        self.run_bzr('commit --unchanged --message f')
 
240
        self.run_bzr('branch . ../branch2')
 
241
        self.run_bzr('branch . ../branch3')
 
242
        self.run_bzr('commit --unchanged --message peter')
257
243
        os.chdir('../branch2')
258
 
        self.runbzr('merge ../branch1')
259
 
        self.runbzr('commit --unchanged --message pumpkin')
 
244
        self.run_bzr('merge ../branch1')
 
245
        self.run_bzr('commit --unchanged --message pumpkin')
260
246
        os.chdir('../branch3')
261
 
        self.runbzr('merge ../branch2')
262
 
        message = self.capture('status')
 
247
        self.run_bzr('merge ../branch2')
 
248
        message = self.run_bzr('status')[0]
263
249
 
264
250
 
265
251
    def test_conflicts(self):
266
252
        """Handling of merge conflicts"""
267
253
        self.create_conflicts()
268
 
        self.runbzr('merge ../other --show-base', retcode=1)
 
254
        self.run_bzr('merge ../other --show-base', retcode=1)
269
255
        conflict_text = file('hello').read()
270
256
        self.assert_('<<<<<<<' in conflict_text)
271
257
        self.assert_('>>>>>>>' in conflict_text)
272
258
        self.assert_('=======' in conflict_text)
273
259
        self.assert_('|||||||' in conflict_text)
274
260
        self.assert_('hi world' in conflict_text)
275
 
        self.runbzr('revert')
276
 
        self.runbzr('resolve --all')
277
 
        self.runbzr('merge ../other', retcode=1)
 
261
        self.run_bzr('revert')
 
262
        self.run_bzr('resolve --all')
 
263
        self.run_bzr('merge ../other', retcode=1)
278
264
        conflict_text = file('hello').read()
279
265
        self.assert_('|||||||' not in conflict_text)
280
266
        self.assert_('hi world' not in conflict_text)
281
 
        result = self.runbzr('conflicts', backtick=1)
 
267
        result = self.run_bzr('conflicts')[0]
282
268
        self.assertEquals(result, "Text conflict in hello\nText conflict in"
283
269
                                  " question\n")
284
 
        result = self.runbzr('status', backtick=1)
 
270
        result = self.run_bzr('status')[0]
285
271
        self.assert_("conflicts:\n  Text conflict in hello\n"
286
272
                     "  Text conflict in question\n" in result, result)
287
 
        self.runbzr('resolve hello')
288
 
        result = self.runbzr('conflicts', backtick=1)
 
273
        self.run_bzr('resolve hello')
 
274
        result = self.run_bzr('conflicts')[0]
289
275
        self.assertEquals(result, "Text conflict in question\n")
290
 
        self.runbzr('commit -m conflicts', retcode=3)
291
 
        self.runbzr('resolve --all')
292
 
        result = self.runbzr('conflicts', backtick=1)
293
 
        self.runbzr('commit -m conflicts')
 
276
        self.run_bzr('commit -m conflicts', retcode=3)
 
277
        self.run_bzr('resolve --all')
 
278
        result = self.run_bzr('conflicts')[0]
 
279
        self.run_bzr('commit -m conflicts')
294
280
        self.assertEquals(result, "")
295
281
 
296
282
    def test_push(self):
300
286
        self.example_branch()
301
287
 
302
288
        # with no push target, fail
303
 
        self.runbzr('push', retcode=3)
 
289
        self.run_bzr('push', retcode=3)
304
290
        # with an explicit target work
305
 
        self.runbzr('push ../output-branch')
 
291
        self.run_bzr('push ../output-branch')
306
292
        # with an implicit target work
307
 
        self.runbzr('push')
 
293
        self.run_bzr('push')
308
294
        # nothing missing
309
 
        self.runbzr('missing ../output-branch')
 
295
        self.run_bzr('missing ../output-branch')
310
296
        # advance this branch
311
 
        self.runbzr('commit --unchanged -m unchanged')
 
297
        self.run_bzr('commit --unchanged -m unchanged')
312
298
 
313
299
        os.chdir('../output-branch')
314
300
        # There is no longer a difference as long as we have
315
301
        # access to the working tree
316
 
        self.runbzr('diff')
 
302
        self.run_bzr('diff')
317
303
 
318
304
        # But we should be missing a revision
319
 
        self.runbzr('missing ../my-branch', retcode=1)
 
305
        self.run_bzr('missing ../my-branch', retcode=1)
320
306
 
321
307
        # diverge the branches
322
 
        self.runbzr('commit --unchanged -m unchanged')
 
308
        self.run_bzr('commit --unchanged -m unchanged')
323
309
        os.chdir('../my-branch')
324
310
        # cannot push now
325
 
        self.runbzr('push', retcode=3)
 
311
        self.run_bzr('push', retcode=3)
326
312
        # and there are difference
327
 
        self.runbzr('missing ../output-branch', retcode=1)
328
 
        self.runbzr('missing --verbose ../output-branch', retcode=1)
 
313
        self.run_bzr('missing ../output-branch', retcode=1)
 
314
        self.run_bzr('missing --verbose ../output-branch', retcode=1)
329
315
        # but we can force a push
330
 
        self.runbzr('push --overwrite')
 
316
        self.run_bzr('push --overwrite')
331
317
        # nothing missing
332
 
        self.runbzr('missing ../output-branch')
 
318
        self.run_bzr('missing ../output-branch')
333
319
        
334
320
        # pushing to a new dir with no parent should fail
335
 
        self.runbzr('push ../missing/new-branch', retcode=3)
 
321
        self.run_bzr('push ../missing/new-branch', retcode=3)
336
322
        # unless we provide --create-prefix
337
 
        self.runbzr('push --create-prefix ../missing/new-branch')
 
323
        self.run_bzr('push --create-prefix ../missing/new-branch')
338
324
        # nothing missing
339
 
        self.runbzr('missing ../missing/new-branch')
 
325
        self.run_bzr('missing ../missing/new-branch')
340
326
 
341
327
    def test_external_command(self):
342
328
        """Test that external commands can be run by setting the path
349
335
        if sys.platform == 'win32':
350
336
            cmd_name += '.bat'
351
337
        oldpath = os.environ.get('BZRPATH', None)
352
 
        bzr = self.capture
353
338
        try:
354
339
            if 'BZRPATH' in os.environ:
355
340
                del os.environ['BZRPATH']
365
350
 
366
351
            # It should not find the command in the local 
367
352
            # directory by default, since it is not in my path
368
 
            bzr(cmd_name, retcode=3)
 
353
            self.run_bzr(cmd_name, retcode=3)
369
354
 
370
355
            # Now put it into my path
371
356
            os.environ['BZRPATH'] = '.'
372
357
 
373
 
            bzr(cmd_name)
 
358
            self.run_bzr(cmd_name)
374
359
 
375
360
            # Make sure empty path elements are ignored
376
361
            os.environ['BZRPATH'] = os.pathsep
377
362
 
378
 
            bzr(cmd_name, retcode=3)
 
363
            self.run_bzr(cmd_name, retcode=3)
379
364
 
380
365
        finally:
381
366
            if oldpath:
395
380
        from os import chdir, mkdir
396
381
        from os.path import exists
397
382
 
398
 
        runbzr = self.runbzr
399
 
        capture = self.capture
400
383
        progress = self.log
401
384
 
402
385
        progress("basic branch creation")
403
386
        mkdir('branch1')
404
387
        chdir('branch1')
405
 
        runbzr('init')
 
388
        self.run_bzr('init')
406
389
 
407
 
        self.assertEquals(capture('root').rstrip(),
 
390
        self.assertEquals(self.run_bzr('root')[0].rstrip(),
408
391
                          pathjoin(self.test_dir, 'branch1'))
409
392
 
410
393
        progress("status of new file")
413
396
        f.write('hello world!\n')
414
397
        f.close()
415
398
 
416
 
        self.assertEquals(capture('unknowns'), 'test.txt\n')
 
399
        self.assertEquals(self.run_bzr('unknowns')[0], 'test.txt\n')
417
400
 
418
 
        out = capture("status")
 
401
        out = self.run_bzr("status")[0]
419
402
        self.assertEquals(out, 'unknown:\n  test.txt\n')
420
403
 
421
404
        f = file('test2.txt', 'wt')
422
405
        f.write('goodbye cruel world...\n')
423
406
        f.close()
424
407
 
425
 
        out = capture("status test.txt")
 
408
        out = self.run_bzr("status test.txt")[0]
426
409
        self.assertEquals(out, "unknown:\n  test.txt\n")
427
410
 
428
 
        out = capture("status")
 
411
        out = self.run_bzr("status")[0]
429
412
        self.assertEquals(out, ("unknown:\n" "  test.txt\n" "  test2.txt\n"))
430
413
 
431
414
        os.unlink('test2.txt')
432
415
 
433
416
        progress("command aliases")
434
 
        out = capture("st")
 
417
        out = self.run_bzr("st")[0]
435
418
        self.assertEquals(out, ("unknown:\n" "  test.txt\n"))
436
419
 
437
 
        out = capture("stat")
 
420
        out = self.run_bzr("stat")[0]
438
421
        self.assertEquals(out, ("unknown:\n" "  test.txt\n"))
439
422
 
440
423
        progress("command help")
441
 
        runbzr("help st")
442
 
        runbzr("help")
443
 
        runbzr("help commands")
444
 
        runbzr("help slartibartfast", 3)
 
424
        self.run_bzr("help st")
 
425
        self.run_bzr("help")
 
426
        self.run_bzr("help commands")
 
427
        self.run_bzr("help slartibartfast", retcode=3)
445
428
 
446
 
        out = capture("help ci")
447
 
        out.index('aliases: ')
 
429
        out = self.run_bzr("help ci")[0]
 
430
        out.index('aliases: ci, checkin\n')
448
431
 
449
432
        f = file('hello.txt', 'wt')
450
433
        f.write('some nice new content\n')
451
434
        f.close()
452
435
 
453
 
        runbzr("add hello.txt")
 
436
        self.run_bzr("add hello.txt")
454
437
        
455
438
        f = file('msg.tmp', 'wt')
456
439
        f.write('this is my new commit\nand it has multiple lines, for fun')
457
440
        f.close()
458
441
 
459
 
        runbzr('commit -F msg.tmp')
460
 
 
461
 
        self.assertEquals(capture('revno'), '1\n')
462
 
        runbzr('export -r 1 export-1.tmp')
463
 
        runbzr('export export.tmp')
464
 
 
465
 
        runbzr('log')
466
 
        runbzr('log -v')
467
 
        runbzr('log -v --forward')
468
 
        runbzr('log -m', retcode=3)
469
 
        log_out = capture('log -m commit')
 
442
        self.run_bzr('commit -F msg.tmp')
 
443
 
 
444
        self.assertEquals(self.run_bzr('revno')[0], '1\n')
 
445
        self.run_bzr('export -r 1 export-1.tmp')
 
446
        self.run_bzr('export export.tmp')
 
447
 
 
448
        self.run_bzr('log')
 
449
        self.run_bzr('log -v')
 
450
        self.run_bzr('log -v --forward')
 
451
        self.run_bzr('log -m', retcode=3)
 
452
        log_out = self.run_bzr('log -m commit')[0]
470
453
        self.assert_("this is my new commit\n  and" in log_out)
471
454
        self.assert_("rename nested" not in log_out)
472
455
        self.assert_('revision-id' not in log_out)
473
 
        self.assert_('revision-id' in capture('log --show-ids -m commit'))
 
456
        self.assert_('revision-id' in self.run_bzr('log --show-ids -m commit')[0])
474
457
 
475
 
        log_out = capture('log --line')
 
458
        log_out = self.run_bzr('log --line')[0]
476
459
        # determine the widest line we want
477
460
        max_width = terminal_width() - 1
478
461
        for line in log_out.splitlines():
483
466
        progress("file with spaces in name")
484
467
        mkdir('sub directory')
485
468
        file('sub directory/file with spaces ', 'wt').write('see how this works\n')
486
 
        runbzr('add .')
487
 
        runbzr('diff', retcode=1)
488
 
        runbzr('commit -m add-spaces')
489
 
        runbzr('check')
490
 
 
491
 
        runbzr('log')
492
 
        runbzr('log --forward')
493
 
 
494
 
        runbzr('info')
 
469
        self.run_bzr('add .')
 
470
        self.run_bzr('diff', retcode=1)
 
471
        self.run_bzr('commit -m add-spaces')
 
472
        self.run_bzr('check')
 
473
 
 
474
        self.run_bzr('log')
 
475
        self.run_bzr('log --forward')
 
476
 
 
477
        self.run_bzr('info')
495
478
 
496
479
        if has_symlinks():
497
480
            progress("symlinks")
498
481
            mkdir('symlinks')
499
482
            chdir('symlinks')
500
 
            runbzr('init')
 
483
            self.run_bzr('init')
501
484
            os.symlink("NOWHERE1", "link1")
502
 
            runbzr('add link1')
503
 
            self.assertEquals(self.capture('unknowns'), '')
504
 
            runbzr(['commit', '-m', '1: added symlink link1'])
 
485
            self.run_bzr('add link1')
 
486
            self.assertEquals(self.run_bzr('unknowns')[0], '')
 
487
            self.run_bzr(['commit', '-m', '1: added symlink link1'])
505
488
    
506
489
            mkdir('d1')
507
 
            runbzr('add d1')
508
 
            self.assertEquals(self.capture('unknowns'), '')
 
490
            self.run_bzr('add d1')
 
491
            self.assertEquals(self.run_bzr('unknowns')[0], '')
509
492
            os.symlink("NOWHERE2", "d1/link2")
510
 
            self.assertEquals(self.capture('unknowns'), 'd1/link2\n')
 
493
            self.assertEquals(self.run_bzr('unknowns')[0], 'd1/link2\n')
511
494
            # is d1/link2 found when adding d1
512
 
            runbzr('add d1')
513
 
            self.assertEquals(self.capture('unknowns'), '')
 
495
            self.run_bzr('add d1')
 
496
            self.assertEquals(self.run_bzr('unknowns')[0], '')
514
497
            os.symlink("NOWHERE3", "d1/link3")
515
 
            self.assertEquals(self.capture('unknowns'), 'd1/link3\n')
516
 
            runbzr(['commit', '-m', '2: added dir, symlink'])
 
498
            self.assertEquals(self.run_bzr('unknowns')[0], 'd1/link3\n')
 
499
            self.run_bzr(['commit', '-m', '2: added dir, symlink'])
517
500
    
518
 
            runbzr('rename d1 d2')
519
 
            runbzr('move d2/link2 .')
520
 
            runbzr('move link1 d2')
 
501
            self.run_bzr('rename d1 d2')
 
502
            self.run_bzr('move d2/link2 .')
 
503
            self.run_bzr('move link1 d2')
521
504
            self.assertEquals(os.readlink("./link2"), "NOWHERE2")
522
505
            self.assertEquals(os.readlink("d2/link1"), "NOWHERE1")
523
 
            runbzr('add d2/link3')
524
 
            runbzr('diff', retcode=1)
525
 
            runbzr(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
 
506
            self.run_bzr('add d2/link3')
 
507
            self.run_bzr('diff', retcode=1)
 
508
            self.run_bzr(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
526
509
    
527
510
            os.unlink("link2")
528
511
            os.symlink("TARGET 2", "link2")
529
512
            os.unlink("d2/link1")
530
513
            os.symlink("TARGET 1", "d2/link1")
531
 
            runbzr('diff', retcode=1)
532
 
            self.assertEquals(self.capture("relpath d2/link1"), "d2/link1\n")
533
 
            runbzr(['commit', '-m', '4: retarget of two links'])
 
514
            self.run_bzr('diff', retcode=1)
 
515
            self.assertEquals(self.run_bzr("relpath d2/link1")[0], "d2/link1\n")
 
516
            self.run_bzr(['commit', '-m', '4: retarget of two links'])
534
517
    
535
 
            runbzr('remove d2/link1')
536
 
            self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
537
 
            runbzr(['commit', '-m', '5: remove d2/link1'])
 
518
            self.run_bzr('remove --keep d2/link1')
 
519
            self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
 
520
            self.run_bzr(['commit', '-m', '5: remove d2/link1'])
538
521
            # try with the rm alias
539
 
            runbzr('add d2/link1')
540
 
            runbzr(['commit', '-m', '6: add d2/link1'])
541
 
            runbzr('rm d2/link1')
542
 
            self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
543
 
            runbzr(['commit', '-m', '7: remove d2/link1'])
 
522
            self.run_bzr('add d2/link1')
 
523
            self.run_bzr(['commit', '-m', '6: add d2/link1'])
 
524
            self.run_bzr('rm --keep d2/link1')
 
525
            self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
 
526
            self.run_bzr(['commit', '-m', '7: remove d2/link1'])
544
527
    
545
528
            os.mkdir("d1")
546
 
            runbzr('add d1')
547
 
            runbzr('rename d2/link3 d1/link3new')
548
 
            self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
549
 
            runbzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
550
 
            
551
 
            runbzr(['check'])
552
 
            
553
 
            runbzr(['export', '-r', '1', 'exp1.tmp'])
 
529
            self.run_bzr('add d1')
 
530
            self.run_bzr('rename d2/link3 d1/link3new')
 
531
            self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
 
532
            self.run_bzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
 
533
            
 
534
            self.run_bzr(['check'])
 
535
            
 
536
            self.run_bzr(['export', '-r', '1', 'exp1.tmp'])
554
537
            chdir("exp1.tmp")
555
538
            self.assertEquals(listdir_sorted("."), [ "link1" ])
556
539
            self.assertEquals(os.readlink("link1"), "NOWHERE1")
557
540
            chdir("..")
558
541
            
559
 
            runbzr(['export', '-r', '2', 'exp2.tmp'])
 
542
            self.run_bzr(['export', '-r', '2', 'exp2.tmp'])
560
543
            chdir("exp2.tmp")
561
544
            self.assertEquals(listdir_sorted("."), [ "d1", "link1" ])
562
545
            chdir("..")
563
546
            
564
 
            runbzr(['export', '-r', '3', 'exp3.tmp'])
 
547
            self.run_bzr(['export', '-r', '3', 'exp3.tmp'])
565
548
            chdir("exp3.tmp")
566
549
            self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
567
550
            self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
569
552
            self.assertEquals(os.readlink("link2")   , "NOWHERE2")
570
553
            chdir("..")
571
554
            
572
 
            runbzr(['export', '-r', '4', 'exp4.tmp'])
 
555
            self.run_bzr(['export', '-r', '4', 'exp4.tmp'])
573
556
            chdir("exp4.tmp")
574
557
            self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
575
558
            self.assertEquals(os.readlink("d2/link1"), "TARGET 1")
577
560
            self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
578
561
            chdir("..")
579
562
            
580
 
            runbzr(['export', '-r', '5', 'exp5.tmp'])
 
563
            self.run_bzr(['export', '-r', '5', 'exp5.tmp'])
581
564
            chdir("exp5.tmp")
582
565
            self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
583
566
            self.assert_(os.path.islink("link2"))
584
567
            self.assert_(listdir_sorted("d2")== [ "link3" ])
585
568
            chdir("..")
586
569
            
587
 
            runbzr(['export', '-r', '8', 'exp6.tmp'])
 
570
            self.run_bzr(['export', '-r', '8', 'exp6.tmp'])
588
571
            chdir("exp6.tmp")
589
572
            self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
590
573
            self.assertEquals(listdir_sorted("d1"), [ "link3new" ])
612
595
 
613
596
    def test_log(self):
614
597
        self.build_tree(['branch/', 'branch/file'])
615
 
        self.capture('init branch')
616
 
        self.capture('add branch/file')
617
 
        self.capture('commit -m foo branch')
 
598
        self.run_bzr('init branch')[0]
 
599
        self.run_bzr('add branch/file')[0]
 
600
        self.run_bzr('commit -m foo branch')[0]
618
601
        url = self.get_readonly_url('branch/file')
619
 
        output = self.capture('log %s' % url)
 
602
        output = self.run_bzr('log %s' % url)[0]
620
603
        self.assertEqual(8, len(output.split('\n')))
621
604
        
622
605
    def test_check(self):
623
606
        self.build_tree(['branch/', 'branch/file'])
624
 
        self.capture('init branch')
625
 
        self.capture('add branch/file')
626
 
        self.capture('commit -m foo branch')
 
607
        self.run_bzr('init branch')[0]
 
608
        self.run_bzr('add branch/file')[0]
 
609
        self.run_bzr('commit -m foo branch')[0]
627
610
        url = self.get_readonly_url('branch/')
628
611
        self.run_bzr('check', url)
629
612