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