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