46
44
self.assertEquals('modified:\n dir/file\n', self.capture('status'))
48
def _prepare_rename_mod_tree(self):
49
self.build_tree(['a/', 'a/b', 'a/c', 'a/d/', 'a/d/e', 'f/', 'f/g',
53
self.run_bzr('commit', '-m', '1')
54
wt = WorkingTree.open('.')
55
wt.rename_one('a/b', 'f/b')
56
wt.rename_one('a/d/e', 'f/e')
57
wt.rename_one('a/d', 'f/d')
58
wt.rename_one('f/g', 'a/g')
59
wt.rename_one('f/h', 'h')
60
wt.rename_one('f', 'j')
62
46
def helper(self, param=''):
63
47
self._prepare_tree()
88
72
self.assertEqual('', self.capture('status'))
89
73
self.runbzr('revert')
90
74
self.assertEqual('', self.capture('status'))
92
def test_revert_dirname(self):
93
"""Test that revert DIRECTORY does what's expected"""
94
self._prepare_rename_mod_tree()
95
self.run_bzr('revert', 'a')
96
self.failUnlessExists('a/b')
97
self.failUnlessExists('a/d')
98
self.failIfExists('a/g')
99
self.failUnlessExists('j')
100
self.failUnlessExists('h')
101
self.run_bzr('revert', 'f')
102
self.failIfExists('j')
103
self.failIfExists('h')
104
self.failUnlessExists('a/d/e')
106
def test_revert(self):
109
file('hello', 'wt').write('foo')
110
self.run_bzr('add', 'hello')
111
self.run_bzr('commit', '-m', 'setup', 'hello')
113
file('goodbye', 'wt').write('baz')
114
self.run_bzr('add', 'goodbye')
115
self.run_bzr('commit', '-m', 'setup', 'goodbye')
117
file('hello', 'wt').write('bar')
118
file('goodbye', 'wt').write('qux')
119
self.run_bzr('revert', 'hello')
120
self.check_file_contents('hello', 'foo')
121
self.check_file_contents('goodbye', 'qux')
122
self.run_bzr('revert')
123
self.check_file_contents('goodbye', 'baz')
125
os.mkdir('revertdir')
126
self.run_bzr('add', 'revertdir')
127
self.run_bzr('commit', '-m', 'f')
128
os.rmdir('revertdir')
129
self.run_bzr('revert')
131
if bzrlib.osutils.has_symlinks():
132
os.symlink('/unlikely/to/exist', 'symlink')
133
self.run_bzr('add', 'symlink')
134
self.run_bzr('commit', '-m', 'f')
136
self.run_bzr('revert')
137
self.failUnlessExists('symlink')
139
os.symlink('a-different-path', 'symlink')
140
self.run_bzr('revert')
141
self.assertEqual('/unlikely/to/exist',
142
os.readlink('symlink'))
144
self.log("skipping revert symlink tests")
146
file('hello', 'wt').write('xyz')
147
self.run_bzr('commit', '-m', 'xyz', 'hello')
148
self.run_bzr('revert', '-r', '1', 'hello')
149
self.check_file_contents('hello', 'foo')
150
self.run_bzr('revert', 'hello')
151
self.check_file_contents('hello', 'xyz')
152
os.chdir('revertdir')
153
self.run_bzr('revert')