bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
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 |
|
|
6220.3.4
by Jonathan Riddell
add test |
190 |
def test_mv_no_root(self): |
191 |
tree = self.make_branch_and_tree('.') |
|
192 |
self.run_bzr_error( |
|
193 |
["bzr: ERROR: can not move root of branch"], |
|
194 |
'mv . a') |
|
195 |
||
|
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
196 |
def test_mv_through_symlinks(self): |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
197 |
self.requireFeature(SymlinkFeature) |
|
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
198 |
tree = self.make_branch_and_tree('.') |
199 |
self.build_tree(['a/', 'a/b']) |
|
200 |
os.symlink('a', 'c') |
|
201 |
os.symlink('.', 'd') |
|
202 |
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. |
203 |
self.run_bzr('mv c/b b') |
|
2091.3.2
by Aaron Bentley
Traverse non-terminal symlinks for mv et al |
204 |
tree = workingtree.WorkingTree.open('.') |
205 |
self.assertEqual('b-id', tree.path2id('b')) |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
206 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
207 |
def test_mv_already_moved_file(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
208 |
"""Test bzr mv original_file to moved_file. |
209 |
||
210 |
Tests if a file which has allready been moved by an external tool,
|
|
211 |
is handled correctly by bzr mv.
|
|
212 |
Setup: a is in the working tree, b does not exist.
|
|
213 |
User does: mv a b; bzr mv a b
|
|
214 |
"""
|
|
215 |
self.build_tree(['a']) |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
216 |
tree = self.make_branch_and_tree('.') |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
217 |
tree.add(['a']) |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
218 |
|
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
219 |
osutils.rename('a', 'b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
220 |
self.run_bzr('mv a b') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
221 |
self.assertMoved('a','b') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
222 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
223 |
def test_mv_already_moved_file_to_versioned_target(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
224 |
"""Test bzr mv existing_file to versioned_file. |
225 |
||
226 |
Tests if an attempt to move an existing versioned file
|
|
227 |
to another versiond file will fail.
|
|
228 |
Setup: a and b are in the working tree.
|
|
229 |
User does: rm b; mv a b; bzr mv a b
|
|
230 |
"""
|
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
231 |
self.build_tree(['a', 'b']) |
232 |
tree = self.make_branch_and_tree('.') |
|
233 |
tree.add(['a', 'b']) |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
234 |
|
235 |
os.remove('b') |
|
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
236 |
osutils.rename('a', 'b') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
237 |
self.run_bzr_error( |
|
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
238 |
["^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. |
239 |
'mv a b') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
240 |
#check that nothing changed
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
241 |
self.assertPathDoesNotExist('a') |
242 |
self.assertPathExists('b') |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
243 |
|
244 |
def test_mv_already_moved_file_into_subdir(self): |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
245 |
"""Test bzr mv original_file to versioned_directory/file. |
246 |
||
247 |
Tests if a file which has already been moved into a versioned
|
|
248 |
directory by an external tool, is handled correctly by bzr mv.
|
|
249 |
Setup: a and sub/ are in the working tree.
|
|
250 |
User does: mv a sub/a; bzr mv a sub/a
|
|
251 |
"""
|
|
252 |
self.build_tree(['a', 'sub/']) |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
253 |
tree = self.make_branch_and_tree('.') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
254 |
tree.add(['a', 'sub']) |
255 |
||
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
256 |
osutils.rename('a', 'sub/a') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
257 |
self.run_bzr('mv a sub/a') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
258 |
self.assertMoved('a','sub/a') |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
259 |
|
260 |
def test_mv_already_moved_file_into_unversioned_subdir(self): |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
261 |
"""Test bzr mv original_file to unversioned_directory/file. |
262 |
||
263 |
Tests if an attempt to move an existing versioned file
|
|
264 |
into an unversioned directory will fail.
|
|
265 |
Setup: a is in the working tree, sub/ is not.
|
|
266 |
User does: mv a sub/a; bzr mv a sub/a
|
|
267 |
"""
|
|
268 |
self.build_tree(['a', 'sub/']) |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
269 |
tree = self.make_branch_and_tree('.') |
270 |
tree.add(['a']) |
|
271 |
||
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
272 |
osutils.rename('a', 'sub/a') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
273 |
self.run_bzr_error( |
|
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
274 |
["^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. |
275 |
'mv a sub/a') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
276 |
self.assertPathDoesNotExist('a') |
277 |
self.assertPathExists('sub/a') |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
278 |
|
279 |
def test_mv_already_moved_files_into_subdir(self): |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
280 |
"""Test bzr mv original_files to versioned_directory. |
281 |
||
282 |
Tests if files which has already been moved into a versioned
|
|
283 |
directory by an external tool, is handled correctly by bzr mv.
|
|
284 |
Setup: a1, a2, sub are in the working tree.
|
|
285 |
User does: mv a1 sub/.; bzr mv a1 a2 sub
|
|
286 |
"""
|
|
287 |
self.build_tree(['a1', 'a2', 'sub/']) |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
288 |
tree = self.make_branch_and_tree('.') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
289 |
tree.add(['a1', 'a2', 'sub']) |
290 |
||
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
291 |
osutils.rename('a1', 'sub/a1') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
292 |
self.run_bzr('mv a1 a2 sub') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
293 |
self.assertMoved('a1','sub/a1') |
294 |
self.assertMoved('a2','sub/a2') |
|
295 |
||
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
296 |
def test_mv_already_moved_files_into_unversioned_subdir(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
297 |
"""Test bzr mv original_file to unversioned_directory. |
298 |
||
299 |
Tests if an attempt to move existing versioned file
|
|
300 |
into an unversioned directory will fail.
|
|
301 |
Setup: a1, a2 are in the working tree, sub is not.
|
|
302 |
User does: mv a1 sub/.; bzr mv a1 a2 sub
|
|
303 |
"""
|
|
304 |
self.build_tree(['a1', 'a2', 'sub/']) |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
305 |
tree = self.make_branch_and_tree('.') |
306 |
tree.add(['a1', 'a2']) |
|
307 |
||
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
308 |
osutils.rename('a1', 'sub/a1') |
|
2206.1.8
by Marius Kruger
Converted move/rename error messages to show source => target. |
309 |
self.run_bzr_error( |
|
2745.3.2
by Daniel Watkins
Updated tests to reflect new error text. |
310 |
["^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. |
311 |
'mv a1 a2 sub') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
312 |
self.assertPathDoesNotExist('a1') |
313 |
self.assertPathExists('sub/a1') |
|
314 |
self.assertPathExists('a2') |
|
315 |
self.assertPathDoesNotExist('sub/a2') |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
316 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
317 |
def test_mv_already_moved_file_forcing_after(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
318 |
"""Test bzr mv versioned_file to unversioned_file. |
319 |
||
320 |
Tests if an attempt to move an existing versioned file to an existing
|
|
321 |
unversioned file will fail, informing the user to use the --after
|
|
322 |
option to force this.
|
|
323 |
Setup: a is in the working tree, b not versioned.
|
|
324 |
User does: mv a b; touch a; bzr mv a b
|
|
325 |
"""
|
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
326 |
self.build_tree(['a', 'b']) |
327 |
tree = self.make_branch_and_tree('.') |
|
328 |
tree.add(['a']) |
|
329 |
||
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
330 |
osutils.rename('a', 'b') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
331 |
self.build_tree(['a']) #touch a |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
332 |
self.run_bzr_error( |
|
2220.1.12
by Marius Kruger
* Fix errors.py import order |
333 |
["^bzr: ERROR: Could not rename a => b because both files exist." |
|
2967.3.2
by Daniel Watkins
Modified tests to reflect modified error messages. |
334 |
" \(Use --after to tell bzr about a rename that has already"
|
335 |
" happened\)$"], |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
336 |
'mv a b') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
337 |
self.assertPathExists('a') |
338 |
self.assertPathExists('b') |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
339 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
340 |
def test_mv_already_moved_file_using_after(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
341 |
"""Test bzr mv --after versioned_file to unversioned_file. |
342 |
||
343 |
Tests if an existing versioned file can be forced to move to an
|
|
344 |
existing unversioned file using the --after option. With the result
|
|
345 |
that bazaar considers the unversioned_file to be moved from
|
|
346 |
versioned_file and versioned_file will become unversioned.
|
|
347 |
Setup: a is in the working tree and b exists.
|
|
348 |
User does: mv a b; touch a; bzr mv a b --after
|
|
349 |
Resulting in a => b and a is unknown.
|
|
350 |
"""
|
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
351 |
self.build_tree(['a', 'b']) |
352 |
tree = self.make_branch_and_tree('.') |
|
353 |
tree.add(['a']) |
|
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
354 |
osutils.rename('a', 'b') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
355 |
self.build_tree(['a']) #touch a |
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
356 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
357 |
self.run_bzr('mv a b --after') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
358 |
self.assertPathExists('a') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
359 |
self.assertNotInWorkingTree('a')#a should be unknown now. |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
360 |
self.assertPathExists('b') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
361 |
self.assertInWorkingTree('b') |
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
362 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
363 |
def test_mv_already_moved_files_forcing_after(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
364 |
"""Test bzr mv versioned_files to directory/unversioned_file. |
365 |
||
366 |
Tests if an attempt to move an existing versioned file to an existing
|
|
367 |
unversioned file in some other directory will fail, informing the user
|
|
368 |
to use the --after option to force this.
|
|
369 |
||
370 |
Setup: a1, a2, sub are versioned and in the working tree,
|
|
371 |
sub/a1, sub/a2 are in working tree.
|
|
372 |
User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub
|
|
373 |
"""
|
|
374 |
self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2']) |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
375 |
tree = self.make_branch_and_tree('.') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
376 |
tree.add(['a1', 'a2', 'sub']) |
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
377 |
osutils.rename('a1', 'sub/a1') |
378 |
osutils.rename('a2', 'sub/a2') |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
379 |
self.build_tree(['a1']) #touch a1 |
380 |
self.build_tree(['a2']) #touch a2 |
|
|
2123.3.4
by Steffen Eichenberg
a few new blackbox test for mv |
381 |
|
382 |
self.run_bzr_error( |
|
|
2967.3.2
by Daniel Watkins
Modified tests to reflect modified error messages. |
383 |
["^bzr: ERROR: Could not rename a1 => sub/a1 because both files" |
384 |
" exist. \(Use --after to tell bzr about a rename that has already"
|
|
385 |
" happened\)$"], |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
386 |
'mv a1 a2 sub') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
387 |
self.assertPathExists('a1') |
388 |
self.assertPathExists('a2') |
|
389 |
self.assertPathExists('sub/a1') |
|
390 |
self.assertPathExists('sub/a2') |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
391 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
392 |
def test_mv_already_moved_files_using_after(self): |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
393 |
"""Test bzr mv --after versioned_file to directory/unversioned_file. |
394 |
||
395 |
Tests if an existing versioned file can be forced to move to an
|
|
396 |
existing unversioned file in some other directory using the --after
|
|
397 |
option. With the result that bazaar considers
|
|
398 |
directory/unversioned_file to be moved from versioned_file and
|
|
399 |
versioned_file will become unversioned.
|
|
400 |
||
401 |
Setup: a1, a2, sub are versioned and in the working tree,
|
|
402 |
sub/a1, sub/a2 are in working tree.
|
|
403 |
User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub --after
|
|
404 |
"""
|
|
405 |
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 |
406 |
tree = self.make_branch_and_tree('.') |
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
407 |
tree.add(['a1', 'a2', 'sub']) |
|
2309.2.3
by Alexander Belchenko
blackbox.test_mv: using safe osutils.rename instead of os.rename |
408 |
osutils.rename('a1', 'sub/a1') |
409 |
osutils.rename('a2', 'sub/a2') |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
410 |
self.build_tree(['a1']) #touch a1 |
411 |
self.build_tree(['a2']) #touch a2 |
|
|
2123.3.7
by Steffen Eichenberg
split tests so that each new method contains one test only |
412 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
413 |
self.run_bzr('mv a1 a2 sub --after') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
414 |
self.assertPathExists('a1') |
415 |
self.assertPathExists('a2') |
|
416 |
self.assertPathExists('sub/a1') |
|
417 |
self.assertPathExists('sub/a2') |
|
|
2220.1.5
by Marius Kruger
* bzrlib/tests/blackbox/test_mv.py |
418 |
self.assertInWorkingTree('sub/a1') |
|
2220.1.14
by Aaron Bentley
Cleanup formatting and error handling |
419 |
self.assertInWorkingTree('sub/a2') |
|
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
420 |
|
421 |
def test_mv_already_moved_directory(self): |
|
422 |
"""Use `bzr mv a b` to mark a directory as renamed. |
|
423 |
||
424 |
https://bugs.launchpad.net/bzr/+bug/107967/
|
|
425 |
"""
|
|
426 |
self.build_tree(['a/', 'c/']) |
|
427 |
tree = self.make_branch_and_tree('.') |
|
428 |
tree.add(['a', 'c']) |
|
429 |
osutils.rename('a', 'b') |
|
430 |
osutils.rename('c', 'd') |
|
431 |
# mv a b should work just like it does for already renamed files
|
|
432 |
self.run_bzr('mv a b') |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
433 |
self.assertPathDoesNotExist('a') |
|
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
434 |
self.assertNotInWorkingTree('a') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
435 |
self.assertPathExists('b') |
|
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
436 |
self.assertInWorkingTree('b') |
437 |
# and --after should work, too (technically it's ignored)
|
|
438 |
self.run_bzr('mv --after c d') |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
439 |
self.assertPathDoesNotExist('c') |
|
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
440 |
self.assertNotInWorkingTree('c') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
441 |
self.assertPathExists('d') |
|
3201.2.1
by Lukáš Lalinský
Make 'mv a b' work for already renamed directories, like it does for files |
442 |
self.assertInWorkingTree('d') |
|
3193.8.35
by Aaron Bentley
Implement mv --auto. |
443 |
|
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
444 |
def make_abcd_tree(self): |
|
3193.8.35
by Aaron Bentley
Implement mv --auto. |
445 |
tree = self.make_branch_and_tree('tree') |
446 |
self.build_tree(['tree/a', 'tree/c']) |
|
447 |
tree.add(['a', 'c']) |
|
448 |
tree.commit('record old names') |
|
449 |
osutils.rename('tree/a', 'tree/b') |
|
450 |
osutils.rename('tree/c', 'tree/d') |
|
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
451 |
return tree |
452 |
||
453 |
def test_mv_auto(self): |
|
454 |
self.make_abcd_tree() |
|
|
3193.8.35
by Aaron Bentley
Implement mv --auto. |
455 |
out, err = self.run_bzr('mv --auto', working_dir='tree') |
456 |
self.assertEqual(out, '') |
|
457 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
458 |
tree = workingtree.WorkingTree.open('tree') |
|
459 |
self.assertIsNot(None, tree.path2id('b')) |
|
460 |
self.assertIsNot(None, tree.path2id('d')) |
|
|
3193.8.36
by Aaron Bentley
Get remaining behaviour under test. |
461 |
|
462 |
def test_mv_auto_one_path(self): |
|
463 |
self.make_abcd_tree() |
|
464 |
out, err = self.run_bzr('mv --auto tree') |
|
465 |
self.assertEqual(out, '') |
|
466 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
467 |
tree = workingtree.WorkingTree.open('tree') |
|
468 |
self.assertIsNot(None, tree.path2id('b')) |
|
469 |
self.assertIsNot(None, tree.path2id('d')) |
|
470 |
||
471 |
def test_mv_auto_two_paths(self): |
|
472 |
self.make_abcd_tree() |
|
473 |
out, err = self.run_bzr('mv --auto tree tree2', retcode=3) |
|
474 |
self.assertEqual('bzr: ERROR: Only one path may be specified to' |
|
475 |
' --auto.\n', err) |
|
|
3193.8.37
by Aaron Bentley
Finish up conversion to mv --auto. |
476 |
|
477 |
def test_mv_auto_dry_run(self): |
|
478 |
self.make_abcd_tree() |
|
479 |
out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree') |
|
480 |
self.assertEqual(out, '') |
|
481 |
self.assertEqual(err, 'a => b\nc => d\n') |
|
482 |
tree = workingtree.WorkingTree.open('tree') |
|
483 |
self.assertIsNot(None, tree.path2id('a')) |
|
484 |
self.assertIsNot(None, tree.path2id('c')) |
|
485 |
||
486 |
def test_mv_no_auto_dry_run(self): |
|
487 |
self.make_abcd_tree() |
|
488 |
out, err = self.run_bzr('mv c d --dry-run', |
|
489 |
working_dir='tree', retcode=3) |
|
490 |
self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err) |
|
491 |
||
492 |
def test_mv_auto_after(self): |
|
493 |
self.make_abcd_tree() |
|
494 |
out, err = self.run_bzr('mv --auto --after', working_dir='tree', |
|
495 |
retcode=3) |
|
496 |
self.assertEqual('bzr: ERROR: --after cannot be specified with' |
|
497 |
' --auto.\n', err) |
|
|
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
498 |
|
|
4795.3.2
by Andrew Bennetts
Add test, and NEWS entry. |
499 |
def test_mv_quiet(self): |
500 |
tree = self.make_branch_and_tree('.') |
|
501 |
self.build_tree(['aaa']) |
|
502 |
tree.add(['aaa']) |
|
503 |
out, err = self.run_bzr('mv --quiet aaa bbb') |
|
504 |
self.assertEqual(out, '') |
|
505 |
self.assertEqual(err, '') |
|
506 |
||
|
4539.2.1
by Robert Collins
Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) |
507 |
def test_mv_readonly_lightweight_checkout(self): |
508 |
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. |
509 |
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) |
510 |
tree = branch.create_checkout('tree', lightweight=True) |
511 |
self.build_tree(['tree/path']) |
|
512 |
tree.add('path') |
|
513 |
# If this fails, the tree is trying to acquire a branch lock, which it
|
|
514 |
# shouldn't.
|
|
515 |
self.run_bzr(['mv', 'tree/path', 'tree/path2']) |
|
|
5609.8.1
by Martin
Blackbox test reproducing problem encounted in bug 707954 |
516 |
|
517 |
def test_mv_unversioned_non_ascii(self): |
|
518 |
"""Clear error on mv of an unversioned non-ascii file, see lp:707954""" |
|
|
5967.12.3
by Martin Pool
Unify duplicated UnicodeFilename and _PosixPermissionsFeature |
519 |
self.requireFeature(UnicodeFilenameFeature) |
|
5609.8.1
by Martin
Blackbox test reproducing problem encounted in bug 707954 |
520 |
tree = self.make_branch_and_tree(".") |
521 |
self.build_tree([u"\xA7"]) |
|
522 |
out, err = self.run_bzr_error(["Could not rename", "not versioned"], |
|
523 |
["mv", u"\xA7", "b"]) |