116
116
"""Check output from version command and master option is reasonable"""
117
117
# output is intentionally passed through to stdout so that we
118
118
# can see the version being tested
119
output = self.run_bzr_captured(['version'])[0]
119
output = self.run_bzr(['version'])[0]
120
120
self.log('bzr version output:')
122
122
self.assert_(output.startswith('Bazaar (bzr) '))
123
123
self.assertNotEqual(output.index('Canonical'), -1)
124
124
# make sure --version is consistent
125
tmp_output = self.run_bzr_captured(['--version'])[0]
125
tmp_output = self.run_bzr(['--version'])[0]
126
126
self.assertEquals(output, tmp_output)
128
128
def example_branch(test):
396
396
f.write('hello world!\n')
399
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'test.txt\n')
399
self.assertEquals(self.run_bzr('unknowns')[0], 'test.txt\n')
401
out = self.run_bzr_captured("status")[0]
401
out = self.run_bzr("status")[0]
402
402
self.assertEquals(out, 'unknown:\n test.txt\n')
404
404
f = file('test2.txt', 'wt')
405
405
f.write('goodbye cruel world...\n')
408
out = self.run_bzr_captured("status test.txt")[0]
408
out = self.run_bzr("status test.txt")[0]
409
409
self.assertEquals(out, "unknown:\n test.txt\n")
411
out = self.run_bzr_captured("status")[0]
411
out = self.run_bzr("status")[0]
412
412
self.assertEquals(out, ("unknown:\n" " test.txt\n" " test2.txt\n"))
414
414
os.unlink('test2.txt')
416
416
progress("command aliases")
417
out = self.run_bzr_captured("st")[0]
417
out = self.run_bzr("st")[0]
418
418
self.assertEquals(out, ("unknown:\n" " test.txt\n"))
420
out = self.run_bzr_captured("stat")[0]
420
out = self.run_bzr("stat")[0]
421
421
self.assertEquals(out, ("unknown:\n" " test.txt\n"))
423
423
progress("command help")
449
449
self.run_bzr('log -v')
450
450
self.run_bzr('log -v --forward')
451
451
self.run_bzr('log -m', retcode=3)
452
log_out = self.run_bzr_captured('log -m commit')[0]
452
log_out = self.run_bzr('log -m commit')[0]
453
453
self.assert_("this is my new commit\n and" in log_out)
454
454
self.assert_("rename nested" not in log_out)
455
455
self.assert_('revision-id' not in log_out)
456
self.assert_('revision-id' in self.run_bzr_captured('log --show-ids -m commit')[0])
456
self.assert_('revision-id' in self.run_bzr('log --show-ids -m commit')[0])
458
log_out = self.run_bzr_captured('log --line')[0]
458
log_out = self.run_bzr('log --line')[0]
459
459
# determine the widest line we want
460
460
max_width = terminal_width() - 1
461
461
for line in log_out.splitlines():
483
483
self.run_bzr('init')
484
484
os.symlink("NOWHERE1", "link1")
485
485
self.run_bzr('add link1')
486
self.assertEquals(self.run_bzr_captured('unknowns')[0], '')
487
self.run_bzr_captured(['commit', '-m', '1: added symlink link1'])
486
self.assertEquals(self.run_bzr('unknowns')[0], '')
487
self.run_bzr(['commit', '-m', '1: added symlink link1'])
490
490
self.run_bzr('add d1')
491
self.assertEquals(self.run_bzr_captured('unknowns')[0], '')
491
self.assertEquals(self.run_bzr('unknowns')[0], '')
492
492
os.symlink("NOWHERE2", "d1/link2")
493
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'd1/link2\n')
493
self.assertEquals(self.run_bzr('unknowns')[0], 'd1/link2\n')
494
494
# is d1/link2 found when adding d1
495
495
self.run_bzr('add d1')
496
self.assertEquals(self.run_bzr_captured('unknowns')[0], '')
496
self.assertEquals(self.run_bzr('unknowns')[0], '')
497
497
os.symlink("NOWHERE3", "d1/link3")
498
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'd1/link3\n')
499
self.run_bzr_captured(['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'])
501
501
self.run_bzr('rename d1 d2')
502
502
self.run_bzr('move d2/link2 .')
505
505
self.assertEquals(os.readlink("d2/link1"), "NOWHERE1")
506
506
self.run_bzr('add d2/link3')
507
507
self.run_bzr('diff', retcode=1)
508
self.run_bzr_captured(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
508
self.run_bzr(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
510
510
os.unlink("link2")
511
511
os.symlink("TARGET 2", "link2")
512
512
os.unlink("d2/link1")
513
513
os.symlink("TARGET 1", "d2/link1")
514
514
self.run_bzr('diff', retcode=1)
515
self.assertEquals(self.run_bzr_captured("relpath d2/link1")[0], "d2/link1\n")
516
self.run_bzr_captured(['commit', '-m', '4: retarget of two links'])
515
self.assertEquals(self.run_bzr("relpath d2/link1")[0], "d2/link1\n")
516
self.run_bzr(['commit', '-m', '4: retarget of two links'])
518
518
self.run_bzr('remove --keep d2/link1')
519
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'd2/link1\n')
520
self.run_bzr_captured(['commit', '-m', '5: remove d2/link1'])
519
self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
520
self.run_bzr(['commit', '-m', '5: remove d2/link1'])
521
521
# try with the rm alias
522
522
self.run_bzr('add d2/link1')
523
self.run_bzr_captured(['commit', '-m', '6: add d2/link1'])
523
self.run_bzr(['commit', '-m', '6: add d2/link1'])
524
524
self.run_bzr('rm --keep d2/link1')
525
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'd2/link1\n')
526
self.run_bzr_captured(['commit', '-m', '7: remove d2/link1'])
525
self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
526
self.run_bzr(['commit', '-m', '7: remove d2/link1'])
529
529
self.run_bzr('add d1')
530
530
self.run_bzr('rename d2/link3 d1/link3new')
531
self.assertEquals(self.run_bzr_captured('unknowns')[0], 'd2/link1\n')
532
self.run_bzr_captured(['commit', '-m', '8: remove d2/link1, move/rename link3'])
534
self.run_bzr_captured(['check'])
536
self.run_bzr_captured(['export', '-r', '1', 'exp1.tmp'])
531
self.assertEquals(self.run_bzr('unknowns')[0], 'd2/link1\n')
532
self.run_bzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
534
self.run_bzr(['check'])
536
self.run_bzr(['export', '-r', '1', 'exp1.tmp'])
537
537
chdir("exp1.tmp")
538
538
self.assertEquals(listdir_sorted("."), [ "link1" ])
539
539
self.assertEquals(os.readlink("link1"), "NOWHERE1")
542
self.run_bzr_captured(['export', '-r', '2', 'exp2.tmp'])
542
self.run_bzr(['export', '-r', '2', 'exp2.tmp'])
543
543
chdir("exp2.tmp")
544
544
self.assertEquals(listdir_sorted("."), [ "d1", "link1" ])
547
self.run_bzr_captured(['export', '-r', '3', 'exp3.tmp'])
547
self.run_bzr(['export', '-r', '3', 'exp3.tmp'])
548
548
chdir("exp3.tmp")
549
549
self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
550
550
self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
560
560
self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
563
self.run_bzr_captured(['export', '-r', '5', 'exp5.tmp'])
563
self.run_bzr(['export', '-r', '5', 'exp5.tmp'])
564
564
chdir("exp5.tmp")
565
565
self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
566
566
self.assert_(os.path.islink("link2"))
567
567
self.assert_(listdir_sorted("d2")== [ "link3" ])
570
self.run_bzr_captured(['export', '-r', '8', 'exp6.tmp'])
570
self.run_bzr(['export', '-r', '8', 'exp6.tmp'])
571
571
chdir("exp6.tmp")
572
572
self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
573
573
self.assertEquals(listdir_sorted("d1"), [ "link3new" ])
596
596
def test_log(self):
597
597
self.build_tree(['branch/', 'branch/file'])
598
self.run_bzr_captured('init branch')[0]
599
self.run_bzr_captured('add branch/file')[0]
600
self.run_bzr_captured('commit -m foo branch')[0]
598
self.run_bzr('init branch')[0]
599
self.run_bzr('add branch/file')[0]
600
self.run_bzr('commit -m foo branch')[0]
601
601
url = self.get_readonly_url('branch/file')
602
output = self.run_bzr_captured('log %s' % url)[0]
602
output = self.run_bzr('log %s' % url)[0]
603
603
self.assertEqual(8, len(output.split('\n')))
605
605
def test_check(self):
606
606
self.build_tree(['branch/', 'branch/file'])
607
self.run_bzr_captured('init branch')[0]
608
self.run_bzr_captured('add branch/file')[0]
609
self.run_bzr_captured('commit -m foo branch')[0]
607
self.run_bzr('init branch')[0]
608
self.run_bzr('add branch/file')[0]
609
self.run_bzr('commit -m foo branch')[0]
610
610
url = self.get_readonly_url('branch/')
611
611
self.run_bzr('check', url)