4763.2.4
by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry. |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
16 |
|
17 |
"""Test for 'bzr mv'"""
|
|
18 |
||
19 |
import os |
|
20 |
||
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
21 |
import bzrlib.branch |
2091.3.6
by Aaron Bentley
Add symlink test guards |
22 |
from bzrlib import ( |
23 |
osutils, |
|
24 |
workingtree, |
|
2158.2.1
by v.ladeuil+lp at free
Windows tests cleanup. |
25 |
)
|
2220.1.14
by Aaron Bentley
Cleanup formatting and error handling |
26 |
|
2158.2.1
by v.ladeuil+lp at free
Windows tests cleanup. |
27 |
from bzrlib.tests import ( |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
28 |
TestCaseWithTransport, |
29 |
)
|
|
30 |
from bzrlib.tests.features import ( |
|
3246.1.2
by Alexander Belchenko
test_mv_file_to_wrong_case_dir require feature CaseInsensitiveFilesystem |
31 |
CaseInsensitiveFilesystemFeature, |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
32 |
SymlinkFeature, |
5967.12.3
by Martin Pool
Unify duplicated UnicodeFilename and _PosixPermissionsFeature |
33 |
UnicodeFilenameFeature, |
2158.2.1
by v.ladeuil+lp at free
Windows tests cleanup. |
34 |
)
|
2220.1.14
by Aaron Bentley
Cleanup formatting and error handling |
35 |
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
36 |
|
37 |
class TestMove(TestCaseWithTransport): |
|
38 |
||
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
39 |
def assertMoved(self,from_path,to_path): |
40 |
"""Assert that to_path is existing and versioned but from_path not. """
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
41 |
self.assertPathDoesNotExist(from_path) |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
42 |
self.assertNotInWorkingTree(from_path) |
43 |
||
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
44 |
self.assertPathExists(to_path) |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
45 |
self.assertInWorkingTree(to_path) |
46 |
||
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
47 |
def test_mv_modes(self): |
48 |
"""Test two modes of operation for mv"""
|
|
49 |
tree = self.make_branch_and_tree('.') |
|
50 |
files = self.build_tree(['a', 'c', 'subdir/']) |
|
51 |
tree.add(['a', 'c', 'subdir']) |
|
52 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
53 |
self.run_bzr('mv a b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
54 |
self.assertMoved('a','b') |
1846.1.2
by Wouter van Heyst
test mv more rigorously |
55 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
56 |
self.run_bzr('mv b subdir') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
57 |
self.assertMoved('b','subdir/b') |
1846.1.2
by Wouter van Heyst
test mv more rigorously |
58 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
59 |
self.run_bzr('mv subdir/b a') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
60 |
self.assertMoved('subdir/b','a') |
1846.1.2
by Wouter van Heyst
test mv more rigorously |
61 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
62 |
self.run_bzr('mv a c subdir') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
63 |
self.assertMoved('a','subdir/a') |
64 |
self.assertMoved('c','subdir/c') |
|
1846.1.2
by Wouter van Heyst
test mv more rigorously |
65 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
66 |
self.run_bzr('mv subdir/a subdir/newa') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
67 |
self.assertMoved('subdir/a','subdir/newa') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
68 |
|
69 |
def test_mv_unversioned(self): |
|
70 |
self.build_tree(['unversioned.txt']) |
|
71 |
self.run_bzr_error( |
|
2206.1.8
by Marius Kruger
Converted move/rename error messages to show source => target. |
72 |
["^bzr: ERROR: Could not rename unversioned.txt => elsewhere." |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
73 |
" .*unversioned.txt is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
74 |
'mv unversioned.txt elsewhere') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
75 |
|
76 |
def test_mv_nonexisting(self): |
|
77 |
self.run_bzr_error( |
|
2206.1.8
by Marius Kruger
Converted move/rename error messages to show source => target. |
78 |
["^bzr: ERROR: Could not rename doesnotexist => somewhereelse." |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
79 |
" .*doesnotexist is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
80 |
'mv doesnotexist somewhereelse') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
81 |
|
82 |
def test_mv_unqualified(self): |
|
83 |
self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
84 |
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
85 |
def test_mv_invalid(self): |
86 |
tree = self.make_branch_and_tree('.') |
|
87 |
self.build_tree(['test.txt', 'sub1/']) |
|
88 |
tree.add(['test.txt']) |
|
89 |
||
90 |
self.run_bzr_error( |
|
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
91 |
["^bzr: ERROR: Could not move to sub1: sub1 is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
92 |
'mv test.txt sub1') |
2206.1.7
by Marius Kruger
* errors |
93 |
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
94 |
self.run_bzr_error( |
2206.1.9
by Marius Kruger
* Change move/rename errors yet again |
95 |
["^bzr: ERROR: Could not move test.txt => .*hello.txt: " |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
96 |
"sub1 is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
97 |
'mv test.txt sub1/hello.txt') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
98 |
|
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
99 |
def test_mv_dirs(self): |
100 |
tree = self.make_branch_and_tree('.') |
|
101 |
self.build_tree(['hello.txt', 'sub1/']) |
|
102 |
tree.add(['hello.txt', 'sub1']) |
|
103 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
104 |
self.run_bzr('mv sub1 sub2') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
105 |
self.assertMoved('sub1','sub2') |
106 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
107 |
self.run_bzr('mv hello.txt sub2') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
108 |
self.assertMoved('hello.txt','sub2/hello.txt') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
109 |
|
110 |
self.build_tree(['sub1/']) |
|
111 |
tree.add(['sub1']) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
112 |
self.run_bzr('mv sub2/hello.txt sub1') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
113 |
self.assertMoved('sub2/hello.txt','sub1/hello.txt') |
114 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
115 |
self.run_bzr('mv sub2 sub1') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
116 |
self.assertMoved('sub2','sub1/sub2') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
117 |
|
1846.1.2
by Wouter van Heyst
test mv more rigorously |
118 |
def test_mv_relative(self): |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
119 |
self.build_tree(['sub1/', 'sub1/sub2/', 'sub1/hello.txt']) |
120 |
tree = self.make_branch_and_tree('.') |
|
121 |
tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt']) |
|
122 |
||
123 |
os.chdir('sub1/sub2') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
124 |
self.run_bzr('mv ../hello.txt .') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
125 |
self.assertPathExists('./hello.txt') |
1846.1.1
by Wouter van Heyst
Don't fail on 'bzr mv', extract move tests from OldTests. |
126 |
|
127 |
os.chdir('..') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
128 |
self.run_bzr('mv sub2/hello.txt .') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
129 |
os.chdir('..') |
130 |
self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt') |
|
1846.1.2
by Wouter van Heyst
test mv more rigorously |
131 |
|
3246.1.1
by Alexander Belchenko
Allow rename (change case of name) directory on case-insensitive filesystem. |
132 |
def test_mv_change_case_file(self): |
2978.8.2
by Alexander Belchenko
teach fancy_rename to handle change case renames in possible case-insensitive filesystem |
133 |
# test for bug #77740 (mv unable change filename case on Windows)
|
2978.8.1
by Alexander Belchenko
Rename on Windows is able to change filename case. (#77740) |
134 |
tree = self.make_branch_and_tree('.') |
135 |
self.build_tree(['test.txt']) |
|
136 |
tree.add(['test.txt']) |
|
137 |
self.run_bzr('mv test.txt Test.txt') |
|
2978.8.2
by Alexander Belchenko
teach fancy_rename to handle change case renames in possible case-insensitive filesystem |
138 |
# we can't use failUnlessExists on case-insensitive filesystem
|
139 |
# so try to check shape of the tree
|
|
2978.8.1
by Alexander Belchenko
Rename on Windows is able to change filename case. (#77740) |
140 |
shape = sorted(os.listdir(u'.')) |
141 |
self.assertEqual(['.bzr', 'Test.txt'], shape) |
|
142 |
self.assertInWorkingTree('Test.txt') |
|
143 |
self.assertNotInWorkingTree('test.txt') |
|
144 |
||
3246.1.1
by Alexander Belchenko
Allow rename (change case of name) directory on case-insensitive filesystem. |
145 |
def test_mv_change_case_dir(self): |
146 |
tree = self.make_branch_and_tree('.') |
|
147 |
self.build_tree(['foo/']) |
|
148 |
tree.add(['foo']) |
|
149 |
self.run_bzr('mv foo Foo') |
|
150 |
# we can't use failUnlessExists on case-insensitive filesystem
|
|
151 |
# so try to check shape of the tree
|
|
152 |
shape = sorted(os.listdir(u'.')) |
|
153 |
self.assertEqual(['.bzr', 'Foo'], shape) |
|
154 |
self.assertInWorkingTree('Foo') |
|
155 |
self.assertNotInWorkingTree('foo') |
|
156 |
||
157 |
def test_mv_change_case_dir_w_files(self): |
|
158 |
tree = self.make_branch_and_tree('.') |
|
159 |
self.build_tree(['foo/', 'foo/bar']) |
|
160 |
tree.add(['foo']) |
|
161 |
self.run_bzr('mv foo Foo') |
|
162 |
# we can't use failUnlessExists on case-insensitive filesystem
|
|
163 |
# so try to check shape of the tree
|
|
164 |
shape = sorted(os.listdir(u'.')) |
|
165 |
self.assertEqual(['.bzr', 'Foo'], shape) |
|
166 |
self.assertInWorkingTree('Foo') |
|
167 |
self.assertNotInWorkingTree('foo') |
|
168 |
||
169 |
def test_mv_file_to_wrong_case_dir(self): |
|
3246.1.2
by Alexander Belchenko
test_mv_file_to_wrong_case_dir require feature CaseInsensitiveFilesystem |
170 |
self.requireFeature(CaseInsensitiveFilesystemFeature) |
3246.1.1
by Alexander Belchenko
Allow rename (change case of name) directory on case-insensitive filesystem. |
171 |
tree = self.make_branch_and_tree('.') |
172 |
self.build_tree(['foo/', 'bar']) |
|
173 |
tree.add(['foo', 'bar']) |
|
174 |
out, err = self.run_bzr('mv bar Foo', retcode=3) |
|
175 |
self.assertEquals('', out) |
|
176 |
self.assertEquals( |
|
177 |
'bzr: ERROR: Could not move to Foo: Foo is not versioned.\n', |
|
178 |
err) |
|
179 |
||
1846.1.2
by Wouter van Heyst
test mv more rigorously |
180 |
def test_mv_smoke_aliases(self): |
181 |
# just test that aliases for mv exist, if their behaviour is changed in
|
|
182 |
# the future, then extend the tests.
|
|
183 |
self.build_tree(['a']) |
|
184 |
tree = self.make_branch_and_tree('.') |
|
185 |
tree.add(['a']) |
|
186 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
187 |
self.run_bzr('move a b') |
188 |
self.run_bzr('rename b a') |
|
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
189 |
|
190 |
def test_mv_through_symlinks(self): |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
191 |
self.requireFeature(SymlinkFeature) |
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
192 |
tree = self.make_branch_and_tree('.') |
193 |
self.build_tree(['a/', 'a/b']) |
|
194 |
os.symlink('a', 'c') |
|
195 |
os.symlink('.', 'd') |
|
196 |
tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id']) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
197 |
self.run_bzr('mv c/b b') |
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
198 |
tree = workingtree.WorkingTree.open('.') |
199 |
self.assertEqual('b-id', tree.path2id('b')) |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
200 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
201 |
def test_mv_already_moved_file(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
202 |
"""Test bzr mv original_file to moved_file.
|
203 |
||
204 |
Tests if a file which has allready been moved by an external tool,
|
|
205 |
is handled correctly by bzr mv.
|
|
206 |
Setup: a is in the working tree, b does not exist.
|
|
207 |
User does: mv a b; bzr mv a b
|
|
208 |
"""
|
|
209 |
self.build_tree(['a']) |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
210 |
tree = self.make_branch_and_tree('.') |
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
211 |
tree.add(['a']) |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
212 |
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
213 |
osutils.rename('a', 'b') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
214 |
self.run_bzr('mv a b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
215 |
self.assertMoved('a','b') |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
216 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
217 |
def test_mv_already_moved_file_to_versioned_target(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
218 |
"""Test bzr mv existing_file to versioned_file.
|
219 |
||
220 |
Tests if an attempt to move an existing versioned file
|
|
221 |
to another versiond file will fail.
|
|
222 |
Setup: a and b are in the working tree.
|
|
223 |
User does: rm b; mv a b; bzr mv a b
|
|
224 |
"""
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
225 |
self.build_tree(['a', 'b']) |
226 |
tree = self.make_branch_and_tree('.') |
|
227 |
tree.add(['a', 'b']) |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
228 |
|
229 |
os.remove('b') |
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
230 |
osutils.rename('a', 'b') |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
231 |
self.run_bzr_error( |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
232 |
["^bzr: ERROR: Could not move a => b. b is already versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
233 |
'mv a b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
234 |
#check that nothing changed
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
235 |
self.assertPathDoesNotExist('a') |
236 |
self.assertPathExists('b') |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
237 |
|
238 |
def test_mv_already_moved_file_into_subdir(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
239 |
"""Test bzr mv original_file to versioned_directory/file.
|
240 |
||
241 |
Tests if a file which has already been moved into a versioned
|
|
242 |
directory by an external tool, is handled correctly by bzr mv.
|
|
243 |
Setup: a and sub/ are in the working tree.
|
|
244 |
User does: mv a sub/a; bzr mv a sub/a
|
|
245 |
"""
|
|
246 |
self.build_tree(['a', 'sub/']) |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
247 |
tree = self.make_branch_and_tree('.') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
248 |
tree.add(['a', 'sub']) |
249 |
||
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
250 |
osutils.rename('a', 'sub/a') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
251 |
self.run_bzr('mv a sub/a') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
252 |
self.assertMoved('a','sub/a') |
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
253 |
|
254 |
def test_mv_already_moved_file_into_unversioned_subdir(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
255 |
"""Test bzr mv original_file to unversioned_directory/file.
|
256 |
||
257 |
Tests if an attempt to move an existing versioned file
|
|
258 |
into an unversioned directory will fail.
|
|
259 |
Setup: a is in the working tree, sub/ is not.
|
|
260 |
User does: mv a sub/a; bzr mv a sub/a
|
|
261 |
"""
|
|
262 |
self.build_tree(['a', 'sub/']) |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
263 |
tree = self.make_branch_and_tree('.') |
264 |
tree.add(['a']) |
|
265 |
||
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
266 |
osutils.rename('a', 'sub/a') |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
267 |
self.run_bzr_error( |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
268 |
["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
269 |
'mv a sub/a') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
270 |
self.assertPathDoesNotExist('a') |
271 |
self.assertPathExists('sub/a') |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
272 |
|
273 |
def test_mv_already_moved_files_into_subdir(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
274 |
"""Test bzr mv original_files to versioned_directory.
|
275 |
||
276 |
Tests if files which has already been moved into a versioned
|
|
277 |
directory by an external tool, is handled correctly by bzr mv.
|
|
278 |
Setup: a1, a2, sub are in the working tree.
|
|
279 |
User does: mv a1 sub/.; bzr mv a1 a2 sub
|
|
280 |
"""
|
|
281 |
self.build_tree(['a1', 'a2', 'sub/']) |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
282 |
tree = self.make_branch_and_tree('.') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
283 |
tree.add(['a1', 'a2', 'sub']) |
284 |
||
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
285 |
osutils.rename('a1', 'sub/a1') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
286 |
self.run_bzr('mv a1 a2 sub') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
287 |
self.assertMoved('a1','sub/a1') |
288 |
self.assertMoved('a2','sub/a2') |
|
289 |
||
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
290 |
def test_mv_already_moved_files_into_unversioned_subdir(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
291 |
"""Test bzr mv original_file to unversioned_directory.
|
292 |
||
293 |
Tests if an attempt to move existing versioned file
|
|
294 |
into an unversioned directory will fail.
|
|
295 |
Setup: a1, a2 are in the working tree, sub is not.
|
|
296 |
User does: mv a1 sub/.; bzr mv a1 a2 sub
|
|
297 |
"""
|
|
298 |
self.build_tree(['a1', 'a2', 'sub/']) |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
299 |
tree = self.make_branch_and_tree('.') |
300 |
tree.add(['a1', 'a2']) |
|
301 |
||
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
302 |
osutils.rename('a1', 'sub/a1') |
2206.1.8
by Marius Kruger
Converted move/rename error messages to show source => target. |
303 |
self.run_bzr_error( |
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
304 |
["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
305 |
'mv a1 a2 sub') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
306 |
self.assertPathDoesNotExist('a1') |
307 |
self.assertPathExists('sub/a1') |
|
308 |
self.assertPathExists('a2') |
|
309 |
self.assertPathDoesNotExist('sub/a2') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
310 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
311 |
def test_mv_already_moved_file_forcing_after(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
312 |
"""Test bzr mv versioned_file to unversioned_file.
|
313 |
||
314 |
Tests if an attempt to move an existing versioned file to an existing
|
|
315 |
unversioned file will fail, informing the user to use the --after
|
|
316 |
option to force this.
|
|
317 |
Setup: a is in the working tree, b not versioned.
|
|
318 |
User does: mv a b; touch a; bzr mv a b
|
|
319 |
"""
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
320 |
self.build_tree(['a', 'b']) |
321 |
tree = self.make_branch_and_tree('.') |
|
322 |
tree.add(['a']) |
|
323 |
||
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
324 |
osutils.rename('a', 'b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
325 |
self.build_tree(['a']) #touch a |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
326 |
self.run_bzr_error( |
2220.1.12
by Marius Kruger
* Fix errors.py import order |
327 |
["^bzr: ERROR: Could not rename a => b because both files exist." |
2967.3.2
by Daniel Watkins
Modified tests to reflect modified error messages. |
328 |
" \(Use --after to tell bzr about a rename that has already"
|
329 |
" happened\)$"], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
330 |
'mv a b') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
331 |
self.assertPathExists('a') |
332 |
self.assertPathExists('b') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
333 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
334 |
def test_mv_already_moved_file_using_after(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
335 |
"""Test bzr mv --after versioned_file to unversioned_file.
|
336 |
||
337 |
Tests if an existing versioned file can be forced to move to an
|
|
338 |
existing unversioned file using the --after option. With the result
|
|
339 |
that bazaar considers the unversioned_file to be moved from
|
|
340 |
versioned_file and versioned_file will become unversioned.
|
|
341 |
Setup: a is in the working tree and b exists.
|
|
342 |
User does: mv a b; touch a; bzr mv a b --after
|
|
343 |
Resulting in a => b and a is unknown.
|
|
344 |
"""
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
345 |
self.build_tree(['a', 'b']) |
346 |
tree = self.make_branch_and_tree('.') |
|
347 |
tree.add(['a']) |
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
348 |
osutils.rename('a', 'b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
349 |
self.build_tree(['a']) #touch a |
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
350 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
351 |
self.run_bzr('mv a b --after') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
352 |
self.assertPathExists('a') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
353 |
self.assertNotInWorkingTree('a')#a should be unknown now. |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
354 |
self.assertPathExists('b') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
355 |
self.assertInWorkingTree('b') |
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
356 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
357 |
def test_mv_already_moved_files_forcing_after(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
358 |
"""Test bzr mv versioned_files to directory/unversioned_file.
|
359 |
||
360 |
Tests if an attempt to move an existing versioned file to an existing
|
|
361 |
unversioned file in some other directory will fail, informing the user
|
|
362 |
to use the --after option to force this.
|
|
363 |
||
364 |
Setup: a1, a2, sub are versioned and in the working tree,
|
|
365 |
sub/a1, sub/a2 are in working tree.
|
|
366 |
User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub
|
|
367 |
"""
|
|
368 |
self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2']) |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
369 |
tree = self.make_branch_and_tree('.') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
370 |
tree.add(['a1', 'a2', 'sub']) |
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
371 |
osutils.rename('a1', 'sub/a1') |
372 |
osutils.rename('a2', 'sub/a2') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
373 |
self.build_tree(['a1']) #touch a1 |
374 |
self.build_tree(['a2']) #touch a2 |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
375 |
|
376 |
self.run_bzr_error( |
|
2967.3.2
by Daniel Watkins
Modified tests to reflect modified error messages. |
377 |
["^bzr: ERROR: Could not rename a1 => sub/a1 because both files" |
378 |
" exist. \(Use --after to tell bzr about a rename that has already"
|
|
379 |
" happened\)$"], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
380 |
'mv a1 a2 sub') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
381 |
self.assertPathExists('a1') |
382 |
self.assertPathExists('a2') |
|
383 |
self.assertPathExists('sub/a1') |
|
384 |
self.assertPathExists('sub/a2') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
385 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
386 |
def test_mv_already_moved_files_using_after(self): |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
387 |
"""Test bzr mv --after versioned_file to directory/unversioned_file.
|
388 |
||
389 |
Tests if an existing versioned file can be forced to move to an
|
|
390 |
existing unversioned file in some other directory using the --after
|
|
391 |
option. With the result that bazaar considers
|
|
392 |
directory/unversioned_file to be moved from versioned_file and
|
|
393 |
versioned_file will become unversioned.
|
|
394 |
||
395 |
Setup: a1, a2, sub are versioned and in the working tree,
|
|
396 |
sub/a1, sub/a2 are in working tree.
|
|
397 |
User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub --after
|
|
398 |
"""
|
|
399 |
self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2']) |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
400 |
tree = self.make_branch_and_tree('.') |
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
401 |
tree.add(['a1', 'a2', 'sub']) |
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
402 |
osutils.rename('a1', 'sub/a1') |
403 |
osutils.rename('a2', 'sub/a2') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
404 |
self.build_tree(['a1']) #touch a1 |
405 |
self.build_tree(['a2']) #touch a2 |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
406 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
407 |
self.run_bzr('mv a1 a2 sub --after') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
408 |
self.assertPathExists('a1') |
409 |
self.assertPathExists('a2') |
|
410 |
self.assertPathExists('sub/a1') |
|
411 |
self.assertPathExists('sub/a2') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
412 |
self.assertInWorkingTree('sub/a1') |
2220.1.14
by Aaron Bentley
Cleanup formatting and error handling |
413 |
self.assertInWorkingTree('sub/a2') |
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
414 |
|
415 |
def test_mv_already_moved_directory(self): |
|
416 |
"""Use `bzr mv a b` to mark a directory as renamed.
|
|
417 |
||
418 |
https://bugs.launchpad.net/bzr/+bug/107967/
|
|
419 |
"""
|
|
420 |
self.build_tree(['a/', 'c/']) |
|
421 |
tree = self.make_branch_and_tree('.') |
|
422 |
tree.add(['a', 'c']) |
|
423 |
osutils.rename('a', 'b') |
|
424 |
osutils.rename('c', 'd') |
|
425 |
# mv a b should work just like it does for already renamed files
|
|
426 |
self.run_bzr('mv a b') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
427 |
self.assertPathDoesNotExist('a') |
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
428 |
self.assertNotInWorkingTree('a') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
429 |
self.assertPathExists('b') |
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
430 |
self.assertInWorkingTree('b') |
431 |
# and --after should work, too (technically it's ignored)
|
|
432 |
self.run_bzr('mv --after c d') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
433 |
self.assertPathDoesNotExist('c') |
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
434 |
self.assertNotInWorkingTree('c') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
435 |
self.assertPathExists('d') |
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
436 |
self.assertInWorkingTree('d') |
3193.8.35
by Aaron Bentley
Implement mv --auto. |
437 |
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
438 |
def make_abcd_tree(self): |
3193.8.35
by Aaron Bentley
Implement mv --auto. |
439 |
tree = self.make_branch_and_tree('tree') |
440 |
self.build_tree(['tree/a', 'tree/c']) |
|
441 |
tree.add(['a', 'c']) |
|
442 |
tree.commit('record old names') |
|
443 |
osutils.rename('tree/a', 'tree/b') |
|
444 |
osutils.rename('tree/c', 'tree/d') |
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
445 |
return tree |
446 |
||
447 |
def test_mv_auto(self): |
|
448 |
self.make_abcd_tree() |
|
3193.8.35
by Aaron Bentley
Implement mv --auto. |
449 |
out, err = self.run_bzr('mv --auto', working_dir='tree') |
450 |
self.assertEqual(out, '') |
|
451 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
452 |
tree = workingtree.WorkingTree.open('tree') |
|
453 |
self.assertIsNot(None, tree.path2id('b')) |
|
454 |
self.assertIsNot(None, tree.path2id('d')) |
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
455 |
|
456 |
def test_mv_auto_one_path(self): |
|
457 |
self.make_abcd_tree() |
|
458 |
out, err = self.run_bzr('mv --auto tree') |
|
459 |
self.assertEqual(out, '') |
|
460 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
461 |
tree = workingtree.WorkingTree.open('tree') |
|
462 |
self.assertIsNot(None, tree.path2id('b')) |
|
463 |
self.assertIsNot(None, tree.path2id('d')) |
|
464 |
||
465 |
def test_mv_auto_two_paths(self): |
|
466 |
self.make_abcd_tree() |
|
467 |
out, err = self.run_bzr('mv --auto tree tree2', retcode=3) |
|
468 |
self.assertEqual('bzr: ERROR: Only one path may be specified to' |
|
469 |
' --auto.\n', err) |
|
3193.8.37
by Aaron Bentley
Finish up conversion to mv --auto. |
470 |
|
471 |
def test_mv_auto_dry_run(self): |
|
472 |
self.make_abcd_tree() |
|
473 |
out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree') |
|
474 |
self.assertEqual(out, '') |
|
475 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
476 |
tree = workingtree.WorkingTree.open('tree') |
|
477 |
self.assertIsNot(None, tree.path2id('a')) |
|
478 |
self.assertIsNot(None, tree.path2id('c')) |
|
479 |
||
480 |
def test_mv_no_auto_dry_run(self): |
|
481 |
self.make_abcd_tree() |
|
482 |
out, err = self.run_bzr('mv c d --dry-run', |
|
483 |
working_dir='tree', retcode=3) |
|
484 |
self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err) |
|
485 |
||
486 |
def test_mv_auto_after(self): |
|
487 |
self.make_abcd_tree() |
|
488 |
out, err = self.run_bzr('mv --auto --after', working_dir='tree', |
|
489 |
retcode=3) |
|
490 |
self.assertEqual('bzr: ERROR: --after cannot be specified with' |
|
491 |
' --auto.\n', err) |
|
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
492 |
|
4795.3.2
by Andrew Bennetts
Add test, and NEWS entry. |
493 |
def test_mv_quiet(self): |
494 |
tree = self.make_branch_and_tree('.') |
|
495 |
self.build_tree(['aaa']) |
|
496 |
tree.add(['aaa']) |
|
497 |
out, err = self.run_bzr('mv --quiet aaa bbb') |
|
498 |
self.assertEqual(out, '') |
|
499 |
self.assertEqual(err, '') |
|
500 |
||
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
501 |
def test_mv_readonly_lightweight_checkout(self): |
502 |
branch = self.make_branch('foo') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
503 |
branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo')) |
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
504 |
tree = branch.create_checkout('tree', lightweight=True) |
505 |
self.build_tree(['tree/path']) |
|
506 |
tree.add('path') |
|
507 |
# If this fails, the tree is trying to acquire a branch lock, which it
|
|
508 |
# shouldn't.
|
|
509 |
self.run_bzr(['mv', 'tree/path', 'tree/path2']) |
|
5609.8.1
by Martin
Blackbox test reproducing problem encounted in bug 707954 |
510 |
|
511 |
def test_mv_unversioned_non_ascii(self): |
|
512 |
"""Clear error on mv of an unversioned non-ascii file, see lp:707954"""
|
|
5967.12.3
by Martin Pool
Unify duplicated UnicodeFilename and _PosixPermissionsFeature |
513 |
self.requireFeature(UnicodeFilenameFeature) |
5609.8.1
by Martin
Blackbox test reproducing problem encounted in bug 707954 |
514 |
tree = self.make_branch_and_tree(".") |
515 |
self.build_tree([u"\xA7"]) |
|
516 |
out, err = self.run_bzr_error(["Could not rename", "not versioned"], |
|
517 |
["mv", u"\xA7", "b"]) |