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