bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4634.125.4
by John Arbash Meinel
Merge bzr/2.0@4725, resolve NEWS |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
|
2255.13.4
by Martin Pool
merge |
3 |
# and others
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
4 |
#
|
5 |
# This program is free software; you can redistribute it and/or modify
|
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
8 |
# (at your option) any later version.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
18 |
|
19 |
from cStringIO import StringIO |
|
|
3136.1.10
by Aaron Bentley
Clean error if filesystem does not support hard-links |
20 |
import errno |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
21 |
import os |
|
1711.7.19
by John Arbash Meinel
file:// urls look slightly different on win32 |
22 |
import sys |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
23 |
|
|
3287.20.3
by John Arbash Meinel
Aaron recommended to make this a WT_impl test. |
24 |
from bzrlib import ( |
25 |
branch, |
|
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
26 |
branchbuilder, |
|
3287.20.3
by John Arbash Meinel
Aaron recommended to make this a WT_impl test. |
27 |
bzrdir, |
28 |
errors, |
|
29 |
osutils, |
|
30 |
tests, |
|
31 |
urlutils, |
|
32 |
workingtree, |
|
33 |
)
|
|
|
1836.1.18
by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again. |
34 |
from bzrlib.errors import (NotBranchError, NotVersionedError, |
|
1551.7.17
by Aaron Bentley
Switch to PathsNotVersioned, accept extra_trees |
35 |
UnsupportedOperation, PathsNotVersionedError) |
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
36 |
from bzrlib.inventory import Inventory |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
37 |
from bzrlib.osutils import pathjoin, getcwd, has_symlinks |
|
3619.6.7
by Mark Hammond
John asked for TestNotApplicable instead of TestSkipped when no os.link. |
38 |
from bzrlib.tests import TestSkipped, TestNotApplicable |
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
39 |
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
40 |
from bzrlib.trace import mutter |
41 |
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink, |
|
|
3034.4.9
by Alexander Belchenko
skip test_workingtree.TestWorkingTree.test_case_sensitive for WT2 |
42 |
WorkingTree, WorkingTree2) |
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
43 |
from bzrlib.conflicts import ConflictList, TextConflict, ContentsConflict |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
44 |
|
|
1711.7.19
by John Arbash Meinel
file:// urls look slightly different on win32 |
45 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
46 |
class TestWorkingTree(TestCaseWithWorkingTree): |
47 |
||
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
48 |
def test_list_files(self): |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
49 |
tree = self.make_branch_and_tree('.') |
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
50 |
self.build_tree(['dir/', 'file']) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
51 |
if has_symlinks(): |
52 |
os.symlink('target', 'symlink') |
|
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
53 |
tree.lock_read() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
54 |
files = list(tree.list_files()) |
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
55 |
tree.unlock() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
56 |
self.assertEqual(files[0], ('dir', '?', 'directory', None, TreeDirectory())) |
57 |
self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile())) |
|
58 |
if has_symlinks(): |
|
59 |
self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink())) |
|
60 |
||
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
61 |
def test_list_files_sorted(self): |
62 |
tree = self.make_branch_and_tree('.') |
|
|
1836.1.18
by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again. |
63 |
self.build_tree(['dir/', 'file', 'dir/file', 'dir/b', |
64 |
'dir/subdir/', 'a', 'dir/subfile', |
|
65 |
'zz_dir/', 'zz_dir/subfile']) |
|
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
66 |
tree.lock_read() |
|
1836.1.18
by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again. |
67 |
files = [(path, kind) for (path, v, kind, file_id, entry) |
68 |
in tree.list_files()] |
|
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
69 |
tree.unlock() |
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
70 |
self.assertEqual([ |
71 |
('a', 'file'), |
|
72 |
('dir', 'directory'), |
|
73 |
('file', 'file'), |
|
|
1732.1.25
by John Arbash Meinel
Fix list_files test, we don't need to check if children are empty if we fall off the loop. |
74 |
('zz_dir', 'directory'), |
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
75 |
], files) |
76 |
||
|
1732.1.25
by John Arbash Meinel
Fix list_files test, we don't need to check if children are empty if we fall off the loop. |
77 |
tree.add(['dir', 'zz_dir']) |
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
78 |
tree.lock_read() |
|
1836.1.18
by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again. |
79 |
files = [(path, kind) for (path, v, kind, file_id, entry) |
80 |
in tree.list_files()] |
|
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
81 |
tree.unlock() |
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
82 |
self.assertEqual([ |
83 |
('a', 'file'), |
|
84 |
('dir', 'directory'), |
|
85 |
('dir/b', 'file'), |
|
86 |
('dir/file', 'file'), |
|
87 |
('dir/subdir', 'directory'), |
|
88 |
('dir/subfile', 'file'), |
|
89 |
('file', 'file'), |
|
|
1732.1.22
by John Arbash Meinel
Bug in list_files if the last entry in a directory is another directory |
90 |
('zz_dir', 'directory'), |
91 |
('zz_dir/subfile', 'file'), |
|
|
1732.1.8
by John Arbash Meinel
Adding a test for list_files |
92 |
], files) |
93 |
||
|
1551.10.29
by Aaron Bentley
Fix tree.list_files when file kind changes |
94 |
def test_list_files_kind_change(self): |
95 |
tree = self.make_branch_and_tree('tree') |
|
96 |
self.build_tree(['tree/filename']) |
|
97 |
tree.add('filename', 'file-id') |
|
98 |
os.unlink('tree/filename') |
|
99 |
self.build_tree(['tree/filename/']) |
|
100 |
tree.lock_read() |
|
101 |
self.addCleanup(tree.unlock) |
|
102 |
result = list(tree.list_files()) |
|
103 |
self.assertEqual(1, len(result)) |
|
104 |
self.assertEqual(('filename', 'V', 'directory', 'file-id'), |
|
105 |
result[0][:4]) |
|
106 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
107 |
def test_open_containing(self): |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
108 |
branch = self.make_branch_and_tree('.').branch |
|
1711.7.28
by John Arbash Meinel
clean up the WorkingTree.open_containing tests |
109 |
local_base = urlutils.local_path_from_url(branch.base) |
110 |
||
111 |
# Empty opens '.'
|
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
112 |
wt, relpath = WorkingTree.open_containing() |
113 |
self.assertEqual('', relpath) |
|
|
1711.7.28
by John Arbash Meinel
clean up the WorkingTree.open_containing tests |
114 |
self.assertEqual(wt.basedir + '/', local_base) |
115 |
||
116 |
# '.' opens this dir
|
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
117 |
wt, relpath = WorkingTree.open_containing(u'.') |
118 |
self.assertEqual('', relpath) |
|
|
1711.7.28
by John Arbash Meinel
clean up the WorkingTree.open_containing tests |
119 |
self.assertEqual(wt.basedir + '/', local_base) |
120 |
||
121 |
# './foo' finds '.' and a relpath of 'foo'
|
|
122 |
wt, relpath = WorkingTree.open_containing('./foo') |
|
123 |
self.assertEqual('foo', relpath) |
|
124 |
self.assertEqual(wt.basedir + '/', local_base) |
|
125 |
||
126 |
# abspath(foo) finds '.' and relpath of 'foo'
|
|
127 |
wt, relpath = WorkingTree.open_containing('./foo') |
|
128 |
wt, relpath = WorkingTree.open_containing(getcwd() + '/foo') |
|
129 |
self.assertEqual('foo', relpath) |
|
130 |
self.assertEqual(wt.basedir + '/', local_base) |
|
131 |
||
132 |
# can even be a url: finds '.' and relpath of 'foo'
|
|
133 |
wt, relpath = WorkingTree.open_containing('./foo') |
|
134 |
wt, relpath = WorkingTree.open_containing( |
|
135 |
urlutils.local_path_to_url(getcwd() + '/foo')) |
|
136 |
self.assertEqual('foo', relpath) |
|
137 |
self.assertEqual(wt.basedir + '/', local_base) |
|
138 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
139 |
def test_basic_relpath(self): |
140 |
# for comprehensive relpath tests, see whitebox.py.
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
141 |
tree = self.make_branch_and_tree('.') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
142 |
self.assertEqual('child', |
143 |
tree.relpath(pathjoin(getcwd(), 'child'))) |
|
144 |
||
145 |
def test_lock_locks_branch(self): |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
146 |
tree = self.make_branch_and_tree('.') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
147 |
tree.lock_read() |
148 |
self.assertEqual('r', tree.branch.peek_lock_mode()) |
|
149 |
tree.unlock() |
|
150 |
self.assertEqual(None, tree.branch.peek_lock_mode()) |
|
151 |
tree.lock_write() |
|
152 |
self.assertEqual('w', tree.branch.peek_lock_mode()) |
|
153 |
tree.unlock() |
|
154 |
self.assertEqual(None, tree.branch.peek_lock_mode()) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
155 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
156 |
def test_revert(self): |
157 |
"""Test selected-file revert""" |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
158 |
tree = self.make_branch_and_tree('.') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
159 |
|
160 |
self.build_tree(['hello.txt']) |
|
161 |
file('hello.txt', 'w').write('initial hello') |
|
162 |
||
|
1551.7.17
by Aaron Bentley
Switch to PathsNotVersioned, accept extra_trees |
163 |
self.assertRaises(PathsNotVersionedError, |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
164 |
tree.revert, ['hello.txt']) |
165 |
tree.add(['hello.txt']) |
|
166 |
tree.commit('create initial hello.txt') |
|
167 |
||
168 |
self.check_file_contents('hello.txt', 'initial hello') |
|
169 |
file('hello.txt', 'w').write('new hello') |
|
170 |
self.check_file_contents('hello.txt', 'new hello') |
|
171 |
||
172 |
# revert file modified since last revision
|
|
173 |
tree.revert(['hello.txt']) |
|
174 |
self.check_file_contents('hello.txt', 'initial hello') |
|
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
175 |
self.check_file_contents('hello.txt.~1~', 'new hello') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
176 |
|
177 |
# reverting again does not clobber the backup
|
|
178 |
tree.revert(['hello.txt']) |
|
179 |
self.check_file_contents('hello.txt', 'initial hello') |
|
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
180 |
self.check_file_contents('hello.txt.~1~', 'new hello') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
181 |
|
|
1534.10.28
by Aaron Bentley
Use numbered backup files |
182 |
# backup files are numbered
|
183 |
file('hello.txt', 'w').write('new hello2') |
|
184 |
tree.revert(['hello.txt']) |
|
185 |
self.check_file_contents('hello.txt', 'initial hello') |
|
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
186 |
self.check_file_contents('hello.txt.~1~', 'new hello') |
187 |
self.check_file_contents('hello.txt.~2~', 'new hello2') |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
188 |
|
|
1558.12.7
by Aaron Bentley
Fixed revert with missing files |
189 |
def test_revert_missing(self): |
190 |
# Revert a file that has been deleted since last commit
|
|
191 |
tree = self.make_branch_and_tree('.') |
|
192 |
file('hello.txt', 'w').write('initial hello') |
|
193 |
tree.add('hello.txt') |
|
194 |
tree.commit('added hello.txt') |
|
195 |
os.unlink('hello.txt') |
|
196 |
tree.remove('hello.txt') |
|
197 |
tree.revert(['hello.txt']) |
|
198 |
self.failUnlessExists('hello.txt') |
|
199 |
||
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
200 |
def test_versioned_files_not_unknown(self): |
201 |
tree = self.make_branch_and_tree('.') |
|
|
1831.1.1
by Martin Pool
[merge] remove default ignore list & update |
202 |
self.build_tree(['hello.txt']) |
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
203 |
tree.add('hello.txt') |
204 |
self.assertEquals(list(tree.unknowns()), |
|
205 |
[])
|
|
|
1831.1.1
by Martin Pool
[merge] remove default ignore list & update |
206 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
207 |
def test_unknowns(self): |
208 |
tree = self.make_branch_and_tree('.') |
|
209 |
self.build_tree(['hello.txt', |
|
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
210 |
'hello.txt.~1~']) |
|
1765.1.1
by Robert Collins
Remove the default ignores list from bzr, lowering the minimum overhead in bzr add. |
211 |
self.build_tree_contents([('.bzrignore', '*.~*\n')]) |
212 |
tree.add('.bzrignore') |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
213 |
self.assertEquals(list(tree.unknowns()), |
214 |
['hello.txt']) |
|
215 |
||
216 |
def test_initialize(self): |
|
217 |
# initialize should create a working tree and branch in an existing dir
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
218 |
t = self.make_branch_and_tree('.') |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
219 |
b = branch.Branch.open('.') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
220 |
self.assertEqual(t.branch.base, b.base) |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
221 |
t2 = WorkingTree.open('.') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
222 |
self.assertEqual(t.basedir, t2.basedir) |
223 |
self.assertEqual(b.base, t2.branch.base) |
|
224 |
# TODO maybe we should check the branch format? not sure if its
|
|
225 |
# appropriate here.
|
|
226 |
||
227 |
def test_rename_dirs(self): |
|
228 |
"""Test renaming directories and the files within them.""" |
|
229 |
wt = self.make_branch_and_tree('.') |
|
230 |
b = wt.branch |
|
231 |
self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file']) |
|
232 |
wt.add(['dir', 'dir/sub', 'dir/sub/file']) |
|
233 |
||
234 |
wt.commit('create initial state') |
|
235 |
||
236 |
revid = b.revision_history()[0] |
|
237 |
self.log('first revision_id is {%s}' % revid) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
238 |
|
|
5035.3.1
by Jelmer Vernooij
Remove Repository.get_revision_inventory. |
239 |
inv = b.repository.get_inventory(revid) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
240 |
self.log('contents of inventory: %r' % inv.entries()) |
241 |
||
242 |
self.check_inventory_shape(inv, |
|
|
2545.3.2
by James Westby
Add a test for check_inventory_shape. |
243 |
['dir/', 'dir/sub/', 'dir/sub/file']) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
244 |
wt.rename_one('dir', 'newdir') |
245 |
||
|
2255.2.57
by Robert Collins
Dirstate test change: TestWorkingTree.test_rename_dirs should lock around accessing the trees inventory. |
246 |
wt.lock_read() |
247 |
self.check_inventory_shape(wt.inventory, |
|
|
2545.3.2
by James Westby
Add a test for check_inventory_shape. |
248 |
['newdir/', 'newdir/sub/', 'newdir/sub/file']) |
|
2255.2.57
by Robert Collins
Dirstate test change: TestWorkingTree.test_rename_dirs should lock around accessing the trees inventory. |
249 |
wt.unlock() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
250 |
wt.rename_one('newdir/sub', 'newdir/newsub') |
|
2255.2.57
by Robert Collins
Dirstate test change: TestWorkingTree.test_rename_dirs should lock around accessing the trees inventory. |
251 |
wt.lock_read() |
252 |
self.check_inventory_shape(wt.inventory, |
|
|
2545.3.2
by James Westby
Add a test for check_inventory_shape. |
253 |
['newdir/', 'newdir/newsub/', |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
254 |
'newdir/newsub/file']) |
|
2255.2.57
by Robert Collins
Dirstate test change: TestWorkingTree.test_rename_dirs should lock around accessing the trees inventory. |
255 |
wt.unlock() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
256 |
|
257 |
def test_add_in_unversioned(self): |
|
258 |
"""Try to add a file in an unversioned directory. |
|
259 |
||
260 |
"bzr add" adds the parent as necessary, but simple working tree add
|
|
261 |
doesn't do that.
|
|
262 |
"""
|
|
263 |
from bzrlib.errors import NotVersionedError |
|
264 |
wt = self.make_branch_and_tree('.') |
|
265 |
self.build_tree(['foo/', |
|
266 |
'foo/hello']) |
|
267 |
self.assertRaises(NotVersionedError, |
|
268 |
wt.add, |
|
269 |
'foo/hello') |
|
270 |
||
271 |
def test_add_missing(self): |
|
272 |
# adding a msising file -> NoSuchFile
|
|
273 |
wt = self.make_branch_and_tree('.') |
|
274 |
self.assertRaises(errors.NoSuchFile, wt.add, 'fpp') |
|
275 |
||
276 |
def test_remove_verbose(self): |
|
277 |
#FIXME the remove api should not print or otherwise depend on the
|
|
278 |
# text UI - RBC 20060124
|
|
279 |
wt = self.make_branch_and_tree('.') |
|
280 |
self.build_tree(['hello']) |
|
281 |
wt.add(['hello']) |
|
282 |
wt.commit(message='add hello') |
|
283 |
stdout = StringIO() |
|
284 |
stderr = StringIO() |
|
285 |
self.assertEqual(None, self.apply_redirected(None, stdout, stderr, |
|
286 |
wt.remove, |
|
287 |
['hello'], |
|
288 |
verbose=True)) |
|
289 |
self.assertEqual('? hello\n', stdout.getvalue()) |
|
290 |
self.assertEqual('', stderr.getvalue()) |
|
291 |
||
292 |
def test_clone_trivial(self): |
|
293 |
wt = self.make_branch_and_tree('source') |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
294 |
cloned_dir = wt.bzrdir.clone('target') |
295 |
cloned = cloned_dir.open_workingtree() |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
296 |
self.assertEqual(cloned.get_parent_ids(), wt.get_parent_ids()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
297 |
|
298 |
def test_last_revision(self): |
|
299 |
wt = self.make_branch_and_tree('source') |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
300 |
self.assertEqual([], wt.get_parent_ids()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
301 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
2249.5.7
by John Arbash Meinel
Make sure WorkingTree revision_ids are also returned as utf8 strings |
302 |
parent_ids = wt.get_parent_ids() |
303 |
self.assertEqual(['A'], parent_ids) |
|
304 |
for parent_id in parent_ids: |
|
305 |
self.assertIsInstance(parent_id, str) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
306 |
|
307 |
def test_set_last_revision(self): |
|
308 |
wt = self.make_branch_and_tree('source') |
|
|
1908.1.1
by Robert Collins
Relax WorkingTree.set_last-revision to allow any revision to be set. |
309 |
# set last-revision to one not in the history
|
310 |
wt.set_last_revision('A') |
|
311 |
# set it back to None for an empty tree.
|
|
|
2598.5.3
by Aaron Bentley
Push NULL_REVISION deeper |
312 |
wt.set_last_revision('null:') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
313 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
314 |
self.assertEqual(['A'], wt.get_parent_ids()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
315 |
# None is aways in the branch
|
|
2598.5.3
by Aaron Bentley
Push NULL_REVISION deeper |
316 |
wt.set_last_revision('null:') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
317 |
self.assertEqual([], wt.get_parent_ids()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
318 |
# and now we can set it to 'A'
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
319 |
# because some formats mutate the branch to set it on the tree
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
320 |
# we need to alter the branch to let this pass.
|
|
2230.3.27
by Aaron Bentley
Skip arbitrary revision-history test for Branch6 |
321 |
try: |
322 |
wt.branch.set_revision_history(['A', 'B']) |
|
323 |
except errors.NoSuchRevision, e: |
|
324 |
self.assertEqual('B', e.revision) |
|
325 |
raise TestSkipped("Branch format does not permit arbitrary" |
|
326 |
" history") |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
327 |
wt.set_last_revision('A') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
328 |
self.assertEqual(['A'], wt.get_parent_ids()) |
|
2229.2.1
by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository |
329 |
self.assertRaises(errors.ReservedId, wt.set_last_revision, 'A:') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
330 |
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
331 |
def test_set_last_revision_different_to_branch(self): |
332 |
# working tree formats from the meta-dir format and newer support
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
333 |
# setting the last revision on a tree independently of that on the
|
334 |
# branch. Its concievable that some future formats may want to
|
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
335 |
# couple them again (i.e. because its really a smart server and
|
336 |
# the working tree will always match the branch). So we test
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
337 |
# that formats where initialising a branch does not initialise a
|
338 |
# tree - and thus have separable entities - support skewing the
|
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
339 |
# two things.
|
340 |
branch = self.make_branch('tree') |
|
341 |
try: |
|
342 |
# if there is a working tree now, this is not supported.
|
|
343 |
branch.bzrdir.open_workingtree() |
|
344 |
return
|
|
345 |
except errors.NoWorkingTree: |
|
346 |
pass
|
|
347 |
wt = branch.bzrdir.create_workingtree() |
|
348 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
349 |
wt.set_last_revision(None) |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
350 |
self.assertEqual([], wt.get_parent_ids()) |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
351 |
self.assertEqual('A', wt.branch.last_revision()) |
352 |
# and now we can set it back to 'A'
|
|
353 |
wt.set_last_revision('A') |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
354 |
self.assertEqual(['A'], wt.get_parent_ids()) |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
355 |
self.assertEqual('A', wt.branch.last_revision()) |
356 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
357 |
def test_clone_and_commit_preserves_last_revision(self): |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
358 |
"""Doing a commit into a clone tree does not affect the source.""" |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
359 |
wt = self.make_branch_and_tree('source') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
360 |
cloned_dir = wt.bzrdir.clone('target') |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
361 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
362 |
self.assertNotEqual(cloned_dir.open_workingtree().get_parent_ids(), |
363 |
wt.get_parent_ids()) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
364 |
|
365 |
def test_clone_preserves_content(self): |
|
366 |
wt = self.make_branch_and_tree('source') |
|
|
2255.2.51
by John Arbash Meinel
simple rewrap for 79 char lines |
367 |
self.build_tree(['added', 'deleted', 'notadded'], |
368 |
transport=wt.bzrdir.transport.clone('..')) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
369 |
wt.add('deleted', 'deleted') |
370 |
wt.commit('add deleted') |
|
371 |
wt.remove('deleted') |
|
372 |
wt.add('added', 'added') |
|
373 |
cloned_dir = wt.bzrdir.clone('target') |
|
374 |
cloned = cloned_dir.open_workingtree() |
|
375 |
cloned_transport = cloned.bzrdir.transport.clone('..') |
|
376 |
self.assertFalse(cloned_transport.has('deleted')) |
|
377 |
self.assertTrue(cloned_transport.has('added')) |
|
378 |
self.assertFalse(cloned_transport.has('notadded')) |
|
379 |
self.assertEqual('added', cloned.path2id('added')) |
|
380 |
self.assertEqual(None, cloned.path2id('deleted')) |
|
381 |
self.assertEqual(None, cloned.path2id('notadded')) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
382 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
383 |
def test_basis_tree_returns_last_revision(self): |
384 |
wt = self.make_branch_and_tree('.') |
|
385 |
self.build_tree(['foo']) |
|
386 |
wt.add('foo', 'foo-id') |
|
387 |
wt.commit('A', rev_id='A') |
|
388 |
wt.rename_one('foo', 'bar') |
|
389 |
wt.commit('B', rev_id='B') |
|
|
1908.6.3
by Robert Collins
Tidy up the last_revision_id and add_pending_merge conversion to use cleaner apis. |
390 |
wt.set_parent_ids(['B']) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
391 |
tree = wt.basis_tree() |
|
2255.2.30
by Robert Collins
Some workingtree_implementations/test_workingtree.py test work - add DirStateRevisionTree.has_filename, locks around appropriate calls in tests. |
392 |
tree.lock_read() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
393 |
self.failUnless(tree.has_filename('bar')) |
|
2255.2.30
by Robert Collins
Some workingtree_implementations/test_workingtree.py test work - add DirStateRevisionTree.has_filename, locks around appropriate calls in tests. |
394 |
tree.unlock() |
|
1908.6.3
by Robert Collins
Tidy up the last_revision_id and add_pending_merge conversion to use cleaner apis. |
395 |
wt.set_parent_ids(['A']) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
396 |
tree = wt.basis_tree() |
|
2255.2.30
by Robert Collins
Some workingtree_implementations/test_workingtree.py test work - add DirStateRevisionTree.has_filename, locks around appropriate calls in tests. |
397 |
tree.lock_read() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
398 |
self.failUnless(tree.has_filename('foo')) |
|
2255.2.30
by Robert Collins
Some workingtree_implementations/test_workingtree.py test work - add DirStateRevisionTree.has_filename, locks around appropriate calls in tests. |
399 |
tree.unlock() |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
400 |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
401 |
def test_clone_tree_revision(self): |
402 |
# make a tree with a last-revision,
|
|
403 |
# and clone it with a different last-revision, this should switch
|
|
404 |
# do it.
|
|
405 |
#
|
|
406 |
# also test that the content is merged
|
|
407 |
# and conflicts recorded.
|
|
408 |
# This should merge between the trees - local edits should be preserved
|
|
409 |
# but other changes occured.
|
|
410 |
# we test this by having one file that does
|
|
411 |
# not change between two revisions, and another that does -
|
|
412 |
# if the changed one is not changed, fail,
|
|
413 |
# if the one that did not change has lost a local change, fail.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
414 |
#
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
415 |
raise TestSkipped('revision limiting is not implemented yet.') |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
416 |
|
417 |
def test_initialize_with_revision_id(self): |
|
418 |
# a bzrdir can construct a working tree for itself @ a specific revision.
|
|
419 |
source = self.make_branch_and_tree('source') |
|
420 |
source.commit('a', rev_id='a', allow_pointless=True) |
|
421 |
source.commit('b', rev_id='b', allow_pointless=True) |
|
422 |
self.build_tree(['new/']) |
|
423 |
made_control = self.bzrdir_format.initialize('new') |
|
424 |
source.branch.repository.clone(made_control) |
|
425 |
source.branch.clone(made_control) |
|
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
426 |
made_tree = self.workingtree_format.initialize(made_control, |
427 |
revision_id='a') |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
428 |
self.assertEqual(['a'], made_tree.get_parent_ids()) |
|
1508.1.23
by Robert Collins
Test that the working tree last revision is indeed set during commit. |
429 |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
430 |
def test_update_sets_last_revision(self): |
431 |
# working tree formats from the meta-dir format and newer support
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
432 |
# setting the last revision on a tree independently of that on the
|
433 |
# branch. Its concievable that some future formats may want to
|
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
434 |
# couple them again (i.e. because its really a smart server and
|
435 |
# the working tree will always match the branch). So we test
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
436 |
# that formats where initialising a branch does not initialise a
|
437 |
# tree - and thus have separable entities - support skewing the
|
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
438 |
# two things.
|
439 |
main_branch = self.make_branch('tree') |
|
440 |
try: |
|
441 |
# if there is a working tree now, this is not supported.
|
|
442 |
main_branch.bzrdir.open_workingtree() |
|
443 |
return
|
|
444 |
except errors.NoWorkingTree: |
|
445 |
pass
|
|
446 |
wt = main_branch.bzrdir.create_workingtree() |
|
447 |
# create an out of date working tree by making a checkout in this
|
|
448 |
# current format
|
|
449 |
self.build_tree(['checkout/', 'tree/file']) |
|
450 |
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout') |
|
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
451 |
branch.BranchReferenceFormat().initialize(checkout, |
452 |
target_branch=main_branch) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
453 |
old_tree = self.workingtree_format.initialize(checkout) |
454 |
# now commit to 'tree'
|
|
455 |
wt.add('file') |
|
456 |
wt.commit('A', rev_id='A') |
|
457 |
# and update old_tree
|
|
458 |
self.assertEqual(0, old_tree.update()) |
|
459 |
self.failUnlessExists('checkout/file') |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
460 |
self.assertEqual(['A'], old_tree.get_parent_ids()) |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
461 |
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
462 |
def test_update_sets_root_id(self): |
463 |
"""Ensure tree root is set properly by update. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
464 |
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
465 |
Since empty trees don't have root_ids, but workingtrees do,
|
466 |
an update of a checkout of revision 0 to a new revision, should set
|
|
467 |
the root id.
|
|
468 |
"""
|
|
469 |
wt = self.make_branch_and_tree('tree') |
|
470 |
main_branch = wt.branch |
|
471 |
# create an out of date working tree by making a checkout in this
|
|
472 |
# current format
|
|
473 |
self.build_tree(['checkout/', 'tree/file']) |
|
|
1731.1.43
by Aaron Bentley
Merge more checkout changes |
474 |
checkout = main_branch.create_checkout('checkout') |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
475 |
# now commit to 'tree'
|
476 |
wt.add('file') |
|
477 |
wt.commit('A', rev_id='A') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
478 |
# and update checkout
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
479 |
self.assertEqual(0, checkout.update()) |
480 |
self.failUnlessExists('checkout/file') |
|
481 |
self.assertEqual(wt.get_root_id(), checkout.get_root_id()) |
|
482 |
self.assertNotEqual(None, wt.get_root_id()) |
|
483 |
||
|
4634.123.1
by John Arbash Meinel
Add a failing test for 'update'. When this branch lands, update should work. |
484 |
def test_update_sets_updated_root_id(self): |
485 |
wt = self.make_branch_and_tree('tree') |
|
486 |
wt.set_root_id('first_root_id') |
|
487 |
self.assertEqual('first_root_id', wt.get_root_id()) |
|
488 |
self.build_tree(['tree/file']) |
|
489 |
wt.add(['file']) |
|
490 |
wt.commit('first') |
|
491 |
co = wt.branch.create_checkout('checkout') |
|
492 |
wt.set_root_id('second_root_id') |
|
493 |
wt.commit('second') |
|
494 |
self.assertEqual('second_root_id', wt.get_root_id()) |
|
495 |
self.assertEqual(0, co.update()) |
|
496 |
self.assertEqual('second_root_id', co.get_root_id()) |
|
497 |
||
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
498 |
def test_update_returns_conflict_count(self): |
499 |
# working tree formats from the meta-dir format and newer support
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
500 |
# setting the last revision on a tree independently of that on the
|
501 |
# branch. Its concievable that some future formats may want to
|
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
502 |
# couple them again (i.e. because its really a smart server and
|
503 |
# the working tree will always match the branch). So we test
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
504 |
# that formats where initialising a branch does not initialise a
|
505 |
# tree - and thus have separable entities - support skewing the
|
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
506 |
# two things.
|
507 |
main_branch = self.make_branch('tree') |
|
508 |
try: |
|
509 |
# if there is a working tree now, this is not supported.
|
|
510 |
main_branch.bzrdir.open_workingtree() |
|
511 |
return
|
|
512 |
except errors.NoWorkingTree: |
|
513 |
pass
|
|
514 |
wt = main_branch.bzrdir.create_workingtree() |
|
515 |
# create an out of date working tree by making a checkout in this
|
|
516 |
# current format
|
|
517 |
self.build_tree(['checkout/', 'tree/file']) |
|
518 |
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout') |
|
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
519 |
branch.BranchReferenceFormat().initialize(checkout, |
520 |
target_branch=main_branch) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
521 |
old_tree = self.workingtree_format.initialize(checkout) |
522 |
# now commit to 'tree'
|
|
523 |
wt.add('file') |
|
524 |
wt.commit('A', rev_id='A') |
|
525 |
# and add a file file to the checkout
|
|
526 |
self.build_tree(['checkout/file']) |
|
527 |
old_tree.add('file') |
|
528 |
# and update old_tree
|
|
529 |
self.assertEqual(1, old_tree.update()) |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
530 |
self.assertEqual(['A'], old_tree.get_parent_ids()) |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
531 |
|
|
1534.7.199
by Aaron Bentley
Moved merge/revert tests into test_workingtree.py |
532 |
def test_merge_revert(self): |
533 |
from bzrlib.merge import merge_inner |
|
534 |
this = self.make_branch_and_tree('b1') |
|
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
535 |
self.build_tree_contents([('b1/a', 'a test\n'), ('b1/b', 'b test\n')]) |
536 |
this.add(['a', 'b']) |
|
|
1534.7.199
by Aaron Bentley
Moved merge/revert tests into test_workingtree.py |
537 |
this.commit(message='') |
538 |
base = this.bzrdir.clone('b2').open_workingtree() |
|
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
539 |
self.build_tree_contents([('b2/a', 'b test\n')]) |
|
1534.7.199
by Aaron Bentley
Moved merge/revert tests into test_workingtree.py |
540 |
other = this.bzrdir.clone('b3').open_workingtree() |
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
541 |
self.build_tree_contents([('b3/a', 'c test\n'), ('b3/c', 'c test\n')]) |
|
1534.7.199
by Aaron Bentley
Moved merge/revert tests into test_workingtree.py |
542 |
other.add('c') |
543 |
||
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
544 |
self.build_tree_contents([('b1/b', 'q test\n'), ('b1/d', 'd test\n')]) |
545 |
# Note: If we don't lock this before calling merge_inner, then we get a
|
|
546 |
# lock-contention failure. This probably indicates something
|
|
547 |
# weird going on inside merge_inner. Probably something about
|
|
548 |
# calling bt = this_tree.basis_tree() in one lock, and then
|
|
549 |
# locking both this_tree and bt separately, causing a dirstate
|
|
550 |
# locking race.
|
|
551 |
this.lock_write() |
|
552 |
self.addCleanup(this.unlock) |
|
|
1534.7.199
by Aaron Bentley
Moved merge/revert tests into test_workingtree.py |
553 |
merge_inner(this.branch, other, base, this_tree=this) |
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
554 |
a = open('b1/a', 'rb') |
555 |
try: |
|
556 |
self.assertNotEqual(a.read(), 'a test\n') |
|
557 |
finally: |
|
558 |
a.close() |
|
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
559 |
this.revert() |
|
4789.12.1
by John Arbash Meinel
Fix per_workingtree.test_workingtree.test_merge_revert |
560 |
self.assertFileEqual('a test\n', 'b1/a') |
561 |
self.failUnlessExists('b1/b.~1~') |
|
562 |
self.failIfExists('b1/c') |
|
563 |
self.failIfExists('b1/a.~1~') |
|
564 |
self.failUnlessExists('b1/d') |
|
|
1534.7.200
by Aaron Bentley
Merge from mainline |
565 |
|
|
1587.1.10
by Robert Collins
update updates working tree and branch together. |
566 |
def test_update_updates_bound_branch_no_local_commits(self): |
567 |
# doing an update in a tree updates the branch its bound to too.
|
|
568 |
master_tree = self.make_branch_and_tree('master') |
|
569 |
tree = self.make_branch_and_tree('tree') |
|
570 |
try: |
|
571 |
tree.branch.bind(master_tree.branch) |
|
572 |
except errors.UpgradeRequired: |
|
573 |
# legacy branches cannot bind
|
|
574 |
return
|
|
575 |
master_tree.commit('foo', rev_id='foo', allow_pointless=True) |
|
576 |
tree.update() |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
577 |
self.assertEqual(['foo'], tree.get_parent_ids()) |
|
1587.1.10
by Robert Collins
update updates working tree and branch together. |
578 |
self.assertEqual('foo', tree.branch.last_revision()) |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
579 |
|
580 |
def test_update_turns_local_commit_into_merge(self): |
|
581 |
# doing an update with a few local commits and no master commits
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
582 |
# makes pending-merges.
|
|
1587.1.13
by Robert Collins
Explain why update pivots more clearly in the relevant test. |
583 |
# this is done so that 'bzr update; bzr revert' will always produce
|
584 |
# an exact copy of the 'logical branch' - the referenced branch for
|
|
585 |
# a checkout, and the master for a bound branch.
|
|
586 |
# its possible that we should instead have 'bzr update' when there
|
|
587 |
# is nothing new on the master leave the current commits intact and
|
|
588 |
# alter 'revert' to revert to the master always. But for now, its
|
|
589 |
# good.
|
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
590 |
master_tree = self.make_branch_and_tree('master') |
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
591 |
master_tip = master_tree.commit('first master commit') |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
592 |
tree = self.make_branch_and_tree('tree') |
593 |
try: |
|
594 |
tree.branch.bind(master_tree.branch) |
|
595 |
except errors.UpgradeRequired: |
|
596 |
# legacy branches cannot bind
|
|
597 |
return
|
|
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
598 |
# sync with master
|
599 |
tree.update() |
|
600 |
# work locally
|
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
601 |
tree.commit('foo', rev_id='foo', allow_pointless=True, local=True) |
602 |
tree.commit('bar', rev_id='bar', allow_pointless=True, local=True) |
|
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
603 |
# sync with master prepatory to committing
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
604 |
tree.update() |
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
605 |
# which should have pivoted the local tip into a merge
|
606 |
self.assertEqual([master_tip, 'bar'], tree.get_parent_ids()) |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
607 |
# and the local branch history should match the masters now.
|
608 |
self.assertEqual(master_tree.branch.revision_history(), |
|
609 |
tree.branch.revision_history()) |
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
610 |
|
|
4916.1.7
by Martin Pool
Add per_workingtree test you can update to arbitrary revisions |
611 |
def test_update_takes_revision_parameter(self): |
612 |
wt = self.make_branch_and_tree('wt') |
|
613 |
self.build_tree_contents([('wt/a', 'old content')]) |
|
614 |
wt.add(['a']) |
|
615 |
rev1 = wt.commit('first master commit') |
|
616 |
self.build_tree_contents([('wt/a', 'new content')]) |
|
617 |
rev2 = wt.commit('second master commit') |
|
618 |
# https://bugs.edge.launchpad.net/bzr/+bug/45719/comments/20
|
|
619 |
# when adding 'update -r' we should make sure all wt formats support
|
|
620 |
# it
|
|
621 |
conflicts = wt.update(revision=rev1) |
|
622 |
self.assertFileEqual('old content', 'wt/a') |
|
623 |
self.assertEqual([rev1], wt.get_parent_ids()) |
|
624 |
||
|
2255.2.156
by Martin Pool
Merge WorkingTree implementation back from trunk |
625 |
def test_merge_modified_detects_corruption(self): |
626 |
# FIXME: This doesn't really test that it works; also this is not
|
|
627 |
# implementation-independent. mbp 20070226
|
|
|
1558.3.3
by Aaron Bentley
Fix error handling for merge_modified |
628 |
tree = self.make_branch_and_tree('master') |
|
3407.2.7
by Martin Pool
Deprecate LockableFiles.put_utf8 and put_bytes. |
629 |
tree._transport.put_bytes('merge-hashes', 'asdfasdf') |
|
1558.3.3
by Aaron Bentley
Fix error handling for merge_modified |
630 |
self.assertRaises(errors.MergeModifiedFormatError, tree.merge_modified) |
|
1534.10.8
by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree |
631 |
|
|
2298.1.1
by Martin Pool
Add test for merge_modified |
632 |
def test_merge_modified(self): |
633 |
# merge_modified stores a map from file id to hash
|
|
634 |
tree = self.make_branch_and_tree('tree') |
|
635 |
d = {'file-id': osutils.sha_string('hello')} |
|
636 |
self.build_tree_contents([('tree/somefile', 'hello')]) |
|
637 |
tree.lock_write() |
|
638 |
try: |
|
639 |
tree.add(['somefile'], ['file-id']) |
|
640 |
tree.set_merge_modified(d) |
|
641 |
mm = tree.merge_modified() |
|
642 |
self.assertEquals(mm, d) |
|
643 |
finally: |
|
644 |
tree.unlock() |
|
645 |
mm = tree.merge_modified() |
|
646 |
self.assertEquals(mm, d) |
|
647 |
||
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
648 |
def test_conflicts(self): |
|
1534.10.8
by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree |
649 |
from bzrlib.tests.test_conflicts import example_conflicts |
650 |
tree = self.make_branch_and_tree('master') |
|
651 |
try: |
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
652 |
tree.set_conflicts(example_conflicts) |
|
1534.10.8
by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree |
653 |
except UnsupportedOperation: |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
654 |
raise TestSkipped('set_conflicts not supported') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
655 |
|
|
1534.10.8
by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree |
656 |
tree2 = WorkingTree.open('master') |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
657 |
self.assertEqual(tree2.conflicts(), example_conflicts) |
|
3407.2.7
by Martin Pool
Deprecate LockableFiles.put_utf8 and put_bytes. |
658 |
tree2._transport.put_bytes('conflicts', '') |
659 |
self.assertRaises(errors.ConflictFormatError, |
|
|
1955.3.14
by John Arbash Meinel
Correctly fix the workingtree put() test fixes |
660 |
tree2.conflicts) |
|
3407.2.7
by Martin Pool
Deprecate LockableFiles.put_utf8 and put_bytes. |
661 |
tree2._transport.put_bytes('conflicts', 'a') |
662 |
self.assertRaises(errors.ConflictFormatError, |
|
|
1955.3.14
by John Arbash Meinel
Correctly fix the workingtree put() test fixes |
663 |
tree2.conflicts) |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
664 |
|
665 |
def make_merge_conflicts(self): |
|
|
2255.2.32
by Robert Collins
Make test_clear_merge_conflicts pass for dirstate. This involved working |
666 |
from bzrlib.merge import merge_inner |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
667 |
tree = self.make_branch_and_tree('mine') |
668 |
file('mine/bloo', 'wb').write('one') |
|
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
669 |
file('mine/blo', 'wb').write('on') |
|
2255.2.32
by Robert Collins
Make test_clear_merge_conflicts pass for dirstate. This involved working |
670 |
tree.add(['bloo', 'blo']) |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
671 |
tree.commit("blah", allow_pointless=False) |
|
2255.5.3
by John Arbash Meinel
XXX Workaround the DirStateRevisionTree bug until we get a proper fix, tests pass again |
672 |
base = tree.branch.repository.revision_tree(tree.last_revision()) |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
673 |
bzrdir.BzrDir.open("mine").sprout("other") |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
674 |
file('other/bloo', 'wb').write('two') |
675 |
othertree = WorkingTree.open('other') |
|
676 |
othertree.commit('blah', allow_pointless=False) |
|
677 |
file('mine/bloo', 'wb').write('three') |
|
678 |
tree.commit("blah", allow_pointless=False) |
|
679 |
merge_inner(tree.branch, othertree, base, this_tree=tree) |
|
680 |
return tree |
|
681 |
||
682 |
def test_merge_conflicts(self): |
|
683 |
tree = self.make_merge_conflicts() |
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
684 |
self.assertEqual(len(tree.conflicts()), 1) |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
685 |
|
686 |
def test_clear_merge_conflicts(self): |
|
687 |
tree = self.make_merge_conflicts() |
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
688 |
self.assertEqual(len(tree.conflicts()), 1) |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
689 |
try: |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
690 |
tree.set_conflicts(ConflictList()) |
|
1534.10.12
by Aaron Bentley
Merge produces new conflicts |
691 |
except UnsupportedOperation: |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
692 |
raise TestSkipped('unsupported operation') |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
693 |
self.assertEqual(tree.conflicts(), ConflictList()) |
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
694 |
|
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
695 |
def test_add_conflicts(self): |
696 |
tree = self.make_branch_and_tree('tree') |
|
697 |
try: |
|
698 |
tree.add_conflicts([TextConflict('path_a')]) |
|
699 |
except UnsupportedOperation: |
|
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
700 |
raise TestSkipped('unsupported operation') |
|
1551.7.13
by Aaron Bentley
Switched from actual, expected to expected, actual, for John. |
701 |
self.assertEqual(ConflictList([TextConflict('path_a')]), |
702 |
tree.conflicts()) |
|
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
703 |
tree.add_conflicts([TextConflict('path_a')]) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
704 |
self.assertEqual(ConflictList([TextConflict('path_a')]), |
|
1551.7.13
by Aaron Bentley
Switched from actual, expected to expected, actual, for John. |
705 |
tree.conflicts()) |
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
706 |
tree.add_conflicts([ContentsConflict('path_a')]) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
707 |
self.assertEqual(ConflictList([ContentsConflict('path_a'), |
|
1551.7.13
by Aaron Bentley
Switched from actual, expected to expected, actual, for John. |
708 |
TextConflict('path_a')]), |
709 |
tree.conflicts()) |
|
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
710 |
tree.add_conflicts([TextConflict('path_b')]) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
711 |
self.assertEqual(ConflictList([ContentsConflict('path_a'), |
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
712 |
TextConflict('path_a'), |
|
1551.7.13
by Aaron Bentley
Switched from actual, expected to expected, actual, for John. |
713 |
TextConflict('path_b')]), |
714 |
tree.conflicts()) |
|
|
1551.7.11
by Aaron Bentley
Add WorkingTree.add_conflicts |
715 |
|
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
716 |
def test_revert_clear_conflicts(self): |
717 |
tree = self.make_merge_conflicts() |
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
718 |
self.assertEqual(len(tree.conflicts()), 1) |
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
719 |
tree.revert(["blo"]) |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
720 |
self.assertEqual(len(tree.conflicts()), 1) |
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
721 |
tree.revert(["bloo"]) |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
722 |
self.assertEqual(len(tree.conflicts()), 0) |
|
1534.10.14
by Aaron Bentley
Made revert clear conflicts |
723 |
|
724 |
def test_revert_clear_conflicts2(self): |
|
725 |
tree = self.make_merge_conflicts() |
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
726 |
self.assertEqual(len(tree.conflicts()), 1) |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
727 |
tree.revert() |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
728 |
self.assertEqual(len(tree.conflicts()), 0) |
|
1624.3.22
by Olaf Conradi
Merge bzr.dev |
729 |
|
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
730 |
def test_format_description(self): |
731 |
tree = self.make_branch_and_tree('tree') |
|
732 |
text = tree._format.get_format_description() |
|
733 |
self.failUnless(len(text)) |
|
|
1681.1.1
by Robert Collins
Make WorkingTree.branch a read only property. (Robert Collins) |
734 |
|
735 |
def test_branch_attribute_is_not_settable(self): |
|
736 |
# the branch attribute is an aspect of the working tree, not a
|
|
737 |
# configurable attribute
|
|
738 |
tree = self.make_branch_and_tree('tree') |
|
739 |
def set_branch(): |
|
740 |
tree.branch = tree.branch |
|
741 |
self.assertRaises(AttributeError, set_branch) |
|
742 |
||
|
1713.3.1
by Robert Collins
Smoke tests for tree.list_files and bzr ignored when a versioned file matches an ignore rule. |
743 |
def test_list_files_versioned_before_ignored(self): |
744 |
"""A versioned file matching an ignore rule should not be ignored.""" |
|
745 |
tree = self.make_branch_and_tree('.') |
|
746 |
self.build_tree(['foo.pyc']) |
|
747 |
# ensure that foo.pyc is ignored
|
|
748 |
self.build_tree_contents([('.bzrignore', 'foo.pyc')]) |
|
749 |
tree.add('foo.pyc', 'anid') |
|
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
750 |
tree.lock_read() |
|
1713.3.1
by Robert Collins
Smoke tests for tree.list_files and bzr ignored when a versioned file matches an ignore rule. |
751 |
files = sorted(list(tree.list_files())) |
|
2255.2.52
by Robert Collins
Dirstate - fix workingtree.list_files to use the public interface to access the trees inventory. |
752 |
tree.unlock() |
|
1713.3.1
by Robert Collins
Smoke tests for tree.list_files and bzr ignored when a versioned file matches an ignore rule. |
753 |
self.assertEqual((u'.bzrignore', '?', 'file', None), files[0][:-1]) |
754 |
self.assertEqual((u'foo.pyc', 'V', 'file', 'anid'), files[1][:-1]) |
|
755 |
self.assertEqual(2, len(files)) |
|
|
1711.8.2
by John Arbash Meinel
Test that WorkingTree locks Branch before self, and unlocks self before Branch |
756 |
|
|
1830.3.7
by John Arbash Meinel
Check that WorkingTree.add does the right thing. |
757 |
def test_non_normalized_add_accessible(self): |
758 |
try: |
|
759 |
self.build_tree([u'a\u030a']) |
|
760 |
except UnicodeError: |
|
761 |
raise TestSkipped('Filesystem does not support unicode filenames') |
|
762 |
tree = self.make_branch_and_tree('.') |
|
763 |
orig = osutils.normalized_filename |
|
764 |
osutils.normalized_filename = osutils._accessible_normalized_filename |
|
765 |
try: |
|
766 |
tree.add([u'a\u030a']) |
|
|
2255.2.58
by Robert Collins
Fix the way we used osutils.normalized_filename in dirstate to support overriding in tests - and document this in the original location it was used. |
767 |
tree.lock_read() |
|
1907.1.3
by Aaron Bentley
Fixed unicode test cases |
768 |
self.assertEqual([('', 'directory'), (u'\xe5', 'file')], |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
769 |
[(path, ie.kind) for path,ie in |
|
1830.3.17
by John Arbash Meinel
list_files() with wrong normalized_filename code raises exceptions. Fix this |
770 |
tree.inventory.iter_entries()]) |
|
2255.2.58
by Robert Collins
Fix the way we used osutils.normalized_filename in dirstate to support overriding in tests - and document this in the original location it was used. |
771 |
tree.unlock() |
|
1830.3.7
by John Arbash Meinel
Check that WorkingTree.add does the right thing. |
772 |
finally: |
773 |
osutils.normalized_filename = orig |
|
774 |
||
775 |
def test_non_normalized_add_inaccessible(self): |
|
776 |
try: |
|
777 |
self.build_tree([u'a\u030a']) |
|
778 |
except UnicodeError: |
|
779 |
raise TestSkipped('Filesystem does not support unicode filenames') |
|
780 |
tree = self.make_branch_and_tree('.') |
|
781 |
orig = osutils.normalized_filename |
|
782 |
osutils.normalized_filename = osutils._inaccessible_normalized_filename |
|
783 |
try: |
|
784 |
self.assertRaises(errors.InvalidNormalization, |
|
785 |
tree.add, [u'a\u030a']) |
|
786 |
finally: |
|
787 |
osutils.normalized_filename = orig |
|
|
2123.3.9
by Steffen Eichenberg
added tests for deprecated API workingtree.move |
788 |
|
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
789 |
def test__write_inventory(self): |
790 |
# The private interface _write_inventory is currently used by transform.
|
|
791 |
tree = self.make_branch_and_tree('.') |
|
792 |
# if we write write an inventory then do a walkdirs we should get back
|
|
793 |
# missing entries, and actual, and unknowns as appropriate.
|
|
794 |
self.build_tree(['present', 'unknown']) |
|
|
2946.3.3
by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('') |
795 |
inventory = Inventory(tree.get_root_id()) |
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
796 |
inventory.add_path('missing', 'file', 'missing-id') |
797 |
inventory.add_path('present', 'file', 'present-id') |
|
|
2255.2.28
by Robert Collins
TestWorkingTree.test__write_inventory needs to lock the tree before calling _write_inventory for dirstate. |
798 |
# there is no point in being able to write an inventory to an unlocked
|
799 |
# tree object - its a low level api not a convenience api.
|
|
800 |
tree.lock_write() |
|
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
801 |
tree._write_inventory(inventory) |
|
2255.2.28
by Robert Collins
TestWorkingTree.test__write_inventory needs to lock the tree before calling _write_inventory for dirstate. |
802 |
tree.unlock() |
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
803 |
tree.lock_read() |
804 |
try: |
|
805 |
present_stat = os.lstat('present') |
|
806 |
unknown_stat = os.lstat('unknown') |
|
807 |
expected_results = [ |
|
|
2946.3.3
by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('') |
808 |
(('', tree.get_root_id()), |
|
1852.15.14
by Robert Collins
test that WorkingTree._write_inventory works as expected by the current code. |
809 |
[('missing', 'missing', 'unknown', None, 'missing-id', 'file'), |
810 |
('present', 'present', 'file', present_stat, 'present-id', 'file'), |
|
811 |
('unknown', 'unknown', 'file', unknown_stat, None, None), |
|
812 |
]
|
|
813 |
)]
|
|
814 |
self.assertEqual(expected_results, list(tree.walkdirs())) |
|
815 |
finally: |
|
816 |
tree.unlock() |
|
|
2255.7.56
by Robert Collins
Document behaviour of tree.path2id("path/"). |
817 |
|
818 |
def test_path2id(self): |
|
|
2255.7.62
by Robert Collins
Update the Tree.filter_unversioned_files docstring to reflect what the existing implementations actually do, and change the WorkingTree4 implementation to match a newly created test for it. |
819 |
# smoke test for path2id
|
|
2255.7.56
by Robert Collins
Document behaviour of tree.path2id("path/"). |
820 |
tree = self.make_branch_and_tree('.') |
821 |
self.build_tree(['foo']) |
|
822 |
tree.add(['foo'], ['foo-id']) |
|
823 |
self.assertEqual('foo-id', tree.path2id('foo')) |
|
824 |
# the next assertion is for backwards compatability with WorkingTree3,
|
|
825 |
# though its probably a bad idea, it makes things work. Perhaps
|
|
826 |
# it should raise a deprecation warning?
|
|
827 |
self.assertEqual('foo-id', tree.path2id('foo/')) |
|
|
2255.7.62
by Robert Collins
Update the Tree.filter_unversioned_files docstring to reflect what the existing implementations actually do, and change the WorkingTree4 implementation to match a newly created test for it. |
828 |
|
829 |
def test_filter_unversioned_files(self): |
|
830 |
# smoke test for filter_unversioned_files
|
|
831 |
tree = self.make_branch_and_tree('.') |
|
832 |
paths = ['here-and-versioned', 'here-and-not-versioned', |
|
833 |
'not-here-and-versioned', 'not-here-and-not-versioned'] |
|
834 |
tree.add(['here-and-versioned', 'not-here-and-versioned'], |
|
835 |
kinds=['file', 'file']) |
|
836 |
self.build_tree(['here-and-versioned', 'here-and-not-versioned']) |
|
837 |
tree.lock_read() |
|
838 |
self.addCleanup(tree.unlock) |
|
839 |
self.assertEqual( |
|
840 |
set(['not-here-and-not-versioned', 'here-and-not-versioned']), |
|
841 |
tree.filter_unversioned_files(paths)) |
|
|
2255.2.200
by Martin Pool
Add simple test for WorkingTree.kind |
842 |
|
843 |
def test_detect_real_kind(self): |
|
844 |
# working trees report the real kind of the file on disk, not the kind
|
|
845 |
# they had when they were first added
|
|
846 |
# create one file of every interesting type
|
|
847 |
tree = self.make_branch_and_tree('.') |
|
|
4100.2.2
by Aaron Bentley
Remove locking decorator |
848 |
tree.lock_write() |
849 |
self.addCleanup(tree.unlock) |
|
|
2255.2.200
by Martin Pool
Add simple test for WorkingTree.kind |
850 |
self.build_tree(['file', 'directory/']) |
851 |
names = ['file', 'directory'] |
|
852 |
if has_symlinks(): |
|
853 |
os.symlink('target', 'symlink') |
|
854 |
names.append('symlink') |
|
855 |
tree.add(names, [n + '-id' for n in names]) |
|
856 |
# now when we first look, we should see everything with the same kind
|
|
857 |
# with which they were initially added
|
|
858 |
for n in names: |
|
859 |
actual_kind = tree.kind(n + '-id') |
|
860 |
self.assertEqual(n, actual_kind) |
|
861 |
# move them around so the names no longer correspond to the types
|
|
862 |
os.rename(names[0], 'tmp') |
|
863 |
for i in range(1, len(names)): |
|
864 |
os.rename(names[i], names[i-1]) |
|
865 |
os.rename('tmp', names[-1]) |
|
|
2255.2.202
by Martin Pool
WorkingTree_4.kind should report tree-references if they're |
866 |
# now look and expect to see the correct types again
|
867 |
for i in range(len(names)): |
|
868 |
actual_kind = tree.kind(names[i-1] + '-id') |
|
869 |
expected_kind = names[i] |
|
870 |
self.assertEqual(expected_kind, actual_kind) |
|
|
2499.3.1
by Aaron Bentley
Fix Workingtree4.get_file_sha1 on missing files |
871 |
|
|
3146.8.4
by Aaron Bentley
Eliminate direct use of inventory from transform application |
872 |
def test_stored_kind_with_missing(self): |
873 |
tree = self.make_branch_and_tree('tree') |
|
874 |
tree.lock_write() |
|
875 |
self.addCleanup(tree.unlock) |
|
876 |
self.build_tree(['tree/a', 'tree/b/']) |
|
877 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
878 |
os.unlink('tree/a') |
|
879 |
os.rmdir('tree/b') |
|
880 |
self.assertEqual('file', tree.stored_kind('a-id')) |
|
881 |
self.assertEqual('directory', tree.stored_kind('b-id')) |
|
882 |
||
|
2499.3.1
by Aaron Bentley
Fix Workingtree4.get_file_sha1 on missing files |
883 |
def test_missing_file_sha1(self): |
884 |
"""If a file is missing, its sha1 should be reported as None.""" |
|
885 |
tree = self.make_branch_and_tree('.') |
|
886 |
tree.lock_write() |
|
887 |
self.addCleanup(tree.unlock) |
|
888 |
self.build_tree(['file']) |
|
889 |
tree.add('file', 'file-id') |
|
890 |
tree.commit('file added') |
|
891 |
os.unlink('file') |
|
892 |
self.assertIs(None, tree.get_file_sha1('file-id')) |
|
|
1551.15.56
by Aaron Bentley
Raise NoSuchId when get_file_sha1 is invoked with a baed file id |
893 |
|
894 |
def test_no_file_sha1(self): |
|
895 |
"""If a file is not present, get_file_sha1 should raise NoSuchId""" |
|
896 |
tree = self.make_branch_and_tree('.') |
|
897 |
tree.lock_write() |
|
898 |
self.addCleanup(tree.unlock) |
|
899 |
self.assertRaises(errors.NoSuchId, tree.get_file_sha1, 'file-id') |
|
900 |
self.build_tree(['file']) |
|
901 |
tree.add('file', 'file-id') |
|
902 |
tree.commit('foo') |
|
903 |
tree.remove('file') |
|
904 |
self.assertRaises(errors.NoSuchId, tree.get_file_sha1, 'file-id') |
|
|
3034.4.5
by Aaron Bentley
Add workingtree test for case_insensitive var |
905 |
|
906 |
def test_case_sensitive(self): |
|
907 |
"""If filesystem is case-sensitive, tree should report this. |
|
908 |
||
909 |
We check case-sensitivity by creating a file with a lowercase name,
|
|
910 |
then testing whether it exists with an uppercase name.
|
|
911 |
"""
|
|
|
3034.4.9
by Alexander Belchenko
skip test_workingtree.TestWorkingTree.test_case_sensitive for WT2 |
912 |
self.build_tree(['filename']) |
|
3034.4.5
by Aaron Bentley
Add workingtree test for case_insensitive var |
913 |
if os.path.exists('FILENAME'): |
914 |
case_sensitive = False |
|
915 |
else: |
|
916 |
case_sensitive = True |
|
917 |
tree = self.make_branch_and_tree('test') |
|
|
3034.4.9
by Alexander Belchenko
skip test_workingtree.TestWorkingTree.test_case_sensitive for WT2 |
918 |
if tree.__class__ == WorkingTree2: |
919 |
raise TestSkipped('WorkingTree2 is not supported') |
|
|
3034.4.5
by Aaron Bentley
Add workingtree test for case_insensitive var |
920 |
self.assertEqual(case_sensitive, tree.case_sensitive) |
|
3146.8.2
by Aaron Bentley
Introduce iter_all_file_ids, to avoid hitting Inventory for this case |
921 |
|
|
3146.8.16
by Aaron Bentley
Updates from review |
922 |
def test_all_file_ids_with_missing(self): |
|
3146.8.2
by Aaron Bentley
Introduce iter_all_file_ids, to avoid hitting Inventory for this case |
923 |
tree = self.make_branch_and_tree('tree') |
924 |
tree.lock_write() |
|
925 |
self.addCleanup(tree.unlock) |
|
926 |
self.build_tree(['tree/a', 'tree/b']) |
|
927 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
928 |
os.unlink('tree/a') |
|
929 |
self.assertEqual(set(['a-id', 'b-id', tree.get_root_id()]), |
|
|
3146.8.16
by Aaron Bentley
Updates from review |
930 |
tree.all_file_ids()) |
|
3146.8.19
by Aaron Bentley
Merge with bzr.dev |
931 |
|
|
3136.1.10
by Aaron Bentley
Clean error if filesystem does not support hard-links |
932 |
def test_sprout_hardlink(self): |
|
3619.6.9
by Mark Hammond
Move check for os.link to the start of the test |
933 |
real_os_link = getattr(os, 'link', None) |
934 |
if real_os_link is None: |
|
935 |
raise TestNotApplicable("This platform doesn't provide os.link") |
|
|
3136.1.10
by Aaron Bentley
Clean error if filesystem does not support hard-links |
936 |
source = self.make_branch_and_tree('source') |
937 |
self.build_tree(['source/file']) |
|
938 |
source.add('file') |
|
939 |
source.commit('added file') |
|
940 |
def fake_link(source, target): |
|
941 |
raise OSError(errno.EPERM, 'Operation not permitted') |
|
942 |
os.link = fake_link |
|
943 |
try: |
|
944 |
# Hard-link support is optional, so supplying hardlink=True may
|
|
945 |
# or may not raise an exception. But if it does, it must be
|
|
946 |
# HardLinkNotSupported
|
|
947 |
try: |
|
948 |
source.bzrdir.sprout('target', accelerator_tree=source, |
|
949 |
hardlink=True) |
|
950 |
except errors.HardLinkNotSupported: |
|
951 |
pass
|
|
952 |
finally: |
|
953 |
os.link = real_os_link |
|
|
3287.20.3
by John Arbash Meinel
Aaron recommended to make this a WT_impl test. |
954 |
|
955 |
||
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
956 |
class TestWorkingTreeUpdate(TestCaseWithWorkingTree): |
957 |
||
958 |
def make_diverged_master_branch(self): |
|
959 |
""" |
|
960 |
B: wt.branch.last_revision()
|
|
961 |
M: wt.branch.get_master_branch().last_revision()
|
|
962 |
W: wt.last_revision()
|
|
963 |
||
964 |
||
965 |
1
|
|
966 |
|\
|
|
967 |
B-2 3
|
|
968 |
| |
|
|
969 |
4 5-M
|
|
970 |
|
|
|
971 |
W
|
|
972 |
"""
|
|
973 |
builder = branchbuilder.BranchBuilder( |
|
974 |
self.get_transport(), |
|
975 |
format=self.workingtree_format._matchingbzrdir) |
|
976 |
builder.start_series() |
|
977 |
# mainline
|
|
978 |
builder.build_snapshot( |
|
979 |
'1', None, |
|
980 |
[('add', ('', 'root-id', 'directory', '')), |
|
981 |
('add', ('file1', 'file1-id', 'file', 'file1 content\n'))]) |
|
982 |
# branch
|
|
983 |
builder.build_snapshot('2', ['1'], []) |
|
984 |
builder.build_snapshot( |
|
985 |
'4', ['2'], |
|
986 |
[('add', ('file4', 'file4-id', 'file', 'file4 content\n'))]) |
|
987 |
# master
|
|
988 |
builder.build_snapshot('3', ['1'], []) |
|
989 |
builder.build_snapshot( |
|
990 |
'5', ['3'], |
|
991 |
[('add', ('file5', 'file5-id', 'file', 'file5 content\n'))]) |
|
992 |
builder.finish_series() |
|
993 |
return builder, builder._branch.last_revision() |
|
994 |
||
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
995 |
def make_checkout_and_master(self, builder, wt_path, master_path, wt_revid, |
996 |
master_revid=None, branch_revid=None): |
|
997 |
"""Build a lightweight checkout and its master branch.""" |
|
998 |
if master_revid is None: |
|
999 |
master_revid = wt_revid |
|
1000 |
if branch_revid is None: |
|
1001 |
branch_revid = master_revid |
|
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1002 |
final_branch = builder.get_branch() |
1003 |
# The master branch
|
|
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1004 |
master = final_branch.bzrdir.sprout(master_path, |
1005 |
master_revid).open_branch() |
|
1006 |
# The checkout
|
|
1007 |
wt = self.make_branch_and_tree(wt_path) |
|
1008 |
wt.pull(final_branch, stop_revision=wt_revid) |
|
1009 |
wt.branch.pull(final_branch, stop_revision=branch_revid, overwrite=True) |
|
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1010 |
try: |
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1011 |
wt.branch.bind(master) |
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1012 |
except errors.UpgradeRequired: |
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1013 |
raise TestNotApplicable( |
1014 |
"Can't bind %s" % wt.branch._format.__class__) |
|
1015 |
return wt, master |
|
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1016 |
|
1017 |
def test_update_remove_commit(self): |
|
1018 |
"""Update should remove revisions when the branch has removed |
|
1019 |
some commits.
|
|
1020 |
||
1021 |
We want to revert 4, so that strating with the
|
|
1022 |
make_diverged_master_branch() graph the final result should be
|
|
1023 |
equivalent to:
|
|
1024 |
||
1025 |
1
|
|
1026 |
|\
|
|
1027 |
3 2
|
|
1028 |
| |\
|
|
1029 |
MB-5 | 4
|
|
1030 |
|/
|
|
1031 |
W
|
|
1032 |
||
1033 |
And the changes in 4 have been removed from the WT.
|
|
1034 |
"""
|
|
1035 |
builder, tip = self.make_diverged_master_branch() |
|
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1036 |
wt, master = self.make_checkout_and_master( |
1037 |
builder, 'checkout', 'master', '4', |
|
1038 |
master_revid=tip, branch_revid='2') |
|
|
4985.3.19
by Vincent Ladeuil
Make the test more precise. |
1039 |
# First update the branch
|
1040 |
old_tip = wt.branch.update() |
|
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1041 |
self.assertEqual('2', old_tip) |
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1042 |
# No conflicts should occur
|
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1043 |
self.assertEqual(0, wt.update(old_tip=old_tip)) |
|
4985.3.19
by Vincent Ladeuil
Make the test more precise. |
1044 |
# We are in sync with the master
|
1045 |
self.assertEqual(tip, wt.branch.last_revision()) |
|
|
4985.3.20
by Vincent Ladeuil
Remove the blackbox test and fix typo. |
1046 |
# We have the right parents ready to be committed
|
|
4985.3.19
by Vincent Ladeuil
Make the test more precise. |
1047 |
self.assertEqual(['5', '2'], wt.get_parent_ids()) |
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1048 |
|
|
4985.3.21
by Vincent Ladeuil
Final cleanup. |
1049 |
def test_update_revision(self): |
1050 |
builder, tip = self.make_diverged_master_branch() |
|
1051 |
wt, master = self.make_checkout_and_master( |
|
1052 |
builder, 'checkout', 'master', '4', |
|
1053 |
master_revid=tip, branch_revid='2') |
|
1054 |
self.assertEqual(0, wt.update(revision='1')) |
|
1055 |
self.assertEqual('1', wt.last_revision()) |
|
1056 |
self.assertEqual(tip, wt.branch.last_revision()) |
|
1057 |
self.failUnlessExists('checkout/file1') |
|
1058 |
self.failIfExists('checkout/file4') |
|
1059 |
self.failIfExists('checkout/file5') |
|
1060 |
||
|
4985.3.18
by Vincent Ladeuil
Start rewriting the test. |
1061 |
|
|
3287.20.3
by John Arbash Meinel
Aaron recommended to make this a WT_impl test. |
1062 |
class TestIllegalPaths(TestCaseWithWorkingTree): |
1063 |
||
1064 |
def test_bad_fs_path(self): |
|
|
3638.3.14
by Vincent Ladeuil
Make test_bad_fs_path not applicable on OSX. |
1065 |
if osutils.normalizes_filenames(): |
1066 |
# You *can't* create an illegal filename on OSX.
|
|
1067 |
raise tests.TestNotApplicable('OSX normalizes filenames') |
|
|
3287.20.3
by John Arbash Meinel
Aaron recommended to make this a WT_impl test. |
1068 |
self.requireFeature(tests.UTF8Filesystem) |
1069 |
# We require a UTF8 filesystem, because otherwise we would need to get
|
|
1070 |
# tricky to figure out how to create an illegal filename.
|
|
1071 |
# \xb5 is an illegal path because it should be \xc2\xb5 for UTF-8
|
|
1072 |
tree = self.make_branch_and_tree('tree') |
|
1073 |
self.build_tree(['tree/subdir/']) |
|
1074 |
tree.add('subdir') |
|
1075 |
||
1076 |
f = open('tree/subdir/m\xb5', 'wb') |
|
1077 |
try: |
|
1078 |
f.write('trivial\n') |
|
1079 |
finally: |
|
1080 |
f.close() |
|
1081 |
||
1082 |
tree.lock_read() |
|
1083 |
self.addCleanup(tree.unlock) |
|
1084 |
basis = tree.basis_tree() |
|
1085 |
basis.lock_read() |
|
1086 |
self.addCleanup(basis.unlock) |
|
1087 |
||
1088 |
e = self.assertListRaises(errors.BadFilenameEncoding, |
|
1089 |
tree.iter_changes, tree.basis_tree(), |
|
1090 |
want_unversioned=True) |
|
1091 |
# We should display the relative path
|
|
1092 |
self.assertEqual('subdir/m\xb5', e.filename) |
|
1093 |
self.assertEqual(osutils._fs_enc, e.fs_encoding) |