/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: John Arbash Meinel
  • Date: 2007-06-28 23:18:09 UTC
  • mfrom: (2562 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070628231809-pqbt7puoqj8bl07b
[merge] bzr.dev 2562

Show diffs side-by-side

added added

removed removed

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