123
123
self.runbzr('revert')
126
def test_mv_modes(self):
127
"""Test two modes of operation for mv"""
129
self.build_tree(['a', 'c', 'subdir/'])
130
self.run_bzr_captured(['add', self.test_dir])
131
self.run_bzr_captured(['mv', 'a', 'b'])
132
self.run_bzr_captured(['mv', 'b', 'subdir'])
133
self.run_bzr_captured(['mv', 'subdir/b', 'a'])
134
self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
135
self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
137
126
def test_main_version(self):
138
127
"""Check output from version command and master option is reasonable"""
139
128
# output is intentionally passed through to stdout so that we
526
515
out = capture("help ci")
527
516
out.index('aliases: ')
529
progress("can't rename unversioned file")
530
runbzr("rename test.txt new-test.txt", 3)
532
progress("adding a file")
534
runbzr("add test.txt")
535
self.assertEquals(capture("unknowns"), '')
537
progress("rename newly-added file")
538
runbzr("rename test.txt hello.txt")
539
self.assert_(os.path.exists("hello.txt"))
540
self.assert_(not os.path.exists("test.txt"))
542
self.assertEquals(capture("revno"), '0\n')
544
progress("add first revision")
545
runbzr(['commit', '-m', 'add first revision'])
547
progress("more complex renames")
549
runbzr("rename hello.txt sub1", 3)
550
runbzr("rename hello.txt sub1/hello.txt", 3)
551
runbzr("move hello.txt sub1", 3)
554
runbzr("rename sub1 sub2")
555
runbzr("move hello.txt sub2")
556
self.assertEqual(capture("relpath sub2/hello.txt"),
557
pathjoin("sub2", "hello.txt\n"))
559
self.assert_(exists("sub2"))
560
self.assert_(exists("sub2/hello.txt"))
561
self.assert_(not exists("sub1"))
562
self.assert_(not exists("hello.txt"))
564
runbzr(['commit', '-m', 'commit with some things moved to subdirs'])
568
runbzr('move sub2/hello.txt sub1')
569
self.assert_(not exists('sub2/hello.txt'))
570
self.assert_(exists('sub1/hello.txt'))
571
runbzr('move sub2 sub1')
572
self.assert_(not exists('sub2'))
573
self.assert_(exists('sub1/sub2'))
575
runbzr(['commit', '-m', 'rename nested subdirectories'])
578
self.assertEquals(capture('root')[:-1],
579
pathjoin(self.test_dir, 'branch1'))
580
runbzr('move ../hello.txt .')
581
self.assert_(exists('./hello.txt'))
582
self.assertEquals(capture('relpath hello.txt'),
583
pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
584
self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
585
runbzr(['commit', '-m', 'move to parent directory'])
587
self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
589
runbzr('move sub2/hello.txt .')
590
self.assert_(exists('hello.txt'))
592
518
f = file('hello.txt', 'wt')
593
519
f.write('some nice new content\n')
522
runbzr("add hello.txt")
596
524
f = file('msg.tmp', 'wt')
597
525
f.write('this is my new commit\nand it has multiple lines, for fun')
600
528
runbzr('commit -F msg.tmp')
602
self.assertEquals(capture('revno'), '5\n')
603
runbzr('export -r 5 export-5.tmp')
530
self.assertEquals(capture('revno'), '1\n')
531
runbzr('export -r 1 export-1.tmp')
604
532
runbzr('export export.tmp')