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