147
147
self.runbzr('revert')
150
def test_mv_modes(self):
151
"""Test two modes of operation for mv"""
153
self.build_tree(['a', 'c', 'subdir/'])
154
self.run_bzr_captured(['add', self.test_dir])
155
self.run_bzr_captured(['mv', 'a', 'b'])
156
self.run_bzr_captured(['mv', 'b', 'subdir'])
157
self.run_bzr_captured(['mv', 'subdir/b', 'a'])
158
self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
159
self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
161
150
def test_main_version(self):
162
151
"""Check output from version command and master option is reasonable"""
163
152
# output is intentionally passed through to stdout so that we
677
666
out = capture("help ci")
678
667
out.index('aliases: ')
680
progress("can't rename unversioned file")
681
runbzr("rename test.txt new-test.txt", 3)
683
progress("adding a file")
685
runbzr("add test.txt")
686
self.assertEquals(capture("unknowns"), '')
688
progress("rename newly-added file")
689
runbzr("rename test.txt hello.txt")
690
self.assert_(os.path.exists("hello.txt"))
691
self.assert_(not os.path.exists("test.txt"))
693
self.assertEquals(capture("revno"), '0\n')
695
progress("add first revision")
696
runbzr(['commit', '-m', 'add first revision'])
698
progress("more complex renames")
700
runbzr("rename hello.txt sub1", 3)
701
runbzr("rename hello.txt sub1/hello.txt", 3)
702
runbzr("move hello.txt sub1", 3)
705
runbzr("rename sub1 sub2")
706
runbzr("move hello.txt sub2")
707
self.assertEqual(capture("relpath sub2/hello.txt"),
708
pathjoin("sub2", "hello.txt\n"))
710
self.assert_(exists("sub2"))
711
self.assert_(exists("sub2/hello.txt"))
712
self.assert_(not exists("sub1"))
713
self.assert_(not exists("hello.txt"))
715
runbzr(['commit', '-m', 'commit with some things moved to subdirs'])
719
runbzr('move sub2/hello.txt sub1')
720
self.assert_(not exists('sub2/hello.txt'))
721
self.assert_(exists('sub1/hello.txt'))
722
runbzr('move sub2 sub1')
723
self.assert_(not exists('sub2'))
724
self.assert_(exists('sub1/sub2'))
726
runbzr(['commit', '-m', 'rename nested subdirectories'])
729
self.assertEquals(capture('root')[:-1],
730
pathjoin(self.test_dir, 'branch1'))
731
runbzr('move ../hello.txt .')
732
self.assert_(exists('./hello.txt'))
733
self.assertEquals(capture('relpath hello.txt'),
734
pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
735
self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
736
runbzr(['commit', '-m', 'move to parent directory'])
738
self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
740
runbzr('move sub2/hello.txt .')
741
self.assert_(exists('hello.txt'))
743
669
f = file('hello.txt', 'wt')
744
670
f.write('some nice new content\n')
673
runbzr("add hello.txt")
747
675
f = file('msg.tmp', 'wt')
748
676
f.write('this is my new commit\nand it has multiple lines, for fun')
751
679
runbzr('commit -F msg.tmp')
753
self.assertEquals(capture('revno'), '5\n')
754
runbzr('export -r 5 export-5.tmp')
681
self.assertEquals(capture('revno'), '1\n')
682
runbzr('export -r 1 export-1.tmp')
755
683
runbzr('export export.tmp')