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
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
16 |
|
17 |
"""Tests for repository commit builder."""
|
|
18 |
||
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
19 |
import os |
2831.5.1
by Vincent Ladeuil
Portability fix in TestCommitBuilder for unlink. |
20 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import ( |
5609.31.2
by mbp at sourcefrog
Also turn off whoami inference in per_repository tests |
22 |
config, |
2831.5.1
by Vincent Ladeuil
Portability fix in TestCommitBuilder for unlink. |
23 |
errors, |
24 |
osutils, |
|
25 |
repository, |
|
3668.5.1
by Jelmer Vernooij
Use NULL_REVISION rather than None for Repository.revision_tree(). |
26 |
revision as _mod_revision, |
2831.5.1
by Vincent Ladeuil
Portability fix in TestCommitBuilder for unlink. |
27 |
tests, |
28 |
)
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
29 |
from breezy.bzr import ( |
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
30 |
inventorytree, |
6670.4.3
by Jelmer Vernooij
Fix more imports. |
31 |
)
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
32 |
from breezy.bzr.inventorytree import InventoryTreeChange |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
33 |
from breezy.tests import per_repository |
34 |
from breezy.tests import ( |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
35 |
features, |
36 |
)
|
|
5010.2.24
by Vincent Ladeuil
Fix imports in per_repository/test_commit_builder.py. |
37 |
|
7344.1.1
by Martin
Fix tests that need whoami not to be set |
38 |
from ..test_bedding import override_whoami |
39 |
||
5010.2.24
by Vincent Ladeuil
Fix imports in per_repository/test_commit_builder.py. |
40 |
|
41 |
class TestCommitBuilder(per_repository.TestCaseWithRepository): |
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
42 |
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
43 |
def test_get_commit_builder(self): |
2617.6.2
by Robert Collins
Add abort_write_group and wire write_groups into fetch and commit. |
44 |
branch = self.make_branch('.') |
45 |
branch.repository.lock_write() |
|
46 |
builder = branch.repository.get_commit_builder( |
|
6351.3.3
by Jelmer Vernooij
Convert more stuff to use config stacks. |
47 |
branch, [], branch.get_config_stack()) |
2831.5.1
by Vincent Ladeuil
Portability fix in TestCommitBuilder for unlink. |
48 |
self.assertIsInstance(builder, repository.CommitBuilder) |
2805.6.1
by Robert Collins
Set random_revid on CommitBuilder when a commit generated its own revision id. |
49 |
self.assertTrue(builder.random_revid) |
2617.6.2
by Robert Collins
Add abort_write_group and wire write_groups into fetch and commit. |
50 |
branch.repository.commit_write_group() |
51 |
branch.repository.unlock() |
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
52 |
|
3775.2.4
by Robert Collins
Start on a CommitBuilder.record_iter_changes method. |
53 |
def test_finish_inventory_record_iter_changes(self): |
54 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
55 |
with tree.lock_write(): |
3775.2.4
by Robert Collins
Start on a CommitBuilder.record_iter_changes method. |
56 |
builder = tree.branch.get_commit_builder([]) |
57 |
try: |
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
58 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
59 |
tree.iter_changes(tree.basis_tree()))) |
3775.2.4
by Robert Collins
Start on a CommitBuilder.record_iter_changes method. |
60 |
builder.finish_inventory() |
61 |
except: |
|
62 |
builder.abort() |
|
63 |
raise
|
|
64 |
repo = tree.branch.repository |
|
65 |
repo.commit_write_group() |
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
66 |
|
3775.2.5
by Robert Collins
CommitBuilder.abort() is callable after record_iter_changes. |
67 |
def test_abort_record_iter_changes(self): |
68 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
69 |
with tree.lock_write(): |
3775.2.5
by Robert Collins
CommitBuilder.abort() is callable after record_iter_changes. |
70 |
builder = tree.branch.get_commit_builder([]) |
71 |
try: |
|
3775.2.29
by Robert Collins
Updates to the form of add_inventory_by_delta that landed in trunk. |
72 |
basis = tree.basis_tree() |
73 |
last_rev = tree.last_revision() |
|
74 |
changes = tree.iter_changes(basis) |
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
75 |
list(builder.record_iter_changes(tree, last_rev, changes)) |
3775.2.5
by Robert Collins
CommitBuilder.abort() is callable after record_iter_changes. |
76 |
builder.finish_inventory() |
3775.2.29
by Robert Collins
Updates to the form of add_inventory_by_delta that landed in trunk. |
77 |
finally: |
3775.2.5
by Robert Collins
CommitBuilder.abort() is callable after record_iter_changes. |
78 |
builder.abort() |
79 |
||
5777.6.8
by Jelmer Vernooij
Add test for get_commit_builder(lossy=True). |
80 |
def test_commit_lossy(self): |
81 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
82 |
with tree.lock_write(): |
5777.6.8
by Jelmer Vernooij
Add test for get_commit_builder(lossy=True). |
83 |
builder = tree.branch.get_commit_builder([], lossy=True) |
84 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
85 |
tree.iter_changes(tree.basis_tree()))) |
5777.6.8
by Jelmer Vernooij
Add test for get_commit_builder(lossy=True). |
86 |
builder.finish_inventory() |
87 |
rev_id = builder.commit('foo bar blah') |
|
88 |
rev = tree.branch.repository.get_revision(rev_id) |
|
89 |
self.assertEqual('foo bar blah', rev.message) |
|
90 |
||
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
91 |
def test_commit_message(self): |
1740.3.7
by Jelmer Vernooij
Move committer, log, revprops, timestamp and timezone to CommitBuilder. |
92 |
tree = self.make_branch_and_tree(".") |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
93 |
with tree.lock_write(): |
2617.6.8
by Robert Collins
Review feedback and documentation. |
94 |
builder = tree.branch.get_commit_builder([]) |
5718.4.6
by Jelmer Vernooij
inline function only used once. |
95 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
96 |
tree.iter_changes(tree.basis_tree()))) |
5718.4.6
by Jelmer Vernooij
inline function only used once. |
97 |
builder.finish_inventory() |
2617.6.8
by Robert Collins
Review feedback and documentation. |
98 |
rev_id = builder.commit('foo bar blah') |
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
99 |
rev = tree.branch.repository.get_revision(rev_id) |
100 |
self.assertEqual('foo bar blah', rev.message) |
|
101 |
||
6217.5.1
by Jelmer Vernooij
Add CommitBuilder.updates_branch. |
102 |
def test_updates_branch(self): |
103 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
104 |
with tree.lock_write(): |
6217.5.1
by Jelmer Vernooij
Add CommitBuilder.updates_branch. |
105 |
builder = tree.branch.get_commit_builder([]) |
106 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
107 |
tree.iter_changes(tree.basis_tree()))) |
6217.5.1
by Jelmer Vernooij
Add CommitBuilder.updates_branch. |
108 |
builder.finish_inventory() |
109 |
will_update_branch = builder.updates_branch |
|
110 |
rev_id = builder.commit('might update the branch') |
|
111 |
actually_updated_branch = (tree.branch.last_revision() == rev_id) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
112 |
self.assertEqual(actually_updated_branch, will_update_branch) |
6217.5.1
by Jelmer Vernooij
Add CommitBuilder.updates_branch. |
113 |
|
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
114 |
def test_commit_with_revision_id_record_iter_changes(self): |
115 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
116 |
with tree.lock_write(): |
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
117 |
# use a unicode revision id to test more corner cases.
|
118 |
# The repository layer is meant to handle this.
|
|
119 |
revision_id = u'\xc8abc'.encode('utf8') |
|
120 |
try: |
|
121 |
try: |
|
122 |
builder = tree.branch.get_commit_builder([], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
123 |
revision_id=revision_id) |
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
124 |
except errors.NonAsciiRevisionId: |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
125 |
revision_id = b'abc' |
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
126 |
builder = tree.branch.get_commit_builder([], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
127 |
revision_id=revision_id) |
6747.1.1
by Jelmer Vernooij
Remove unnecessary ExcludesUnsupported exception. |
128 |
except repository.CannotSetRevisionId: |
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
129 |
# This format doesn't support supplied revision ids
|
130 |
return
|
|
131 |
self.assertFalse(builder.random_revid) |
|
132 |
try: |
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
133 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
134 |
tree.iter_changes(tree.basis_tree()))) |
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
135 |
builder.finish_inventory() |
136 |
except: |
|
137 |
builder.abort() |
|
138 |
raise
|
|
139 |
self.assertEqual(revision_id, builder.commit('foo bar')) |
|
140 |
self.assertTrue(tree.branch.repository.has_revision(revision_id)) |
|
141 |
# the revision id must be set on the inventory when saving it. This
|
|
142 |
# does not precisely test that - a repository that wants to can add it
|
|
143 |
# on deserialisation, but thats all the current contract guarantees
|
|
144 |
# anyway.
|
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
145 |
self.assertEqual( |
146 |
revision_id, |
|
147 |
tree.branch.repository.revision_tree(revision_id).get_revision_id()) |
|
3775.2.6
by Robert Collins
CommitBuilder can specify a revision_id with record_iter_changes. |
148 |
|
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
149 |
def test_commit_without_root_errors(self): |
150 |
tree = self.make_branch_and_tree(".") |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
151 |
with tree.lock_write(): |
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
152 |
builder = tree.branch.get_commit_builder([]) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
153 |
|
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
154 |
def do_commit(): |
155 |
try: |
|
156 |
list(builder.record_iter_changes( |
|
157 |
tree, tree.last_revision(), [])) |
|
158 |
builder.finish_inventory() |
|
159 |
except: |
|
160 |
builder.abort() |
|
161 |
raise
|
|
6202.2.1
by Jelmer Vernooij
Commit in commit builder test to prevent masking errors. |
162 |
else: |
163 |
builder.commit("msg") |
|
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
164 |
self.assertRaises(errors.RootMissing, do_commit) |
165 |
||
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
166 |
def test_commit_unchanged_root_record_iter_changes(self): |
167 |
tree = self.make_branch_and_tree(".") |
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
168 |
old_revision_id = tree.commit('oldrev') |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
169 |
tree.lock_write() |
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
170 |
builder = tree.branch.get_commit_builder([old_revision_id]) |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
171 |
try: |
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
172 |
list(builder.record_iter_changes(tree, old_revision_id, [])) |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
173 |
# Regardless of repository root behaviour we should consider this a
|
174 |
# pointless commit.
|
|
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
175 |
self.assertFalse(builder.any_changes()) |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
176 |
builder.finish_inventory() |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
177 |
builder.commit('rev') |
5878.1.1
by Jelmer Vernooij
Avoid inventory usage in a commit builder test. |
178 |
builder_tree = builder.revision_tree() |
7358.14.1
by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id(''). |
179 |
new_root_id = builder_tree.path2id('') |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
180 |
new_root_revision = builder_tree.get_file_revision(u'') |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
181 |
if tree.branch.repository.supports_rich_root(): |
182 |
# We should not have seen a new root revision
|
|
5878.1.1
by Jelmer Vernooij
Avoid inventory usage in a commit builder test. |
183 |
self.assertEqual(old_revision_id, new_root_revision) |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
184 |
else: |
185 |
# We should see a new root revision
|
|
5878.1.1
by Jelmer Vernooij
Avoid inventory usage in a commit builder test. |
186 |
self.assertNotEqual(old_revision_id, new_root_revision) |
3775.2.7
by Robert Collins
CommitBuilder handles no-change commits to roots properly with record_iter_changes. |
187 |
finally: |
188 |
tree.unlock() |
|
189 |
||
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
190 |
def test_record_delete_record_iter_changes(self): |
191 |
tree = self.make_branch_and_tree(".") |
|
192 |
self.build_tree(["foo"]) |
|
6770.2.2
by Jelmer Vernooij
Avoid file ids. |
193 |
tree.add(["foo"]) |
194 |
foo_id = tree.path2id('foo') |
|
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
195 |
rev_id = tree.commit("added foo") |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
196 |
with tree.lock_write(): |
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
197 |
builder = tree.branch.get_commit_builder([rev_id]) |
198 |
try: |
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
199 |
delete_change = InventoryTreeChange( |
7322.1.7
by Jelmer Vernooij
Fix remaining tests. |
200 |
foo_id, ('foo', None), True, (True, False), |
201 |
(tree.path2id(''), None), |
|
202 |
('foo', None), ('file', None), |
|
203 |
(False, None)) |
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
204 |
list(builder.record_iter_changes(tree, rev_id, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
205 |
[delete_change])) |
6770.2.2
by Jelmer Vernooij
Avoid file ids. |
206 |
self.assertEqual(("foo", None, foo_id, None), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
207 |
builder.get_basis_delta()[0]) |
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
208 |
self.assertTrue(builder.any_changes()) |
209 |
builder.finish_inventory() |
|
210 |
rev_id2 = builder.commit('delete foo') |
|
211 |
except: |
|
212 |
builder.abort() |
|
213 |
raise
|
|
214 |
rev_tree = builder.revision_tree() |
|
215 |
rev_tree.lock_read() |
|
216 |
self.addCleanup(rev_tree.unlock) |
|
6913.3.5
by Jelmer Vernooij
Avoid calls to path2id. |
217 |
self.assertFalse(rev_tree.is_versioned('foo')) |
3775.2.9
by Robert Collins
CommitBuilder handles deletes via record_iter_entries. |
218 |
|
3775.2.10
by Robert Collins
CommitBuilder gives a revision tree when used with record_iter_contents. |
219 |
def test_revision_tree_record_iter_changes(self): |
220 |
tree = self.make_branch_and_tree(".") |
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
221 |
with tree.lock_write(): |
3775.2.10
by Robert Collins
CommitBuilder gives a revision tree when used with record_iter_contents. |
222 |
builder = tree.branch.get_commit_builder([]) |
223 |
try: |
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
224 |
list(builder.record_iter_changes(tree, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
225 |
_mod_revision.NULL_REVISION, |
226 |
tree.iter_changes(tree.basis_tree()))) |
|
3775.2.10
by Robert Collins
CommitBuilder gives a revision tree when used with record_iter_contents. |
227 |
builder.finish_inventory() |
228 |
rev_id = builder.commit('foo bar') |
|
229 |
except: |
|
230 |
builder.abort() |
|
231 |
raise
|
|
232 |
rev_tree = builder.revision_tree() |
|
233 |
# Just a couple simple tests to ensure that it actually follows
|
|
234 |
# the RevisionTree api.
|
|
235 |
self.assertEqual(rev_id, rev_tree.get_revision_id()) |
|
6072.1.1
by Jelmer Vernooij
Various fixes for tests of foreign plugins. |
236 |
self.assertEqual((), tuple(rev_tree.get_parent_ids())) |
3775.2.10
by Robert Collins
CommitBuilder gives a revision tree when used with record_iter_contents. |
237 |
|
2255.7.65
by Robert Collins
Split test_root_revision_entry into tree and repository portions. |
238 |
def test_root_entry_has_revision(self): |
239 |
# test the root revision created and put in the basis
|
|
240 |
# has the right rev id.
|
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
241 |
# XXX: RBC 20081118 - this test is too big, it depends on the exact
|
242 |
# behaviour of tree methods and so on; it should be written to the
|
|
243 |
# commit builder interface directly.
|
|
2255.7.65
by Robert Collins
Split test_root_revision_entry into tree and repository portions. |
244 |
tree = self.make_branch_and_tree('.') |
245 |
rev_id = tree.commit('message') |
|
246 |
basis_tree = tree.basis_tree() |
|
247 |
basis_tree.lock_read() |
|
248 |
self.addCleanup(basis_tree.unlock) |
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
249 |
self.assertEqual(rev_id, basis_tree.get_file_revision(u'')) |
2255.7.65
by Robert Collins
Split test_root_revision_entry into tree and repository portions. |
250 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
251 |
def _get_revtrees(self, tree, revision_ids): |
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
252 |
with tree.lock_read(): |
2592.3.214
by Robert Collins
Merge bzr.dev. |
253 |
trees = list(tree.branch.repository.revision_trees(revision_ids)) |
254 |
for _tree in trees: |
|
255 |
_tree.lock_read() |
|
256 |
self.addCleanup(_tree.unlock) |
|
257 |
return trees |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
258 |
|
259 |
def test_last_modified_revision_after_commit_root_unchanged(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
260 |
# commiting without changing the root does not change the
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
261 |
# last modified except on non-rich-root-repositories.
|
262 |
tree = self.make_branch_and_tree('.') |
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
263 |
rev1 = tree.commit('rev1') |
264 |
rev2 = tree.commit('rev2') |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
265 |
tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
266 |
self.assertEqual(rev1, tree1.get_file_revision(u'')) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
267 |
if tree.branch.repository.supports_rich_root(): |
6861.1.1
by Jelmer Vernooij
More foreign branch test fixes. |
268 |
self.assertEqual(rev1, tree2.get_file_revision(u'')) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
269 |
else: |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
270 |
self.assertEqual(rev2, tree2.get_file_revision(u'')) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
271 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
272 |
def _add_commit_check_unchanged(self, tree, name): |
6770.2.3
by Jelmer Vernooij
Fix file ids. |
273 |
tree.add([name]) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
274 |
self._commit_check_unchanged(tree, name, tree.path2id(name)) |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
275 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
276 |
def _commit_check_unchanged(self, tree, name, file_id): |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
277 |
rev1 = tree.commit('rev1') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
278 |
rev2 = self.mini_commit_record_iter_changes( |
279 |
tree, name, name, False, False) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
280 |
tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
6913.3.5
by Jelmer Vernooij
Avoid calls to path2id. |
281 |
self.assertEqual(rev1, tree1.get_file_revision(name)) |
282 |
self.assertEqual(rev1, tree2.get_file_revision(name)) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
283 |
expected_graph = {} |
284 |
expected_graph[(file_id, rev1)] = () |
|
285 |
self.assertFileGraph(expected_graph, tree, (file_id, rev1)) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
286 |
|
287 |
def test_last_modified_revision_after_commit_dir_unchanged(self): |
|
288 |
# committing without changing a dir does not change the last modified.
|
|
289 |
tree = self.make_branch_and_tree('.') |
|
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
290 |
if not tree.has_versioned_directories(): |
291 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
292 |
'Format does not support versioned directories') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
293 |
self.build_tree(['dir/']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
294 |
self._add_commit_check_unchanged(tree, 'dir') |
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
295 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
296 |
def test_last_modified_revision_after_commit_dir_contents_unchanged(self): |
297 |
# committing without changing a dir does not change the last modified
|
|
298 |
# of the dir even the dirs contents are changed.
|
|
299 |
tree = self.make_branch_and_tree('.') |
|
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
300 |
self.build_tree(['dir/', 'dir/orig']) |
301 |
tree.add(['dir', 'dir/orig']) |
|
6770.2.4
by Jelmer Vernooij
Fix remaining test. |
302 |
dir_id = tree.path2id('dir') |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
303 |
rev1 = tree.commit('rev1') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
304 |
self.build_tree(['dir/content']) |
6770.2.4
by Jelmer Vernooij
Fix remaining test. |
305 |
tree.add(['dir/content']) |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
306 |
rev2 = tree.commit('rev2') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
307 |
tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
308 |
self.assertEqual(rev1, tree1.get_file_revision('dir')) |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
309 |
self.assertEqual(rev1, tree2.get_file_revision('dir')) |
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
310 |
expected_graph = {(dir_id, rev1): ()} |
6770.2.4
by Jelmer Vernooij
Fix remaining test. |
311 |
self.assertFileGraph(expected_graph, tree, (dir_id, rev1)) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
312 |
|
313 |
def test_last_modified_revision_after_commit_file_unchanged(self): |
|
314 |
# committing without changing a file does not change the last modified.
|
|
315 |
tree = self.make_branch_and_tree('.') |
|
316 |
self.build_tree(['file']) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
317 |
self._add_commit_check_unchanged(tree, 'file') |
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
318 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
319 |
def test_last_modified_revision_after_commit_link_unchanged(self): |
320 |
# committing without changing a link does not change the last modified.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
321 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
322 |
tree = self.make_branch_and_tree('.') |
323 |
os.symlink('target', 'link') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
324 |
self._add_commit_check_unchanged(tree, 'link') |
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
325 |
|
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
326 |
def test_last_modified_revision_after_commit_reference_unchanged(self): |
327 |
# committing without changing a subtree does not change the last
|
|
328 |
# modified.
|
|
329 |
tree = self.make_branch_and_tree('.') |
|
330 |
subtree = self.make_reference('reference') |
|
6926.2.8
by Jelmer Vernooij
Fix some more tests. |
331 |
subtree.commit('') |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
332 |
try: |
333 |
tree.add_reference(subtree) |
|
334 |
self._commit_check_unchanged(tree, 'reference', |
|
7358.14.1
by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id(''). |
335 |
subtree.path2id('')) |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
336 |
except errors.UnsupportedOperation: |
337 |
return
|
|
338 |
||
3709.3.1
by Robert Collins
First cut - make it work - at updating the tree stat cache during commit. |
339 |
def _add_commit_renamed_check_changed(self, tree, name, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
340 |
expect_fs_hash=False): |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
341 |
def rename(): |
342 |
tree.rename_one(name, 'new_' + name) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
343 |
self._add_commit_change_check_changed(tree, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
344 |
(name, 'new_' + name), rename, |
345 |
expect_fs_hash=expect_fs_hash) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
346 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
347 |
def _commit_renamed_check_changed(self, tree, name, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
348 |
expect_fs_hash=False): |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
349 |
def rename(): |
350 |
tree.rename_one(name, 'new_' + name) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
351 |
self._commit_change_check_changed(tree, [name, 'new_' + name], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
352 |
rename, expect_fs_hash=expect_fs_hash) |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
353 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
354 |
def test_last_modified_revision_after_rename_dir_changes(self): |
355 |
# renaming a dir changes the last modified.
|
|
356 |
tree = self.make_branch_and_tree('.') |
|
6915.3.1
by Jelmer Vernooij
Skip tests that require versioned directories. |
357 |
if not tree.has_versioned_directories(): |
358 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
359 |
'Format does not support versioned directories') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
360 |
self.build_tree(['dir/']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
361 |
self._add_commit_renamed_check_changed(tree, 'dir') |
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
362 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
363 |
def test_last_modified_revision_after_rename_file_changes(self): |
364 |
# renaming a file changes the last modified.
|
|
365 |
tree = self.make_branch_and_tree('.') |
|
366 |
self.build_tree(['file']) |
|
3709.3.1
by Robert Collins
First cut - make it work - at updating the tree stat cache during commit. |
367 |
self._add_commit_renamed_check_changed(tree, 'file', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
368 |
expect_fs_hash=True) |
3775.2.12
by Robert Collins
CommitBuilder.record_iter_changes handles renamed files. |
369 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
370 |
def test_last_modified_revision_after_rename_link_changes(self): |
371 |
# renaming a link changes the last modified.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
372 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
373 |
tree = self.make_branch_and_tree('.') |
374 |
os.symlink('target', 'link') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
375 |
self._add_commit_renamed_check_changed(tree, 'link') |
3775.2.13
by Robert Collins
CommitBuilder.record_iter_changes handles renamed symlinks. |
376 |
|
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
377 |
def test_last_modified_revision_after_rename_ref_changes(self): |
378 |
# renaming a reference changes the last modified.
|
|
379 |
tree = self.make_branch_and_tree('.') |
|
380 |
subtree = self.make_reference('reference') |
|
6926.2.8
by Jelmer Vernooij
Fix some more tests. |
381 |
subtree.commit('') |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
382 |
try: |
383 |
tree.add_reference(subtree) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
384 |
self._commit_renamed_check_changed(tree, 'reference') |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
385 |
except errors.UnsupportedOperation: |
386 |
return
|
|
387 |
||
3709.3.1
by Robert Collins
First cut - make it work - at updating the tree stat cache during commit. |
388 |
def _add_commit_reparent_check_changed(self, tree, name, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
389 |
expect_fs_hash=False): |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
390 |
self.build_tree(['newparent/']) |
391 |
tree.add(['newparent']) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
392 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
393 |
def reparent(): |
394 |
tree.rename_one(name, 'newparent/new_' + name) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
395 |
self._add_commit_change_check_changed( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
396 |
tree, (name, 'newparent/new_' + name), reparent, |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
397 |
expect_fs_hash=expect_fs_hash) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
398 |
|
399 |
def test_last_modified_revision_after_reparent_dir_changes(self): |
|
400 |
# reparenting a dir changes the last modified.
|
|
401 |
tree = self.make_branch_and_tree('.') |
|
6883.22.17
by Jelmer Vernooij
Cope with directory test. |
402 |
if not tree.has_versioned_directories(): |
403 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
404 |
'Format does not support versioned directories') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
405 |
self.build_tree(['dir/']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
406 |
self._add_commit_reparent_check_changed(tree, 'dir') |
3775.2.14
by Robert Collins
CommitBuilder.record_iter_changes handles reparented directories. |
407 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
408 |
def test_last_modified_revision_after_reparent_file_changes(self): |
409 |
# reparenting a file changes the last modified.
|
|
410 |
tree = self.make_branch_and_tree('.') |
|
411 |
self.build_tree(['file']) |
|
3709.3.1
by Robert Collins
First cut - make it work - at updating the tree stat cache during commit. |
412 |
self._add_commit_reparent_check_changed(tree, 'file', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
413 |
expect_fs_hash=True) |
3775.2.15
by Robert Collins
CommitBuilder.record_iter_changes handles reparented files. |
414 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
415 |
def test_last_modified_revision_after_reparent_link_changes(self): |
416 |
# reparenting a link changes the last modified.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
417 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
418 |
tree = self.make_branch_and_tree('.') |
419 |
os.symlink('target', 'link') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
420 |
self._add_commit_reparent_check_changed(tree, 'link') |
3775.2.16
by Robert Collins
CommitBuilder.record_iter_changes handles reparented symlinks. |
421 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
422 |
def _add_commit_change_check_changed(self, tree, names, changer, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
423 |
expect_fs_hash=False): |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
424 |
tree.add([names[0]]) |
425 |
self.assertTrue(tree.is_versioned(names[0])) |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
426 |
self._commit_change_check_changed( |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
427 |
tree, names, |
428 |
changer, expect_fs_hash=expect_fs_hash) |
|
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
429 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
430 |
def _commit_change_check_changed(self, tree, names, changer, |
431 |
expect_fs_hash=False): |
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
432 |
rev1 = tree.commit('rev1') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
433 |
changer() |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
434 |
rev2 = self.mini_commit_record_iter_changes( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
435 |
tree, names[0], names[1], expect_fs_hash=expect_fs_hash) |
2871.1.3
by Robert Collins
* The CommitBuilder method ``record_entry_contents`` now returns summary |
436 |
tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
437 |
self.assertEqual(rev1, tree1.get_file_revision(names[0])) |
438 |
self.assertEqual(rev2, tree2.get_file_revision(names[1])) |
|
439 |
file_id = tree1.path2id(names[0]) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
440 |
expected_graph = {} |
441 |
expected_graph[(file_id, rev1)] = () |
|
442 |
expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
|
443 |
self.assertFileGraph(expected_graph, tree, (file_id, rev2)) |
|
2871.1.3
by Robert Collins
* The CommitBuilder method ``record_entry_contents`` now returns summary |
444 |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
445 |
def mini_commit_record_iter_changes(self, tree, name, new_name, |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
446 |
records_version=True, |
447 |
delta_against_basis=True, |
|
448 |
expect_fs_hash=False): |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
449 |
"""Perform a miniature commit looking for record entry results. |
450 |
||
451 |
This version uses the record_iter_changes interface.
|
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
452 |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
453 |
:param tree: The tree to commit.
|
454 |
:param name: The path in the basis tree of the tree being committed.
|
|
455 |
:param new_name: The path in the tree being committed.
|
|
456 |
:param records_version: True if the commit of new_name is expected to
|
|
457 |
record a new version.
|
|
458 |
:param delta_against_basis: True of the commit of new_name is expected
|
|
459 |
to have a delta against the basis.
|
|
4183.5.4
by Robert Collins
Turn record_iter_changes into a generator to emit file system hashes. |
460 |
:param expect_fs_hash: If true, looks for a fs hash output from
|
461 |
record_iter_changes.
|
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
462 |
"""
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
463 |
with tree.lock_write(): |
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
464 |
# mini manual commit here so we can check the return of
|
6700.2.1
by Jelmer Vernooij
Remove record_entry_contents tests and infrastructure. |
465 |
# record_iter_changes
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
466 |
parent_ids = tree.get_parent_ids() |
467 |
builder = tree.branch.get_commit_builder(parent_ids) |
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
468 |
try: |
469 |
parent_tree = tree.basis_tree() |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
470 |
with parent_tree.lock_read(): |
471 |
changes = list(tree.iter_changes(parent_tree)) |
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
472 |
result = list(builder.record_iter_changes(tree, parent_ids[0], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
473 |
changes)) |
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
474 |
file_id = tree.path2id(new_name) |
475 |
self.assertIsNot(None, file_id) |
|
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
476 |
if isinstance(tree, inventorytree.InventoryTree): |
477 |
# TODO(jelmer): record_iter_changes shouldn't yield
|
|
478 |
# data that is WorkingTree-format-specific and uses file ids.
|
|
479 |
if expect_fs_hash: |
|
480 |
tree_file_stat = tree.get_file_with_stat(new_name) |
|
481 |
tree_file_stat[0].close() |
|
482 |
self.assertLength(1, result) |
|
483 |
result = result[0] |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
484 |
self.assertEqual(result[0], new_name) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
485 |
self.assertEqual( |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
486 |
result[1][0], tree.get_file_sha1(new_name)) |
487 |
self.assertEqualStat(result[1][1], tree_file_stat[1]) |
|
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
488 |
else: |
489 |
self.assertEqual([], result) |
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
490 |
builder.finish_inventory() |
491 |
if tree.branch.repository._format.supports_full_versioned_files: |
|
492 |
inv_key = (builder._new_revision_id,) |
|
493 |
inv_sha1 = tree.branch.repository.inventories.get_sha1s( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
494 |
[inv_key])[inv_key] |
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
495 |
self.assertEqual(inv_sha1, builder.inv_sha1) |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
496 |
rev2 = builder.commit('rev2') |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
497 |
except BaseException: |
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
498 |
builder.abort() |
499 |
raise
|
|
6437.12.1
by Jelmer Vernooij
Use CommitBuilder.get_basis_delta rather than private CommitBuilder._basis_delta. |
500 |
delta = builder.get_basis_delta() |
7467.4.13
by Jelmer Vernooij
Fix last rename tests. |
501 |
delta_dict = dict((change[1], change) for change in delta) |
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
502 |
if tree.branch.repository._format.records_per_file_revision: |
7467.4.13
by Jelmer Vernooij
Fix last rename tests. |
503 |
version_recorded = (new_name in delta_dict |
504 |
and delta_dict[new_name][3] is not None |
|
505 |
and delta_dict[new_name][3].revision == rev2) |
|
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
506 |
if records_version: |
507 |
self.assertTrue(version_recorded) |
|
508 |
else: |
|
509 |
self.assertFalse(version_recorded) |
|
6437.12.1
by Jelmer Vernooij
Use CommitBuilder.get_basis_delta rather than private CommitBuilder._basis_delta. |
510 |
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
511 |
revtree = builder.revision_tree() |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
512 |
new_entry = next(revtree.iter_entries_by_dir( |
513 |
specific_files=[new_name]))[1] |
|
6883.16.1
by Jelmer Vernooij
commit builder test improvements: |
514 |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
515 |
if delta_against_basis: |
7467.4.13
by Jelmer Vernooij
Fix last rename tests. |
516 |
(delta_old_name, delta_new_name, |
517 |
delta_file_id, delta_entry) = delta_dict[new_name] |
|
518 |
self.assertEqual(delta_new_name, new_name) |
|
519 |
if tree.supports_rename_tracking(): |
|
520 |
self.assertEqual(name, delta_old_name) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
521 |
else: |
7467.4.13
by Jelmer Vernooij
Fix last rename tests. |
522 |
self.assertIn(delta_old_name, (name, None)) |
523 |
if tree.supports_setting_file_ids(): |
|
524 |
self.assertEqual(delta_file_id, file_id) |
|
525 |
self.assertEqual(delta_entry.file_id, file_id) |
|
526 |
self.assertEqual(delta_entry.kind, new_entry.kind) |
|
527 |
self.assertEqual(delta_entry.name, new_entry.name) |
|
528 |
self.assertEqual(delta_entry.parent_id, new_entry.parent_id) |
|
529 |
if delta_entry.kind == 'file': |
|
7490.126.2
by Jelmer Vernooij
Stop populating text_sha1 in Git. |
530 |
self.assertEqual(delta_entry.text_size, revtree.get_file_size(new_name)) |
531 |
if getattr(delta_entry, 'text_sha1', None): |
|
532 |
self.assertEqual(delta_entry.text_sha1, revtree.get_file_sha1(new_name)) |
|
7467.4.13
by Jelmer Vernooij
Fix last rename tests. |
533 |
elif delta_entry.kind == 'symlink': |
534 |
self.assertEqual(delta_entry.symlink_target, new_entry.symlink_target) |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
535 |
else: |
536 |
expected_delta = None |
|
6883.22.19
by Jelmer Vernooij
Add records_per_file_revision attribute. |
537 |
if tree.branch.repository._format.records_per_file_revision: |
538 |
self.assertFalse(version_recorded) |
|
3775.2.11
by Robert Collins
CommitBuilder handles renamed directory and unmodified entries with single parents, for record_iter_changes. |
539 |
tree.set_parent_ids([rev2]) |
540 |
return rev2 |
|
541 |
||
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
542 |
def assertFileGraph(self, expected_graph, tree, tip): |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
543 |
# all the changes that have occured should be in the ancestry
|
544 |
# (closest to a public per-file graph API we have today)
|
|
545 |
tree.lock_read() |
|
546 |
self.addCleanup(tree.unlock) |
|
5815.5.9
by Jelmer Vernooij
Remove dependencies on texts. |
547 |
g = dict(tree.branch.repository.get_file_graph().iter_ancestry([tip])) |
5010.2.24
by Vincent Ladeuil
Fix imports in per_repository/test_commit_builder.py. |
548 |
self.assertEqual(expected_graph, g) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
549 |
|
550 |
def test_last_modified_revision_after_content_file_changes(self): |
|
551 |
# altering a file changes the last modified.
|
|
552 |
tree = self.make_branch_and_tree('.') |
|
553 |
self.build_tree(['file']) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
554 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
555 |
def change_file(): |
6973.6.3
by Jelmer Vernooij
More fixes. |
556 |
tree.put_file_bytes_non_atomic('file', b'new content') |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
557 |
self._add_commit_change_check_changed(tree, ('file', 'file'), change_file, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
558 |
expect_fs_hash=True) |
3775.2.17
by Robert Collins
CommitBuilder.record_iter_changes handles changed files. |
559 |
|
6700.2.1
by Jelmer Vernooij
Remove record_entry_contents tests and infrastructure. |
560 |
def _test_last_mod_rev_after_content_link_changes( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
561 |
self, link, target, newtarget): |
3775.2.18
by Robert Collins
CommitBuilder.record_iter_changes handles changed symlinks. |
562 |
# changing a link changes the last modified.
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
563 |
self.requireFeature(features.SymlinkFeature) |
3775.2.18
by Robert Collins
CommitBuilder.record_iter_changes handles changed symlinks. |
564 |
tree = self.make_branch_and_tree('.') |
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
565 |
os.symlink(target, link) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
566 |
|
3775.2.18
by Robert Collins
CommitBuilder.record_iter_changes handles changed symlinks. |
567 |
def change_link(): |
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
568 |
os.unlink(link) |
569 |
os.symlink(newtarget, link) |
|
570 |
self._add_commit_change_check_changed( |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
571 |
tree, (link, link), change_link) |
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
572 |
|
6700.2.1
by Jelmer Vernooij
Remove record_entry_contents tests and infrastructure. |
573 |
def test_last_modified_rev_after_content_link_changes(self): |
574 |
self._test_last_mod_rev_after_content_link_changes( |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
575 |
'link', 'target', 'newtarget') |
576 |
||
6700.2.1
by Jelmer Vernooij
Remove record_entry_contents tests and infrastructure. |
577 |
def test_last_modified_rev_after_content_unicode_link_changes(self): |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
578 |
self.requireFeature(features.UnicodeFilenameFeature) |
6700.2.1
by Jelmer Vernooij
Remove record_entry_contents tests and infrastructure. |
579 |
self._test_last_mod_rev_after_content_link_changes( |
6770.2.1
by Jelmer Vernooij
Avoid setting file ids. |
580 |
u'li\u1234nk', u'targ\N{Euro Sign}t', u'n\N{Euro Sign}wtarget') |
3775.2.18
by Robert Collins
CommitBuilder.record_iter_changes handles changed symlinks. |
581 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
582 |
def _commit_sprout(self, tree, name): |
6770.2.3
by Jelmer Vernooij
Fix file ids. |
583 |
tree.add([name]) |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
584 |
rev_id = tree.commit('rev') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
585 |
return rev_id, tree.controldir.sprout('t2').open_workingtree() |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
586 |
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
587 |
def _rename_in_tree(self, tree, name, message): |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
588 |
tree.rename_one(name, 'new_' + name) |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
589 |
return tree.commit(message) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
590 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
591 |
def _commit_sprout_rename_merge(self, tree1, name, expect_fs_hash=False): |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
592 |
"""Do a rename in both trees.""" |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
593 |
rev1, tree2 = self._commit_sprout(tree1, name) |
6770.2.3
by Jelmer Vernooij
Fix file ids. |
594 |
file_id = tree2.path2id(name) |
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
595 |
self.assertIsNot(None, file_id) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
596 |
# change both sides equally
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
597 |
rev2 = self._rename_in_tree(tree1, name, 'rev2') |
598 |
rev3 = self._rename_in_tree(tree2, name, 'rev3') |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
599 |
tree1.merge_from_branch(tree2.branch) |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
600 |
rev4 = self.mini_commit_record_iter_changes( |
601 |
tree1, 'new_' + name, 'new_' + name, |
|
602 |
expect_fs_hash=expect_fs_hash, |
|
603 |
delta_against_basis=tree1.supports_rename_tracking()) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
604 |
tree3, = self._get_revtrees(tree1, [rev4]) |
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
605 |
expected_graph = {} |
6883.22.18
by Jelmer Vernooij
Support handling renames. |
606 |
if tree1.supports_rename_tracking(): |
607 |
self.assertEqual(rev4, tree3.get_file_revision('new_' + name)) |
|
608 |
expected_graph[(file_id, rev1)] = () |
|
609 |
expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
|
610 |
expected_graph[(file_id, rev3)] = ((file_id, rev1),) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
611 |
expected_graph[(file_id, rev4)] = ( |
612 |
(file_id, rev2), (file_id, rev3),) |
|
6883.22.18
by Jelmer Vernooij
Support handling renames. |
613 |
else: |
614 |
self.assertEqual(rev2, tree3.get_file_revision('new_' + name)) |
|
615 |
expected_graph[(file_id, rev4)] = () |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
616 |
self.assertFileGraph(expected_graph, tree1, (file_id, rev4)) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
617 |
|
618 |
def test_last_modified_revision_after_merge_dir_changes(self): |
|
619 |
# merge a dir changes the last modified.
|
|
620 |
tree1 = self.make_branch_and_tree('t1') |
|
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
621 |
if not tree1.has_versioned_directories(): |
622 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
623 |
'Format does not support versioned directories') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
624 |
self.build_tree(['t1/dir/']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
625 |
self._commit_sprout_rename_merge(tree1, 'dir') |
3775.2.19
by Robert Collins
CommitBuilder.record_iter_changes handles merged directories. |
626 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
627 |
def test_last_modified_revision_after_merge_file_changes(self): |
628 |
# merge a file changes the last modified.
|
|
629 |
tree1 = self.make_branch_and_tree('t1') |
|
630 |
self.build_tree(['t1/file']) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
631 |
self._commit_sprout_rename_merge(tree1, 'file', expect_fs_hash=True) |
3775.2.20
by Robert Collins
CommitBuilder.record_iter_changes handles merged files. |
632 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
633 |
def test_last_modified_revision_after_merge_link_changes(self): |
634 |
# merge a link changes the last modified.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
635 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
636 |
tree1 = self.make_branch_and_tree('t1') |
637 |
os.symlink('target', 't1/link') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
638 |
self._commit_sprout_rename_merge(tree1, 'link') |
3775.2.21
by Robert Collins
CommitBuilder.record_iter_changes handles merged symlinks. |
639 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
640 |
def _commit_sprout_rename_merge_converged(self, tree1, name): |
3775.2.22
by Robert Collins
CommitBuilder.record_iter_changes handles changed-in-branch directories. |
641 |
# Make a merge which just incorporates a change from a branch:
|
642 |
# The per-file graph is straight line, and no alteration occurs
|
|
643 |
# in the inventory.
|
|
4183.5.9
by Robert Collins
Fix creating new revisions of files when merging. |
644 |
# Part 1: change in the merged branch.
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
645 |
rev1, tree2 = self._commit_sprout(tree1, name) |
6770.2.3
by Jelmer Vernooij
Fix file ids. |
646 |
file_id = tree2.path2id(name) |
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
647 |
self.assertIsNot(None, file_id) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
648 |
# change on the other side to merge back
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
649 |
rev2 = self._rename_in_tree(tree2, name, 'rev2') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
650 |
tree1.merge_from_branch(tree2.branch) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
651 |
|
4183.5.9
by Robert Collins
Fix creating new revisions of files when merging. |
652 |
def _check_graph(in_tree, changed_in_tree): |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
653 |
rev3 = self.mini_commit_record_iter_changes( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
654 |
in_tree, name, 'new_' + name, False, |
655 |
delta_against_basis=changed_in_tree) |
|
4183.5.9
by Robert Collins
Fix creating new revisions of files when merging. |
656 |
tree3, = self._get_revtrees(in_tree, [rev2]) |
7143.15.15
by Jelmer Vernooij
Merge trunk. |
657 |
self.assertEqual(rev2, tree3.get_file_revision('new_' + name)) |
4183.5.9
by Robert Collins
Fix creating new revisions of files when merging. |
658 |
expected_graph = {} |
659 |
expected_graph[(file_id, rev1)] = () |
|
660 |
expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
|
661 |
self.assertFileGraph(expected_graph, in_tree, (file_id, rev2)) |
|
662 |
_check_graph(tree1, True) |
|
663 |
# Part 2: change in the merged into branch - we use tree2 that has a
|
|
664 |
# change to name, branch tree1 and give it an unrelated change, then
|
|
665 |
# merge that to t2.
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
666 |
other_tree = tree1.controldir.sprout('t3').open_workingtree() |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
667 |
other_rev = other_tree.commit('other_rev') |
4183.5.9
by Robert Collins
Fix creating new revisions of files when merging. |
668 |
tree2.merge_from_branch(other_tree.branch) |
669 |
_check_graph(tree2, False) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
670 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
671 |
def _commit_sprout_make_merge(self, tree1, make): |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
672 |
# Make a merge which incorporates the addition of a new object to
|
673 |
# another branch. The per-file graph shows no additional change
|
|
674 |
# in the merge because its a straight line.
|
|
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
675 |
rev1 = tree1.commit('rev1') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
676 |
tree2 = tree1.controldir.sprout('t2').open_workingtree() |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
677 |
# make and commit on the other side to merge back
|
678 |
make('t2/name') |
|
6770.2.2
by Jelmer Vernooij
Avoid file ids. |
679 |
tree2.add(['name']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
680 |
self.assertTrue(tree2.is_versioned('name')) |
6915.3.2
by Jelmer Vernooij
Set commit message for entropy. |
681 |
rev2 = tree2.commit('rev2') |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
682 |
tree1.merge_from_branch(tree2.branch) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
683 |
rev3 = self.mini_commit_record_iter_changes(tree1, None, 'name', False) |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
684 |
tree3, = self._get_revtrees(tree1, [rev2]) |
685 |
# in rev2, name should be only changed in rev2
|
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
686 |
self.assertEqual(rev2, tree3.get_file_revision('name')) |
687 |
file_id = tree2.path2id('name') |
|
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
688 |
expected_graph = {} |
689 |
expected_graph[(file_id, rev2)] = () |
|
690 |
self.assertFileGraph(expected_graph, tree1, (file_id, rev2)) |
|
691 |
||
692 |
def test_last_modified_revision_after_converged_merge_dir_unchanged(self): |
|
693 |
# merge a dir that changed preserves the last modified.
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
694 |
tree1 = self.make_branch_and_tree('t1') |
6883.14.2
by Jelmer Vernooij
Fix commitbuilder tests. |
695 |
if not tree1.has_versioned_directories(): |
696 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
697 |
'Format does not support versioned directories') |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
698 |
self.build_tree(['t1/dir/']) |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
699 |
self._commit_sprout_rename_merge_converged(tree1, 'dir') |
3775.2.22
by Robert Collins
CommitBuilder.record_iter_changes handles changed-in-branch directories. |
700 |
|
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
701 |
def test_last_modified_revision_after_converged_merge_file_unchanged(self): |
702 |
# merge a file that changed preserves the last modified.
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
703 |
tree1 = self.make_branch_and_tree('t1') |
704 |
self.build_tree(['t1/file']) |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
705 |
self._commit_sprout_rename_merge_converged(tree1, 'file') |
3775.2.23
by Robert Collins
CommitBuilder.record_iter_changes handles changed-in-branch files. |
706 |
|
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
707 |
def test_last_modified_revision_after_converged_merge_link_unchanged(self): |
708 |
# merge a link that changed preserves the last modified.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
709 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
710 |
tree1 = self.make_branch_and_tree('t1') |
711 |
os.symlink('target', 't1/link') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
712 |
self._commit_sprout_rename_merge_converged(tree1, 'link') |
3775.2.24
by Robert Collins
CommitBuilder.record_iter_changes handles changed-in-branch symlinks. |
713 |
|
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
714 |
def test_last_modified_revision_after_merge_new_dir_unchanged(self): |
715 |
# merge a new dir does not change the last modified.
|
|
716 |
tree1 = self.make_branch_and_tree('t1') |
|
6915.3.1
by Jelmer Vernooij
Skip tests that require versioned directories. |
717 |
if not tree1.has_versioned_directories(): |
718 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
719 |
'Format does not support versioned directories') |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
720 |
self._commit_sprout_make_merge(tree1, self.make_dir) |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
721 |
|
722 |
def test_last_modified_revision_after_merge_new_file_unchanged(self): |
|
723 |
# merge a new file does not change the last modified.
|
|
724 |
tree1 = self.make_branch_and_tree('t1') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
725 |
self._commit_sprout_make_merge(tree1, self.make_file) |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
726 |
|
727 |
def test_last_modified_revision_after_merge_new_link_unchanged(self): |
|
728 |
# merge a new link does not change the last modified.
|
|
729 |
tree1 = self.make_branch_and_tree('t1') |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
730 |
self._commit_sprout_make_merge(tree1, self.make_link) |
3775.2.33
by Robert Collins
Fix bug with merges of new files, increasing test coverage to ensure its kept fixed. |
731 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
732 |
def make_dir(self, name): |
733 |
self.build_tree([name + '/']) |
|
734 |
||
735 |
def make_file(self, name): |
|
736 |
self.build_tree([name]) |
|
737 |
||
738 |
def make_link(self, name): |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
739 |
self.requireFeature(features.SymlinkFeature) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
740 |
os.symlink('target', name) |
741 |
||
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
742 |
def make_reference(self, name): |
6926.2.11
by Jelmer Vernooij
Don't rely on 1.9-rich-root. |
743 |
tree = self.make_branch_and_tree(name) |
744 |
if not tree.branch.repository._format.rich_root_data: |
|
745 |
raise tests.TestNotApplicable( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
746 |
'format does not support rich roots') |
4183.5.2
by Robert Collins
Support tree-reference in record_iter_changes. |
747 |
tree.commit('foo') |
748 |
return tree |
|
749 |
||
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
750 |
def _check_kind_change(self, make_before, make_after, expect_fs_hash=False): |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
751 |
tree = self.make_branch_and_tree('.') |
752 |
path = 'name' |
|
753 |
make_before(path) |
|
2831.5.2
by Vincent Ladeuil
Review feedback. |
754 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
755 |
def change_kind(): |
6164.2.3
by Jelmer Vernooij
Use rmtree, since some vcses include control directories in every directory. |
756 |
if osutils.file_kind(path) == "directory": |
757 |
osutils.rmtree(path) |
|
758 |
else: |
|
759 |
osutils.delete_any(path) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
760 |
make_after(path) |
2831.5.2
by Vincent Ladeuil
Review feedback. |
761 |
|
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
762 |
self._add_commit_change_check_changed(tree, (path, path), change_kind, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
763 |
expect_fs_hash=expect_fs_hash) |
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
764 |
|
765 |
def test_last_modified_dir_file(self): |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
766 |
if not self.repository_format.supports_versioned_directories: |
767 |
# TODO(jelmer): Perhaps test this by creating a directory
|
|
768 |
# with a file in it?
|
|
769 |
raise tests.TestNotApplicable( |
|
770 |
'format does not support versioned directories') |
|
6217.2.1
by Jelmer Vernooij
Allow tree implementations to not support kind changes. |
771 |
try: |
772 |
self._check_kind_change(self.make_dir, self.make_file, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
773 |
expect_fs_hash=True) |
6217.2.1
by Jelmer Vernooij
Allow tree implementations to not support kind changes. |
774 |
except errors.UnsupportedKindChange: |
775 |
raise tests.TestSkipped( |
|
776 |
"tree does not support changing entry kind from "
|
|
777 |
"directory to file") |
|
3775.2.25
by Robert Collins
CommitBuilder.record_iter_changes handles directories becoming files and links. |
778 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
779 |
def test_last_modified_dir_link(self): |
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
780 |
if not self.repository_format.supports_versioned_directories: |
781 |
# TODO(jelmer): Perhaps test this by creating a directory
|
|
782 |
# with a file in it?
|
|
783 |
raise tests.TestNotApplicable( |
|
784 |
'format does not support versioned directories') |
|
6217.2.1
by Jelmer Vernooij
Allow tree implementations to not support kind changes. |
785 |
try: |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
786 |
self._check_kind_change(self.make_dir, self.make_link) |
6217.2.1
by Jelmer Vernooij
Allow tree implementations to not support kind changes. |
787 |
except errors.UnsupportedKindChange: |
788 |
raise tests.TestSkipped( |
|
789 |
"tree does not support changing entry kind from "
|
|
790 |
"directory to link") |
|
3775.2.25
by Robert Collins
CommitBuilder.record_iter_changes handles directories becoming files and links. |
791 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
792 |
def test_last_modified_link_file(self): |
3709.3.1
by Robert Collins
First cut - make it work - at updating the tree stat cache during commit. |
793 |
self._check_kind_change(self.make_link, self.make_file, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
794 |
expect_fs_hash=True) |
3775.2.26
by Robert Collins
CommitBuilder.record_iter_changes handles links becomes directories and files. |
795 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
796 |
def test_last_modified_link_dir(self): |
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
797 |
if not self.repository_format.supports_versioned_directories: |
798 |
# TODO(jelmer): Perhaps test this by creating a directory
|
|
799 |
# with a file in it?
|
|
800 |
raise tests.TestNotApplicable( |
|
801 |
'format does not support versioned directories') |
|
802 |
||
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
803 |
self._check_kind_change(self.make_link, self.make_dir) |
3775.2.26
by Robert Collins
CommitBuilder.record_iter_changes handles links becomes directories and files. |
804 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
805 |
def test_last_modified_file_dir(self): |
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
806 |
if not self.repository_format.supports_versioned_directories: |
807 |
# TODO(jelmer): Perhaps test this by creating a directory
|
|
808 |
# with a file in it?
|
|
809 |
raise tests.TestNotApplicable( |
|
810 |
'format does not support versioned directories') |
|
811 |
||
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
812 |
self._check_kind_change(self.make_file, self.make_dir) |
3775.2.27
by Robert Collins
CommitBuilder.record_iter_changes handles files becoming directories and links. |
813 |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
814 |
def test_last_modified_file_link(self): |
6885.7.2
by Jelmer Vernooij
Simplify CommitBuilder tests, fix some tests for formats that don't support rename tracking. |
815 |
self._check_kind_change(self.make_file, self.make_link) |
3775.2.28
by Robert Collins
Merge .dev. |
816 |
|
3831.1.1
by John Arbash Meinel
Before allowing commit to succeed, verify the texts will be 'safe'. |
817 |
def test_get_commit_builder_with_invalid_revprops(self): |
818 |
branch = self.make_branch('.') |
|
819 |
branch.repository.lock_write() |
|
820 |
self.addCleanup(branch.repository.unlock) |
|
821 |
self.assertRaises(ValueError, branch.repository.get_commit_builder, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
822 |
branch, [], branch.get_config_stack(), |
823 |
revprops={'invalid': u'property\rwith\r\ninvalid chars'}) |
|
3831.1.1
by John Arbash Meinel
Before allowing commit to succeed, verify the texts will be 'safe'. |
824 |
|
7490.74.2
by Jelmer Vernooij
Use surrogateescape in revprops. |
825 |
def test_get_commit_builder_with_surrogateescape(self): |
826 |
tree = self.make_branch_and_tree(".") |
|
827 |
with tree.lock_write(): |
|
828 |
builder = tree.branch.get_commit_builder([], revprops={ |
|
829 |
'invalid': u'property' + b'\xc0'.decode('utf-8', 'surrogateescape')}) |
|
830 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
|
831 |
tree.iter_changes(tree.basis_tree()))) |
|
832 |
builder.finish_inventory() |
|
833 |
try: |
|
834 |
rev_id = builder.commit('foo bar blah') |
|
835 |
except NotImplementedError: |
|
836 |
raise tests.TestNotApplicable( |
|
837 |
'Format does not support revision properties') |
|
838 |
rev = tree.branch.repository.get_revision(rev_id) |
|
839 |
self.assertEqual('foo bar blah', rev.message) |
|
840 |
||
3831.1.1
by John Arbash Meinel
Before allowing commit to succeed, verify the texts will be 'safe'. |
841 |
def test_commit_builder_commit_with_invalid_message(self): |
842 |
branch = self.make_branch('.') |
|
843 |
branch.repository.lock_write() |
|
844 |
self.addCleanup(branch.repository.unlock) |
|
845 |
builder = branch.repository.get_commit_builder(branch, [], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
846 |
branch.get_config_stack()) |
3831.1.1
by John Arbash Meinel
Before allowing commit to succeed, verify the texts will be 'safe'. |
847 |
self.addCleanup(branch.repository.abort_write_group) |
848 |
self.assertRaises(ValueError, builder.commit, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
849 |
u'Invalid\r\ncommit message\r\n') |
4595.4.2
by Robert Collins
Disable commit builders on stacked repositories. |
850 |
|
5485.4.2
by Martin
Move guard to CommitBuilder.__init__ and test to bt.per_repository |
851 |
def test_non_ascii_str_committer_rejected(self): |
852 |
"""Ensure an error is raised on a non-ascii byte string committer""" |
|
853 |
branch = self.make_branch('.') |
|
854 |
branch.repository.lock_write() |
|
855 |
self.addCleanup(branch.repository.unlock) |
|
856 |
self.assertRaises(UnicodeDecodeError, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
857 |
branch.repository.get_commit_builder, |
858 |
branch, [], branch.get_config_stack(), |
|
859 |
committer=b"Erik B\xe5gfors <erik@example.com>") |
|
5485.4.2
by Martin
Move guard to CommitBuilder.__init__ and test to bt.per_repository |
860 |
|
4595.4.2
by Robert Collins
Disable commit builders on stacked repositories. |
861 |
def test_stacked_repositories_reject_commit_builder(self): |
862 |
# As per bug 375013, committing to stacked repositories is currently
|
|
5557.1.17
by John Arbash Meinel
Fix the test case that was checking we refused to create a commit_builder |
863 |
# broken if we aren't in a chk repository. So old repositories with
|
864 |
# fallbacks refuse to hand out a commit builder.
|
|
4595.4.2
by Robert Collins
Disable commit builders on stacked repositories. |
865 |
repo_basis = self.make_repository('basis') |
866 |
branch = self.make_branch('local') |
|
867 |
repo_local = branch.repository |
|
868 |
try: |
|
869 |
repo_local.add_fallback_repository(repo_basis) |
|
870 |
except errors.UnstackableRepositoryFormat: |
|
871 |
raise tests.TestNotApplicable("not a stackable format.") |
|
5557.1.17
by John Arbash Meinel
Fix the test case that was checking we refused to create a commit_builder |
872 |
self.addCleanup(repo_local.lock_write().unlock) |
873 |
if not repo_local._format.supports_chks: |
|
874 |
self.assertRaises(errors.BzrError, repo_local.get_commit_builder, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
875 |
branch, [], branch.get_config_stack()) |
5557.1.17
by John Arbash Meinel
Fix the test case that was checking we refused to create a commit_builder |
876 |
else: |
877 |
builder = repo_local.get_commit_builder(branch, [], |
|
6351.3.3
by Jelmer Vernooij
Convert more stuff to use config stacks. |
878 |
branch.get_config_stack()) |
5557.1.17
by John Arbash Meinel
Fix the test case that was checking we refused to create a commit_builder |
879 |
builder.abort() |
5050.18.1
by Aaron Bentley
CommitBuilder user committer, not username in revision-id. |
880 |
|
881 |
def test_committer_no_username(self): |
|
882 |
# Ensure that when no username is available but a committer is
|
|
883 |
# supplied, commit works.
|
|
7344.1.1
by Martin
Fix tests that need whoami not to be set |
884 |
override_whoami(self) |
5050.18.1
by Aaron Bentley
CommitBuilder user committer, not username in revision-id. |
885 |
tree = self.make_branch_and_tree(".") |
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
886 |
with tree.lock_write(): |
5050.18.1
by Aaron Bentley
CommitBuilder user committer, not username in revision-id. |
887 |
# Make sure no username is available.
|
7336.2.1
by Martin
Split non-ini config methods to bedding |
888 |
self.assertRaises(errors.NoWhoami, tree.branch.get_commit_builder, |
5050.18.1
by Aaron Bentley
CommitBuilder user committer, not username in revision-id. |
889 |
[])
|
890 |
builder = tree.branch.get_commit_builder( |
|
891 |
[], committer='me@example.com') |
|
892 |
try: |
|
893 |
list(builder.record_iter_changes(tree, tree.last_revision(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
894 |
tree.iter_changes(tree.basis_tree()))) |
5050.18.1
by Aaron Bentley
CommitBuilder user committer, not username in revision-id. |
895 |
builder.finish_inventory() |
896 |
except: |
|
897 |
builder.abort() |
|
898 |
raise
|
|
899 |
repo = tree.branch.repository |
|
900 |
repo.commit_write_group() |