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) 2005-2012, 2016 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1246
by Martin Pool
- add very simple commit tests |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1246
by Martin Pool
- add very simple commit tests |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1246
by Martin Pool
- add very simple commit tests |
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
|
1246
by Martin Pool
- add very simple commit tests |
16 |
|
17 |
||
18 |
import os |
|
7122.6.11
by Jelmer Vernooij
Fix another test on python3. |
19 |
from io import BytesIO |
1246
by Martin Pool
- add very simple commit tests |
20 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
import breezy |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from .. import ( |
6351.3.12
by Vincent Ladeuil
Use simpler config stacks and use strings as inputs to better respect the API. |
23 |
config, |
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
24 |
controldir, |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
25 |
errors, |
6469.1.20
by Parth Malwankar
added commit test |
26 |
trace, |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
27 |
)
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
28 |
from ..branch import Branch |
6670.4.1
by Jelmer Vernooij
Update imports. |
29 |
from ..bzr.bzrdir import BzrDirMetaFormat1 |
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
30 |
from ..commit import ( |
6734.1.20
by Jelmer Vernooij
Move errors. |
31 |
CannotCommitSelectedFileMerge, |
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
32 |
Commit, |
33 |
NullCommitReporter, |
|
6734.1.20
by Jelmer Vernooij
Move errors. |
34 |
PointlessCommit, |
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
35 |
filter_excluded, |
36 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
37 |
from ..errors import ( |
5972.3.15
by Jelmer Vernooij
Use matchers. |
38 |
BzrError, |
39 |
LockContention, |
|
40 |
)
|
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
41 |
from ..bzr.inventorytree import InventoryTreeChange |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
42 |
from . import ( |
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
43 |
TestCase, |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
44 |
TestCaseWithTransport, |
45 |
test_foreign, |
|
46 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
47 |
from .features import ( |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
48 |
SymlinkFeature, |
49 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
50 |
from .matchers import MatchesAncestry |
1246
by Martin Pool
- add very simple commit tests |
51 |
|
52 |
||
1257
by Martin Pool
doc |
53 |
# TODO: Test commit with some added, and added-but-missing files
|
54 |
||
6883.11.3
by Jelmer Vernooij
Fix tests. |
55 |
class MustSignConfig(config.MemoryStack): |
56 |
||
57 |
def __init__(self): |
|
6973.7.10
by Jelmer Vernooij
More fixes. |
58 |
super(MustSignConfig, self).__init__(b''' |
6883.11.3
by Jelmer Vernooij
Fix tests. |
59 |
create_signatures=always
|
60 |
''') |
|
61 |
||
62 |
||
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
63 |
class CapturingReporter(NullCommitReporter): |
64 |
"""This reporter captures the calls made to it for evaluation later.""" |
|
65 |
||
66 |
def __init__(self): |
|
67 |
# a list of the calls this received
|
|
68 |
self.calls = [] |
|
69 |
||
70 |
def snapshot_change(self, change, path): |
|
71 |
self.calls.append(('change', change, path)) |
|
72 |
||
73 |
def deleted(self, file_id): |
|
74 |
self.calls.append(('deleted', file_id)) |
|
75 |
||
76 |
def missing(self, path): |
|
77 |
self.calls.append(('missing', path)) |
|
78 |
||
79 |
def renamed(self, change, old_path, new_path): |
|
80 |
self.calls.append(('renamed', change, old_path, new_path)) |
|
81 |
||
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
82 |
def is_verbose(self): |
83 |
return True |
|
84 |
||
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
85 |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
86 |
class TestCommit(TestCaseWithTransport): |
1390
by Robert Collins
pair programming worx... merge integration and weave |
87 |
|
1246
by Martin Pool
- add very simple commit tests |
88 |
def test_simple_commit(self): |
89 |
"""Commit and check two versions of a single file.""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
90 |
wt = self.make_branch_and_tree('.') |
91 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
92 |
with open('hello', 'w') as f: |
93 |
f.write('hello world') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
94 |
wt.add('hello') |
6165.4.7
by Jelmer Vernooij
More fixes. |
95 |
rev1 = wt.commit(message='add hello') |
1246
by Martin Pool
- add very simple commit tests |
96 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
97 |
with open('hello', 'w') as f: |
98 |
f.write('version 2') |
|
6165.4.7
by Jelmer Vernooij
More fixes. |
99 |
rev2 = wt.commit(message='commit 2') |
1246
by Martin Pool
- add very simple commit tests |
100 |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
101 |
eq = self.assertEqual |
1246
by Martin Pool
- add very simple commit tests |
102 |
eq(b.revno(), 2) |
6165.4.7
by Jelmer Vernooij
More fixes. |
103 |
rev = b.repository.get_revision(rev1) |
1246
by Martin Pool
- add very simple commit tests |
104 |
eq(rev.message, 'add hello') |
105 |
||
6165.4.7
by Jelmer Vernooij
More fixes. |
106 |
tree1 = b.repository.revision_tree(rev1) |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
107 |
tree1.lock_read() |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
108 |
text = tree1.get_file_text('hello') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
109 |
tree1.unlock() |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
110 |
self.assertEqual(b'hello world', text) |
1246
by Martin Pool
- add very simple commit tests |
111 |
|
6165.4.7
by Jelmer Vernooij
More fixes. |
112 |
tree2 = b.repository.revision_tree(rev2) |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
113 |
tree2.lock_read() |
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
114 |
text = tree2.get_file_text('hello') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
115 |
tree2.unlock() |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
116 |
self.assertEqual(b'version 2', text) |
1246
by Martin Pool
- add very simple commit tests |
117 |
|
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
118 |
def test_commit_lossy_native(self): |
119 |
"""Attempt a lossy commit to a native branch.""" |
|
120 |
wt = self.make_branch_and_tree('.') |
|
121 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
122 |
with open('hello', 'w') as f: |
123 |
f.write('hello world') |
|
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
124 |
wt.add('hello') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
125 |
revid = wt.commit(message='add hello', rev_id=b'revid', lossy=True) |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
126 |
self.assertEqual(b'revid', revid) |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
127 |
|
128 |
def test_commit_lossy_foreign(self): |
|
129 |
"""Attempt a lossy commit to a foreign branch.""" |
|
5777.6.6
by Jelmer Vernooij
Add lossy tests. |
130 |
test_foreign.register_dummy_foreign_for_test(self) |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
131 |
wt = self.make_branch_and_tree('.', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
132 |
format=test_foreign.DummyForeignVcsDirFormat()) |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
133 |
b = wt.branch |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
134 |
with open('hello', 'w') as f: |
135 |
f.write('hello world') |
|
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
136 |
wt.add('hello') |
5777.6.6
by Jelmer Vernooij
Add lossy tests. |
137 |
revid = wt.commit(message='add hello', lossy=True, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
138 |
timestamp=1302659388, timezone=0) |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
139 |
self.assertEqual(b'dummy-v1:1302659388-0-UNKNOWN', revid) |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
140 |
|
5777.7.5
by Jelmer Vernooij
Add tests for committing to a branch bound to a foreign branch. |
141 |
def test_commit_bound_lossy_foreign(self): |
142 |
"""Attempt a lossy commit to a bzr branch bound to a foreign branch.""" |
|
143 |
test_foreign.register_dummy_foreign_for_test(self) |
|
144 |
foreign_branch = self.make_branch('foreign', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
145 |
format=test_foreign.DummyForeignVcsDirFormat()) |
5777.7.5
by Jelmer Vernooij
Add tests for committing to a branch bound to a foreign branch. |
146 |
wt = foreign_branch.create_checkout("local") |
147 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
148 |
with open('local/hello', 'w') as f: |
149 |
f.write('hello world') |
|
5777.7.5
by Jelmer Vernooij
Add tests for committing to a branch bound to a foreign branch. |
150 |
wt.add('hello') |
151 |
revid = wt.commit(message='add hello', lossy=True, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
152 |
timestamp=1302659388, timezone=0) |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
153 |
self.assertEqual(b'dummy-v1:1302659388-0-0', revid) |
154 |
self.assertEqual(b'dummy-v1:1302659388-0-0', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
155 |
foreign_branch.last_revision()) |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
156 |
self.assertEqual(b'dummy-v1:1302659388-0-0', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
157 |
wt.branch.last_revision()) |
5777.7.5
by Jelmer Vernooij
Add tests for committing to a branch bound to a foreign branch. |
158 |
|
4183.5.5
by Robert Collins
Enable record_iter_changes for cases where it can work. |
159 |
def test_missing_commit(self): |
160 |
"""Test a commit with a missing file""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
161 |
wt = self.make_branch_and_tree('.') |
162 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
163 |
with open('hello', 'w') as f: |
164 |
f.write('hello world') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
165 |
wt.add(['hello'], [b'hello-id']) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
166 |
wt.commit(message='add hello') |
1247
by Martin Pool
- tests for deletion and removal of files in commits |
167 |
|
168 |
os.remove('hello') |
|
6125.1.1
by Jelmer Vernooij
Report missing files as removed in 'bzr commit', rather than modified. |
169 |
reporter = CapturingReporter() |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
170 |
wt.commit('removed hello', rev_id=b'rev2', reporter=reporter) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
171 |
self.assertEqual( |
6125.1.1
by Jelmer Vernooij
Report missing files as removed in 'bzr commit', rather than modified. |
172 |
[('missing', u'hello'), ('deleted', u'hello')], |
173 |
reporter.calls) |
|
1247
by Martin Pool
- tests for deletion and removal of files in commits |
174 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
175 |
tree = b.repository.revision_tree(b'rev2') |
7397.4.7
by Jelmer Vernooij
Remove Tree.has_id. |
176 |
self.assertFalse(tree.has_filename('hello')) |
1247
by Martin Pool
- tests for deletion and removal of files in commits |
177 |
|
2258.4.1
by Jelmer Vernooij
Add test that demonstrates a corner case bug in commit. |
178 |
def test_partial_commit_move(self): |
3373.4.1
by John Arbash Meinel
Merge in and clean up the test for bug #83039. |
179 |
"""Test a partial commit where a file was renamed but not committed. |
180 |
||
181 |
https://bugs.launchpad.net/bzr/+bug/83039
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
182 |
|
2258.4.1
by Jelmer Vernooij
Add test that demonstrates a corner case bug in commit. |
183 |
If not handled properly, commit will try to snapshot
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
184 |
dialog.py with olive/ as a parent, while
|
2258.4.1
by Jelmer Vernooij
Add test that demonstrates a corner case bug in commit. |
185 |
olive/ has not been snapshotted yet.
|
186 |
"""
|
|
187 |
wt = self.make_branch_and_tree('.') |
|
188 |
b = wt.branch |
|
3373.4.1
by John Arbash Meinel
Merge in and clean up the test for bug #83039. |
189 |
self.build_tree(['annotate/', 'annotate/foo.py', |
190 |
'olive/', 'olive/dialog.py' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
191 |
])
|
2258.4.1
by Jelmer Vernooij
Add test that demonstrates a corner case bug in commit. |
192 |
wt.add(['annotate', 'olive', 'annotate/foo.py', 'olive/dialog.py']) |
193 |
wt.commit(message='add files') |
|
3373.4.1
by John Arbash Meinel
Merge in and clean up the test for bug #83039. |
194 |
wt.rename_one("olive/dialog.py", "aaa") |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
195 |
self.build_tree_contents([('annotate/foo.py', b'modified\n')]) |
2258.4.1
by Jelmer Vernooij
Add test that demonstrates a corner case bug in commit. |
196 |
wt.commit('renamed hello', specific_files=["annotate"]) |
197 |
||
1253
by Martin Pool
- test that pointless commits are trapped |
198 |
def test_pointless_commit(self): |
199 |
"""Commit refuses unless there are changes or it's forced.""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
200 |
wt = self.make_branch_and_tree('.') |
201 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
202 |
with open('hello', 'w') as f: |
203 |
f.write('hello') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
204 |
wt.add(['hello']) |
205 |
wt.commit(message='add hello') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
206 |
self.assertEqual(b.revno(), 1) |
1253
by Martin Pool
- test that pointless commits are trapped |
207 |
self.assertRaises(PointlessCommit, |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
208 |
wt.commit, |
1253
by Martin Pool
- test that pointless commits are trapped |
209 |
message='fails', |
210 |
allow_pointless=False) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
211 |
self.assertEqual(b.revno(), 1) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
212 |
|
1252
by Martin Pool
- add test for commit of an empty tree |
213 |
def test_commit_empty(self): |
1253
by Martin Pool
- test that pointless commits are trapped |
214 |
"""Commiting an empty tree works.""" |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
215 |
wt = self.make_branch_and_tree('.') |
216 |
b = wt.branch |
|
217 |
wt.commit(message='empty tree', allow_pointless=True) |
|
1253
by Martin Pool
- test that pointless commits are trapped |
218 |
self.assertRaises(PointlessCommit, |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
219 |
wt.commit, |
1253
by Martin Pool
- test that pointless commits are trapped |
220 |
message='empty tree', |
221 |
allow_pointless=False) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
222 |
wt.commit(message='empty tree', allow_pointless=True) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
223 |
self.assertEqual(b.revno(), 2) |
1252
by Martin Pool
- add test for commit of an empty tree |
224 |
|
225 |
def test_selective_delete(self): |
|
226 |
"""Selective commit in tree with deletions""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
227 |
wt = self.make_branch_and_tree('.') |
228 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
229 |
with open('hello', 'w') as f: |
230 |
f.write('hello') |
|
231 |
with open('buongia', 'w') as f: |
|
232 |
f.write('buongia') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
233 |
wt.add(['hello', 'buongia'], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
234 |
[b'hello-id', b'buongia-id']) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
235 |
wt.commit(message='add files', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
236 |
rev_id=b'test@rev-1') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
237 |
|
1254
by Martin Pool
- fix handling of selective commit with deleted files |
238 |
os.remove('hello') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
239 |
with open('buongia', 'w') as f: |
240 |
f.write('new text') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
241 |
wt.commit(message='update text', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
242 |
specific_files=['buongia'], |
243 |
allow_pointless=False, |
|
244 |
rev_id=b'test@rev-2') |
|
1254
by Martin Pool
- fix handling of selective commit with deleted files |
245 |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
246 |
wt.commit(message='remove hello', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
247 |
specific_files=['hello'], |
248 |
allow_pointless=False, |
|
249 |
rev_id=b'test@rev-3') |
|
1254
by Martin Pool
- fix handling of selective commit with deleted files |
250 |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
251 |
eq = self.assertEqual |
1254
by Martin Pool
- fix handling of selective commit with deleted files |
252 |
eq(b.revno(), 3) |
1255
by Martin Pool
- more tests for selective commit of deletion |
253 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
254 |
tree2 = b.repository.revision_tree(b'test@rev-2') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
255 |
tree2.lock_read() |
256 |
self.addCleanup(tree2.unlock) |
|
1255
by Martin Pool
- more tests for selective commit of deletion |
257 |
self.assertTrue(tree2.has_filename('hello')) |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
258 |
self.assertEqual(tree2.get_file_text('hello'), b'hello') |
259 |
self.assertEqual(tree2.get_file_text('buongia'), b'new text') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
260 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
261 |
tree3 = b.repository.revision_tree(b'test@rev-3') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
262 |
tree3.lock_read() |
263 |
self.addCleanup(tree3.unlock) |
|
1255
by Martin Pool
- more tests for selective commit of deletion |
264 |
self.assertFalse(tree3.has_filename('hello')) |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
265 |
self.assertEqual(tree3.get_file_text('buongia'), b'new text') |
1285
by Martin Pool
- fix bug in committing files that are renamed but not modified |
266 |
|
267 |
def test_commit_rename(self): |
|
268 |
"""Test commit of a revision where a file is renamed.""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
269 |
tree = self.make_branch_and_tree('.') |
270 |
b = tree.branch |
|
1185.38.7
by John Arbash Meinel
Updated build_tree to use fixed line-endings for tests which read the file contents and compare |
271 |
self.build_tree(['hello'], line_endings='binary') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
272 |
tree.add(['hello'], [b'hello-id']) |
273 |
tree.commit(message='one', rev_id=b'test@rev-1', allow_pointless=False) |
|
1285
by Martin Pool
- fix bug in committing files that are renamed but not modified |
274 |
|
1508.1.7
by Robert Collins
Move rename_one from Branch to WorkingTree. (Robert Collins). |
275 |
tree.rename_one('hello', 'fruity') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
276 |
tree.commit(message='renamed', rev_id=b'test@rev-2', |
277 |
allow_pointless=False) |
|
1285
by Martin Pool
- fix bug in committing files that are renamed but not modified |
278 |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
279 |
eq = self.assertEqual |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
280 |
tree1 = b.repository.revision_tree(b'test@rev-1') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
281 |
tree1.lock_read() |
282 |
self.addCleanup(tree1.unlock) |
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
283 |
eq(tree1.id2path(b'hello-id'), 'hello') |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
284 |
eq(tree1.get_file_text('hello'), b'contents of hello\n') |
1285
by Martin Pool
- fix bug in committing files that are renamed but not modified |
285 |
self.assertFalse(tree1.has_filename('fruity')) |
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
286 |
self.check_tree_shape(tree1, ['hello']) |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
287 |
eq(tree1.get_file_revision('hello'), b'test@rev-1') |
1285
by Martin Pool
- fix bug in committing files that are renamed but not modified |
288 |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
289 |
tree2 = b.repository.revision_tree(b'test@rev-2') |
3010.1.3
by Robert Collins
Lock RevisionTrees correctly in commit tests. |
290 |
tree2.lock_read() |
291 |
self.addCleanup(tree2.unlock) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
292 |
eq(tree2.id2path(b'hello-id'), 'fruity') |
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
293 |
eq(tree2.get_file_text('fruity'), b'contents of hello\n') |
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
294 |
self.check_tree_shape(tree2, ['fruity']) |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
295 |
eq(tree2.get_file_revision('fruity'), b'test@rev-2') |
1291
by Martin Pool
- add test for moving files between directories |
296 |
|
297 |
def test_reused_rev_id(self): |
|
1292
by Martin Pool
- add check that revision ids cannot be committed twice |
298 |
"""Test that a revision id cannot be reused in a branch""" |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
299 |
wt = self.make_branch_and_tree('.') |
300 |
b = wt.branch |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
301 |
wt.commit('initial', rev_id=b'test@rev-1', allow_pointless=True) |
1292
by Martin Pool
- add check that revision ids cannot be committed twice |
302 |
self.assertRaises(Exception, |
1534.4.35
by Robert Collins
Give branch its own basis tree and last_revision methods; deprecated branch.working_tree() |
303 |
wt.commit, |
1292
by Martin Pool
- add check that revision ids cannot be committed twice |
304 |
message='reused id', |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
305 |
rev_id=b'test@rev-1', |
1292
by Martin Pool
- add check that revision ids cannot be committed twice |
306 |
allow_pointless=True) |
1291
by Martin Pool
- add test for moving files between directories |
307 |
|
308 |
def test_commit_move(self): |
|
309 |
"""Test commit of revisions with moved files and directories""" |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
310 |
eq = self.assertEqual |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
311 |
wt = self.make_branch_and_tree('.') |
312 |
b = wt.branch |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
313 |
r1 = b'test@rev-1' |
1291
by Martin Pool
- add test for moving files between directories |
314 |
self.build_tree(['hello', 'a/', 'b/']) |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
315 |
wt.add(['hello', 'a', 'b'], [b'hello-id', b'a-id', b'b-id']) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
316 |
wt.commit('initial', rev_id=r1, allow_pointless=False) |
317 |
wt.move(['hello'], 'a') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
318 |
r2 = b'test@rev-2' |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
319 |
wt.commit('two', rev_id=r2, allow_pointless=False) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
320 |
wt.lock_read() |
321 |
try: |
|
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
322 |
self.check_tree_shape(wt, ['a/', 'a/hello', 'b/']) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
323 |
finally: |
324 |
wt.unlock() |
|
1291
by Martin Pool
- add test for moving files between directories |
325 |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
326 |
wt.move(['b'], 'a') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
327 |
r3 = b'test@rev-3' |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
328 |
wt.commit('three', rev_id=r3, allow_pointless=False) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
329 |
wt.lock_read() |
330 |
try: |
|
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
331 |
self.check_tree_shape(wt, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
332 |
['a/', 'a/hello', 'a/b/']) |
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
333 |
self.check_tree_shape(b.repository.revision_tree(r3), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
334 |
['a/', 'a/hello', 'a/b/']) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
335 |
finally: |
336 |
wt.unlock() |
|
1291
by Martin Pool
- add test for moving files between directories |
337 |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
338 |
wt.move(['a/hello'], 'a/b') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
339 |
r4 = b'test@rev-4' |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
340 |
wt.commit('four', rev_id=r4, allow_pointless=False) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
341 |
wt.lock_read() |
342 |
try: |
|
5807.1.5
by Jelmer Vernooij
Fix more things to use tree objects. |
343 |
self.check_tree_shape(wt, ['a/', 'a/b/hello', 'a/b/']) |
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
344 |
finally: |
345 |
wt.unlock() |
|
1306
by Martin Pool
- tests that name_version is updated properly in renames/moves |
346 |
|
5035.3.1
by Jelmer Vernooij
Remove Repository.get_revision_inventory. |
347 |
inv = b.repository.get_inventory(r4) |
6855.4.10
by Jelmer Vernooij
merge trunk |
348 |
eq(inv.get_entry(b'hello-id').revision, r4) |
349 |
eq(inv.get_entry(b'a-id').revision, r1) |
|
350 |
eq(inv.get_entry(b'b-id').revision, r3) |
|
2255.2.136
by John Arbash Meinel
(James Westby) add read locks around read_working_inventory() in test_commit_move |
351 |
|
1246
by Martin Pool
- add very simple commit tests |
352 |
def test_removed_commit(self): |
1185.16.72
by Martin Pool
[merge] from robert and fix up tests |
353 |
"""Commit with a removed file""" |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
354 |
wt = self.make_branch_and_tree('.') |
355 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
356 |
with open('hello', 'w') as f: |
357 |
f.write('hello world') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
358 |
wt.add(['hello'], [b'hello-id']) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
359 |
wt.commit(message='add hello') |
1185.16.72
by Martin Pool
[merge] from robert and fix up tests |
360 |
wt.remove('hello') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
361 |
wt.commit('removed hello', rev_id=b'rev2') |
1247
by Martin Pool
- tests for deletion and removal of files in commits |
362 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
363 |
tree = b.repository.revision_tree(b'rev2') |
7397.4.7
by Jelmer Vernooij
Remove Tree.has_id. |
364 |
self.assertFalse(tree.has_filename('hello')) |
1246
by Martin Pool
- add very simple commit tests |
365 |
|
1256
by Martin Pool
- test that commits append to the tree's ancestry |
366 |
def test_committed_ancestry(self): |
367 |
"""Test commit appends revisions to ancestry.""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
368 |
wt = self.make_branch_and_tree('.') |
369 |
b = wt.branch |
|
1256
by Martin Pool
- test that commits append to the tree's ancestry |
370 |
rev_ids = [] |
371 |
for i in range(4): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
372 |
with open('hello', 'w') as f: |
373 |
f.write((str(i) * 4) + '\n') |
|
1256
by Martin Pool
- test that commits append to the tree's ancestry |
374 |
if i == 0: |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
375 |
wt.add(['hello'], [b'hello-id']) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
376 |
rev_id = b'test@rev-%d' % (i + 1) |
1256
by Martin Pool
- test that commits append to the tree's ancestry |
377 |
rev_ids.append(rev_id) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
378 |
wt.commit(message='rev %d' % (i + 1), |
379 |
rev_id=rev_id) |
|
1256
by Martin Pool
- test that commits append to the tree's ancestry |
380 |
for i in range(4): |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
381 |
self.assertThat(rev_ids[:i + 1], |
382 |
MatchesAncestry(b.repository, rev_ids[i])) |
|
1416
by Robert Collins
when committing a specific file, include all its parents |
383 |
|
384 |
def test_commit_new_subdir_child_selective(self): |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
385 |
wt = self.make_branch_and_tree('.') |
386 |
b = wt.branch |
|
1416
by Robert Collins
when committing a specific file, include all its parents |
387 |
self.build_tree(['dir/', 'dir/file1', 'dir/file2']) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
388 |
wt.add(['dir', 'dir/file1', 'dir/file2'], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
389 |
[b'dirid', b'file1id', b'file2id']) |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
390 |
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id=b'1') |
6973.5.2
by Jelmer Vernooij
Add more bees. |
391 |
inv = b.repository.get_inventory(b'1') |
392 |
self.assertEqual(b'1', inv.get_entry(b'dirid').revision) |
|
393 |
self.assertEqual(b'1', inv.get_entry(b'file1id').revision) |
|
1416
by Robert Collins
when committing a specific file, include all its parents |
394 |
# FIXME: This should raise a KeyError I think, rbc20051006
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
395 |
self.assertRaises(BzrError, inv.get_entry, b'file2id') |
1185.16.65
by mbp at sourcefrog
- new commit --strict option |
396 |
|
397 |
def test_strict_commit(self): |
|
398 |
"""Try and commit with unknown files and strict = True, should fail.""" |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
399 |
from ..errors import StrictCommitFailed |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
400 |
wt = self.make_branch_and_tree('.') |
401 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
402 |
with open('hello', 'w') as f: |
403 |
f.write('hello world') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
404 |
wt.add('hello') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
405 |
with open('goodbye', 'w') as f: |
406 |
f.write('goodbye cruel world!') |
|
1534.4.35
by Robert Collins
Give branch its own basis tree and last_revision methods; deprecated branch.working_tree() |
407 |
self.assertRaises(StrictCommitFailed, wt.commit, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
408 |
message='add hello but not goodbye', strict=True) |
1185.16.65
by mbp at sourcefrog
- new commit --strict option |
409 |
|
1185.22.4
by Michael Ellerman
Strict commit was a little .. ah .. too strict, oops :} |
410 |
def test_strict_commit_without_unknowns(self): |
411 |
"""Try and commit with no unknown files and strict = True, |
|
412 |
should work."""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
413 |
wt = self.make_branch_and_tree('.') |
414 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
415 |
with open('hello', 'w') as f: |
416 |
f.write('hello world') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
417 |
wt.add('hello') |
418 |
wt.commit(message='add hello', strict=True) |
|
1185.22.4
by Michael Ellerman
Strict commit was a little .. ah .. too strict, oops :} |
419 |
|
1185.16.65
by mbp at sourcefrog
- new commit --strict option |
420 |
def test_nonstrict_commit(self): |
421 |
"""Try and commit with unknown files and strict = False, should work.""" |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
422 |
wt = self.make_branch_and_tree('.') |
423 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
424 |
with open('hello', 'w') as f: |
425 |
f.write('hello world') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
426 |
wt.add('hello') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
427 |
with open('goodbye', 'w') as f: |
428 |
f.write('goodbye cruel world!') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
429 |
wt.commit(message='add hello but not goodbye', strict=False) |
1185.16.72
by Martin Pool
[merge] from robert and fix up tests |
430 |
|
1185.22.4
by Michael Ellerman
Strict commit was a little .. ah .. too strict, oops :} |
431 |
def test_nonstrict_commit_without_unknowns(self): |
432 |
"""Try and commit with no unknown files and strict = False, |
|
433 |
should work."""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
434 |
wt = self.make_branch_and_tree('.') |
435 |
b = wt.branch |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
436 |
with open('hello', 'w') as f: |
437 |
f.write('hello world') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
438 |
wt.add('hello') |
439 |
wt.commit(message='add hello', strict=False) |
|
1185.22.4
by Michael Ellerman
Strict commit was a little .. ah .. too strict, oops :} |
440 |
|
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
441 |
def test_signed_commit(self): |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
442 |
import breezy.gpg |
443 |
import breezy.commit as commit |
|
444 |
oldstrategy = breezy.gpg.GPGStrategy |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
445 |
wt = self.make_branch_and_tree('.') |
446 |
branch = wt.branch |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
447 |
wt.commit("base", allow_pointless=True, rev_id=b'A') |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
448 |
self.assertFalse(branch.repository.has_signature_for_revision_id(b'A')) |
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
449 |
try: |
7206.4.1
by Jelmer Vernooij
Move breezy.testament to breezy.bzr.testament. |
450 |
from ..bzr.testament import Testament |
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
451 |
# monkey patch gpg signing mechanism
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
452 |
breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy |
6973.9.1
by Jelmer Vernooij
More test fixes. |
453 |
conf = config.MemoryStack(b''' |
6393.1.1
by Vincent Ladeuil
Provides MemoryStack to simplify configuration setup in tests |
454 |
create_signatures=always
|
455 |
''') |
|
456 |
commit.Commit(config_stack=conf).commit( |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
457 |
message="base", allow_pointless=True, rev_id=b'B', |
6393.1.1
by Vincent Ladeuil
Provides MemoryStack to simplify configuration setup in tests |
458 |
working_tree=wt) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
459 |
|
1551.12.15
by Aaron Bentley
add header/trailer to fake clearsigned texts |
460 |
def sign(text): |
6883.11.1
by Jelmer Vernooij
Add support for a mode argument to GPGStrategy.sign. |
461 |
return breezy.gpg.LoopbackGPGStrategy(None).sign( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
462 |
text, breezy.gpg.MODE_CLEAR) |
1551.12.15
by Aaron Bentley
add header/trailer to fake clearsigned texts |
463 |
self.assertEqual(sign(Testament.from_revision(branch.repository, |
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
464 |
b'B').as_short_text()), |
465 |
branch.repository.get_signature_text(b'B')) |
|
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
466 |
finally: |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
467 |
breezy.gpg.GPGStrategy = oldstrategy |
1442.1.62
by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions. |
468 |
|
469 |
def test_commit_failed_signature(self): |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
470 |
import breezy.gpg |
471 |
import breezy.commit as commit |
|
472 |
oldstrategy = breezy.gpg.GPGStrategy |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
473 |
wt = self.make_branch_and_tree('.') |
474 |
branch = wt.branch |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
475 |
wt.commit("base", allow_pointless=True, rev_id=b'A') |
6973.5.2
by Jelmer Vernooij
Add more bees. |
476 |
self.assertFalse(branch.repository.has_signature_for_revision_id(b'A')) |
1442.1.62
by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions. |
477 |
try: |
478 |
# monkey patch gpg signing mechanism
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
479 |
breezy.gpg.GPGStrategy = breezy.gpg.DisabledGPGStrategy |
6973.9.1
by Jelmer Vernooij
More test fixes. |
480 |
conf = config.MemoryStack(b''' |
6393.1.1
by Vincent Ladeuil
Provides MemoryStack to simplify configuration setup in tests |
481 |
create_signatures=always
|
482 |
''') |
|
6728.1.2
by Jelmer Vernooij
Sign using python-gpg rather than command-line gpg. |
483 |
self.assertRaises(breezy.gpg.SigningFailed, |
6393.1.1
by Vincent Ladeuil
Provides MemoryStack to simplify configuration setup in tests |
484 |
commit.Commit(config_stack=conf).commit, |
1534.4.34
by Robert Collins
Fix remaining uses of deprecated apis within bzrlib. |
485 |
message="base", |
1442.1.62
by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions. |
486 |
allow_pointless=True, |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
487 |
rev_id=b'B', |
1534.4.34
by Robert Collins
Fix remaining uses of deprecated apis within bzrlib. |
488 |
working_tree=wt) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
489 |
branch = Branch.open(self.get_url('.')) |
6973.5.2
by Jelmer Vernooij
Add more bees. |
490 |
self.assertEqual(branch.last_revision(), b'A') |
491 |
self.assertFalse(branch.repository.has_revision(b'B')) |
|
1442.1.62
by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions. |
492 |
finally: |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
493 |
breezy.gpg.GPGStrategy = oldstrategy |
1472
by Robert Collins
post commit hook, first pass implementation |
494 |
|
495 |
def test_commit_invokes_hooks(self): |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
496 |
import breezy.commit as commit |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
497 |
wt = self.make_branch_and_tree('.') |
498 |
branch = wt.branch |
|
1472
by Robert Collins
post commit hook, first pass implementation |
499 |
calls = [] |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
500 |
|
1472
by Robert Collins
post commit hook, first pass implementation |
501 |
def called(branch, rev_id): |
502 |
calls.append('called') |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
503 |
breezy.ahook = called |
1472
by Robert Collins
post commit hook, first pass implementation |
504 |
try: |
6973.9.1
by Jelmer Vernooij
More test fixes. |
505 |
conf = config.MemoryStack(b'post_commit=breezy.ahook breezy.ahook') |
6393.1.1
by Vincent Ladeuil
Provides MemoryStack to simplify configuration setup in tests |
506 |
commit.Commit(config_stack=conf).commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
507 |
message="base", allow_pointless=True, rev_id=b'A', |
508 |
working_tree=wt) |
|
1472
by Robert Collins
post commit hook, first pass implementation |
509 |
self.assertEqual(['called', 'called'], calls) |
510 |
finally: |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
511 |
del breezy.ahook |
1593.1.1
by Robert Collins
Move responsibility for setting branch nickname in commits to the WorkingTree convenience function. |
512 |
|
513 |
def test_commit_object_doesnt_set_nick(self): |
|
514 |
# using the Commit object directly does not set the branch nick.
|
|
515 |
wt = self.make_branch_and_tree('.') |
|
516 |
c = Commit() |
|
2149.1.3
by Aaron Bentley
Updates from review comments |
517 |
c.commit(working_tree=wt, message='empty tree', allow_pointless=True) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
518 |
self.assertEqual(wt.branch.revno(), 1) |
1593.1.1
by Robert Collins
Move responsibility for setting branch nickname in commits to the WorkingTree convenience function. |
519 |
self.assertEqual({}, |
520 |
wt.branch.repository.get_revision( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
521 |
wt.branch.last_revision()).properties) |
1593.1.1
by Robert Collins
Move responsibility for setting branch nickname in commits to the WorkingTree convenience function. |
522 |
|
1614.1.1
by Aaron Bentley
Fixed master locking in commit |
523 |
def test_safe_master_lock(self): |
524 |
os.mkdir('master') |
|
525 |
master = BzrDirMetaFormat1().initialize('master') |
|
526 |
master.create_repository() |
|
527 |
master_branch = master.create_branch() |
|
528 |
master.create_workingtree() |
|
529 |
bound = master.sprout('bound') |
|
530 |
wt = bound.open_workingtree() |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
531 |
wt.branch.set_bound_location(os.path.realpath('master')) |
7490.49.1
by Jelmer Vernooij
Move more bzr tests. |
532 |
with master_branch.lock_write(): |
1658.1.5
by Martin Pool
Release more locks taken during test suite |
533 |
self.assertRaises(LockContention, wt.commit, 'silly') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
534 |
|
535 |
def test_commit_bound_merge(self): |
|
536 |
# see bug #43959; commit of a merge in a bound branch fails to push
|
|
537 |
# the new commit into the master
|
|
538 |
master_branch = self.make_branch('master') |
|
539 |
bound_tree = self.make_branch_and_tree('bound') |
|
540 |
bound_tree.branch.bind(master_branch) |
|
541 |
||
7143.15.2
by Jelmer Vernooij
Run autopep8. |
542 |
self.build_tree_contents( |
543 |
[('bound/content_file', b'initial contents\n')]) |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
544 |
bound_tree.add(['content_file']) |
545 |
bound_tree.commit(message='woo!') |
|
546 |
||
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
547 |
other_bzrdir = master_branch.controldir.sprout('other') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
548 |
other_tree = other_bzrdir.open_workingtree() |
549 |
||
4775.1.1
by Martin Pool
Remove several 'the the' typos |
550 |
# do a commit to the other branch changing the content file so
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
551 |
# that our commit after merging will have a merged revision in the
|
552 |
# content file history.
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
553 |
self.build_tree_contents( |
554 |
[('other/content_file', b'change in other\n')]) |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
555 |
other_tree.commit('change in other') |
556 |
||
557 |
# do a merge into the bound branch from other, and then change the
|
|
558 |
# content file locally to force a new revision (rather than using the
|
|
559 |
# revision from other). This forces extra processing in commit.
|
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
560 |
bound_tree.merge_from_branch(other_tree.branch) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
561 |
self.build_tree_contents( |
562 |
[('bound/content_file', b'change in bound\n')]) |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
563 |
|
564 |
# before #34959 was fixed, this failed with 'revision not present in
|
|
565 |
# weave' when trying to implicitly push from the bound branch to the master
|
|
566 |
bound_tree.commit(message='commit of merge in bound tree') |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
567 |
|
568 |
def test_commit_reporting_after_merge(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
569 |
# when doing a commit of a merge, the reporter needs to still
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
570 |
# be called for each item that is added/removed/deleted.
|
571 |
this_tree = self.make_branch_and_tree('this') |
|
572 |
# we need a bunch of files and dirs, to perform one action on each.
|
|
573 |
self.build_tree([ |
|
574 |
'this/dirtorename/', |
|
575 |
'this/dirtoreparent/', |
|
576 |
'this/dirtoleave/', |
|
577 |
'this/dirtoremove/', |
|
578 |
'this/filetoreparent', |
|
579 |
'this/filetorename', |
|
580 |
'this/filetomodify', |
|
581 |
'this/filetoremove', |
|
582 |
'this/filetoleave'] |
|
583 |
)
|
|
584 |
this_tree.add([ |
|
585 |
'dirtorename', |
|
586 |
'dirtoreparent', |
|
587 |
'dirtoleave', |
|
588 |
'dirtoremove', |
|
589 |
'filetoreparent', |
|
590 |
'filetorename', |
|
591 |
'filetomodify', |
|
592 |
'filetoremove', |
|
593 |
'filetoleave'] |
|
594 |
)
|
|
595 |
this_tree.commit('create_files') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
596 |
other_dir = this_tree.controldir.sprout('other') |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
597 |
other_tree = other_dir.open_workingtree() |
598 |
other_tree.lock_write() |
|
599 |
# perform the needed actions on the files and dirs.
|
|
600 |
try: |
|
601 |
other_tree.rename_one('dirtorename', 'renameddir') |
|
602 |
other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir') |
|
603 |
other_tree.rename_one('filetorename', 'renamedfile') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
604 |
other_tree.rename_one( |
605 |
'filetoreparent', 'renameddir/reparentedfile') |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
606 |
other_tree.remove(['dirtoremove', 'filetoremove']) |
607 |
self.build_tree_contents([ |
|
608 |
('other/newdir/', ), |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
609 |
('other/filetomodify', b'new content'), |
610 |
('other/newfile', b'new file content')]) |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
611 |
other_tree.add('newfile') |
612 |
other_tree.add('newdir/') |
|
613 |
other_tree.commit('modify all sample files and dirs.') |
|
614 |
finally: |
|
615 |
other_tree.unlock() |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
616 |
this_tree.merge_from_branch(other_tree.branch) |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
617 |
reporter = CapturingReporter() |
618 |
this_tree.commit('do the commit', reporter=reporter) |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
619 |
expected = { |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
620 |
('change', 'modified', 'filetomodify'), |
621 |
('change', 'added', 'newdir'), |
|
622 |
('change', 'added', 'newfile'), |
|
623 |
('renamed', 'renamed', 'dirtorename', 'renameddir'), |
|
2829.1.1
by Ian Clatworthy
re-apply Aaron's fix for #94975 (Ian Clatworthy) |
624 |
('renamed', 'renamed', 'filetorename', 'renamedfile'), |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
625 |
('renamed', 'renamed', 'dirtoreparent', 'renameddir/reparenteddir'), |
626 |
('renamed', 'renamed', 'filetoreparent', 'renameddir/reparentedfile'), |
|
627 |
('deleted', 'dirtoremove'), |
|
628 |
('deleted', 'filetoremove'), |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
629 |
}
|
4183.5.5
by Robert Collins
Enable record_iter_changes for cases where it can work. |
630 |
result = set(reporter.calls) |
631 |
missing = expected - result |
|
632 |
new = result - expected |
|
633 |
self.assertEqual((set(), set()), (missing, new)) |
|
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
634 |
|
635 |
def test_commit_removals_respects_filespec(self): |
|
636 |
"""Commit respects the specified_files for removals.""" |
|
637 |
tree = self.make_branch_and_tree('.') |
|
638 |
self.build_tree(['a', 'b']) |
|
639 |
tree.add(['a', 'b']) |
|
640 |
tree.commit('added a, b') |
|
641 |
tree.remove(['a', 'b']) |
|
1906.1.1
by Robert Collins
(robertc) Trivial change to test_commit_removals_respects_filespec to be easir to read. |
642 |
tree.commit('removed a', specific_files='a') |
2255.2.148
by John Arbash Meinel
lock a basis tree during a commit test. |
643 |
basis = tree.basis_tree() |
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
644 |
with tree.lock_read(): |
645 |
self.assertFalse(basis.is_versioned('a')) |
|
646 |
self.assertTrue(basis.is_versioned('b')) |
|
1864.2.1
by John Arbash Meinel
Commit timestamp restricted to 1ms precision. |
647 |
|
648 |
def test_commit_saves_1ms_timestamp(self): |
|
649 |
"""Passing in a timestamp is saved with 1ms resolution""" |
|
650 |
tree = self.make_branch_and_tree('.') |
|
651 |
self.build_tree(['a']) |
|
652 |
tree.add('a') |
|
653 |
tree.commit('added a', timestamp=1153248633.4186721, timezone=0, |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
654 |
rev_id=b'a1') |
1864.2.1
by John Arbash Meinel
Commit timestamp restricted to 1ms precision. |
655 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
656 |
rev = tree.branch.repository.get_revision(b'a1') |
1864.2.1
by John Arbash Meinel
Commit timestamp restricted to 1ms precision. |
657 |
self.assertEqual(1153248633.419, rev.timestamp) |
658 |
||
659 |
def test_commit_has_1ms_resolution(self): |
|
660 |
"""Allowing commit to generate the timestamp also has 1ms resolution""" |
|
661 |
tree = self.make_branch_and_tree('.') |
|
662 |
self.build_tree(['a']) |
|
663 |
tree.add('a') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
664 |
tree.commit('added a', rev_id=b'a1') |
1864.2.1
by John Arbash Meinel
Commit timestamp restricted to 1ms precision. |
665 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
666 |
rev = tree.branch.repository.get_revision(b'a1') |
1864.2.1
by John Arbash Meinel
Commit timestamp restricted to 1ms precision. |
667 |
timestamp = rev.timestamp |
668 |
timestamp_1ms = round(timestamp, 3) |
|
669 |
self.assertEqual(timestamp_1ms, timestamp) |
|
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
670 |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
671 |
def assertBasisTreeKind(self, kind, tree, path): |
2255.2.135
by John Arbash Meinel
Add locking in the test_commit_kind_changes test. |
672 |
basis = tree.basis_tree() |
673 |
basis.lock_read() |
|
674 |
try: |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
675 |
self.assertEqual(kind, basis.kind(path)) |
2255.2.135
by John Arbash Meinel
Add locking in the test_commit_kind_changes test. |
676 |
finally: |
677 |
basis.unlock() |
|
678 |
||
6469.1.20
by Parth Malwankar
added commit test |
679 |
def test_unsupported_symlink_commit(self): |
6469.1.21
by Parth Malwankar
SymlinkFeature required for test |
680 |
self.requireFeature(SymlinkFeature) |
6469.1.20
by Parth Malwankar
added commit test |
681 |
tree = self.make_branch_and_tree('.') |
682 |
self.build_tree(['hello']) |
|
683 |
tree.add('hello') |
|
7122.6.11
by Jelmer Vernooij
Fix another test on python3. |
684 |
tree.commit('added hello', rev_id=b'hello_id') |
6469.1.20
by Parth Malwankar
added commit test |
685 |
os.symlink('hello', 'foo') |
686 |
tree.add('foo') |
|
7122.6.11
by Jelmer Vernooij
Fix another test on python3. |
687 |
tree.commit('added foo', rev_id=b'foo_id') |
688 |
log = BytesIO() |
|
6469.1.20
by Parth Malwankar
added commit test |
689 |
trace.push_log_file(log) |
690 |
os_symlink = getattr(os, 'symlink', None) |
|
691 |
os.symlink = None |
|
692 |
try: |
|
693 |
# At this point as bzr thinks symlinks are not supported
|
|
694 |
# we should get a warning about symlink foo and bzr should
|
|
695 |
# not think its removed.
|
|
696 |
os.unlink('foo') |
|
697 |
self.build_tree(['world']) |
|
698 |
tree.add('world') |
|
7122.6.11
by Jelmer Vernooij
Fix another test on python3. |
699 |
tree.commit('added world', rev_id=b'world_id') |
6469.1.20
by Parth Malwankar
added commit test |
700 |
finally: |
701 |
if os_symlink: |
|
702 |
os.symlink = os_symlink |
|
703 |
self.assertContainsRe( |
|
704 |
log.getvalue(), |
|
7122.6.11
by Jelmer Vernooij
Fix another test on python3. |
705 |
b'Ignoring "foo" as symlinks are not ' |
706 |
b'supported on this filesystem\\.') |
|
6469.1.20
by Parth Malwankar
added commit test |
707 |
|
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
708 |
def test_commit_kind_changes(self): |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
709 |
self.requireFeature(SymlinkFeature) |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
710 |
tree = self.make_branch_and_tree('.') |
711 |
os.symlink('target', 'name') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
712 |
tree.add('name', b'a-file-id') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
713 |
tree.commit('Added a symlink') |
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
714 |
self.assertBasisTreeKind('symlink', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
715 |
|
716 |
os.unlink('name') |
|
717 |
self.build_tree(['name']) |
|
718 |
tree.commit('Changed symlink to file') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
719 |
self.assertBasisTreeKind('file', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
720 |
|
721 |
os.unlink('name') |
|
722 |
os.symlink('target', 'name') |
|
723 |
tree.commit('file to symlink') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
724 |
self.assertBasisTreeKind('symlink', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
725 |
|
726 |
os.unlink('name') |
|
727 |
os.mkdir('name') |
|
728 |
tree.commit('symlink to directory') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
729 |
self.assertBasisTreeKind('directory', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
730 |
|
731 |
os.rmdir('name') |
|
732 |
os.symlink('target', 'name') |
|
733 |
tree.commit('directory to symlink') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
734 |
self.assertBasisTreeKind('symlink', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
735 |
|
736 |
# prepare for directory <-> file tests
|
|
737 |
os.unlink('name') |
|
738 |
os.mkdir('name') |
|
739 |
tree.commit('symlink to directory') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
740 |
self.assertBasisTreeKind('directory', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
741 |
|
742 |
os.rmdir('name') |
|
743 |
self.build_tree(['name']) |
|
744 |
tree.commit('Changed directory to file') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
745 |
self.assertBasisTreeKind('file', tree, 'name') |
1959.4.1
by Aaron Bentley
Correctly handle all file kind changes |
746 |
|
747 |
os.unlink('name') |
|
748 |
os.mkdir('name') |
|
749 |
tree.commit('file to directory') |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
750 |
self.assertBasisTreeKind('directory', tree, 'name') |
1959.4.2
by Aaron Bentley
Merge bzr.dev |
751 |
|
1551.8.29
by Aaron Bentley
Stop accepting non-existant files in commit (#50793) |
752 |
def test_commit_unversioned_specified(self): |
753 |
"""Commit should raise if specified files isn't in basis or worktree""" |
|
754 |
tree = self.make_branch_and_tree('.') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
755 |
self.assertRaises(errors.PathsNotVersionedError, tree.commit, |
1551.8.29
by Aaron Bentley
Stop accepting non-existant files in commit (#50793) |
756 |
'message', specific_files=['bogus']) |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
757 |
|
758 |
class Callback(object): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
759 |
|
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
760 |
def __init__(self, message, testcase): |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
761 |
self.called = False |
762 |
self.message = message |
|
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
763 |
self.testcase = testcase |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
764 |
|
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
765 |
def __call__(self, commit_obj): |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
766 |
self.called = True |
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
767 |
self.testcase.assertTrue(isinstance(commit_obj, Commit)) |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
768 |
return self.message |
769 |
||
770 |
def test_commit_callback(self): |
|
771 |
"""Commit should invoke a callback to get the message""" |
|
772 |
||
773 |
tree = self.make_branch_and_tree('.') |
|
774 |
try: |
|
775 |
tree.commit() |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
776 |
except Exception as e: |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
777 |
self.assertTrue(isinstance(e, BzrError)) |
2149.1.3
by Aaron Bentley
Updates from review comments |
778 |
self.assertEqual('The message or message_callback keyword' |
779 |
' parameter is required for commit().', str(e)) |
|
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
780 |
else: |
781 |
self.fail('exception not raised') |
|
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
782 |
cb = self.Callback(u'commit 1', self) |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
783 |
tree.commit(message_callback=cb) |
784 |
self.assertTrue(cb.called) |
|
785 |
repository = tree.branch.repository |
|
786 |
message = repository.get_revision(tree.last_revision()).message |
|
787 |
self.assertEqual('commit 1', message) |
|
788 |
||
789 |
def test_no_callback_pointless(self): |
|
790 |
"""Callback should not be invoked for pointless commit""" |
|
791 |
tree = self.make_branch_and_tree('.') |
|
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
792 |
cb = self.Callback(u'commit 2', self) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
793 |
self.assertRaises(PointlessCommit, tree.commit, message_callback=cb, |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
794 |
allow_pointless=False) |
795 |
self.assertFalse(cb.called) |
|
796 |
||
797 |
def test_no_callback_netfailure(self): |
|
798 |
"""Callback should not be invoked if connectivity fails""" |
|
2149.1.3
by Aaron Bentley
Updates from review comments |
799 |
tree = self.make_branch_and_tree('.') |
2149.1.4
by Aaron Bentley
Add additional test that callback is called with a Commit instance |
800 |
cb = self.Callback(u'commit 2', self) |
2149.1.3
by Aaron Bentley
Updates from review comments |
801 |
repository = tree.branch.repository |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
802 |
# simulate network failure
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
803 |
|
4617.2.1
by Robert Collins
Fix test_commit for use with 2a as the default repository. |
804 |
def raise_(self, arg, arg2, arg3=None, arg4=None): |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
805 |
raise errors.NoSuchFile('foo') |
806 |
repository.add_inventory = raise_ |
|
4617.2.1
by Robert Collins
Fix test_commit for use with 2a as the default repository. |
807 |
repository.add_inventory_by_delta = raise_ |
2149.1.1
by Aaron Bentley
Provide a message_callback parameter to tree.commit |
808 |
self.assertRaises(errors.NoSuchFile, tree.commit, message_callback=cb) |
809 |
self.assertFalse(cb.called) |
|
1551.15.9
by Aaron Bentley
Better error for selected-file commit of merges |
810 |
|
811 |
def test_selected_file_merge_commit(self): |
|
812 |
"""Ensure the correct error is raised""" |
|
813 |
tree = self.make_branch_and_tree('foo') |
|
814 |
# pending merge would turn into a left parent
|
|
815 |
tree.commit('commit 1') |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
816 |
tree.add_parent_tree_id(b'example') |
1551.15.9
by Aaron Bentley
Better error for selected-file commit of merges |
817 |
self.build_tree(['foo/bar', 'foo/baz']) |
818 |
tree.add(['bar', 'baz']) |
|
6734.1.20
by Jelmer Vernooij
Move errors. |
819 |
err = self.assertRaises(CannotCommitSelectedFileMerge, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
820 |
tree.commit, 'commit 2', specific_files=['bar', 'baz']) |
1551.15.9
by Aaron Bentley
Better error for selected-file commit of merges |
821 |
self.assertEqual(['bar', 'baz'], err.files) |
822 |
self.assertEqual('Selected-file commit of merges is not supported' |
|
823 |
' yet: files bar, baz', str(err)) |
|
2671.2.2
by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name. |
824 |
|
2829.1.1
by Ian Clatworthy
re-apply Aaron's fix for #94975 (Ian Clatworthy) |
825 |
def test_commit_ordering(self): |
826 |
"""Test of corner-case commit ordering error""" |
|
827 |
tree = self.make_branch_and_tree('.') |
|
828 |
self.build_tree(['a/', 'a/z/', 'a/c/', 'a/z/x', 'a/z/y']) |
|
829 |
tree.add(['a/', 'a/z/', 'a/c/', 'a/z/x', 'a/z/y']) |
|
830 |
tree.commit('setup') |
|
831 |
self.build_tree(['a/c/d/']) |
|
832 |
tree.add('a/c/d') |
|
833 |
tree.rename_one('a/z/x', 'a/c/d/x') |
|
834 |
tree.commit('test', specific_files=['a/z/y']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
835 |
|
2671.2.2
by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name. |
836 |
def test_commit_no_author(self): |
837 |
"""The default kwarg author in MutableTree.commit should not add |
|
838 |
the 'author' revision property.
|
|
839 |
"""
|
|
840 |
tree = self.make_branch_and_tree('foo') |
|
841 |
rev_id = tree.commit('commit 1') |
|
842 |
rev = tree.branch.repository.get_revision(rev_id) |
|
843 |
self.assertFalse('author' in rev.properties) |
|
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
844 |
self.assertFalse('authors' in rev.properties) |
2671.2.2
by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name. |
845 |
|
846 |
def test_commit_author(self): |
|
6630.1.1
by Jelmer Vernooij
Remove deprecated functionality. |
847 |
"""Passing a non-empty authors kwarg to MutableTree.commit should add |
2671.2.2
by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name. |
848 |
the 'author' revision property.
|
849 |
"""
|
|
850 |
tree = self.make_branch_and_tree('foo') |
|
6630.1.1
by Jelmer Vernooij
Remove deprecated functionality. |
851 |
rev_id = tree.commit( |
852 |
'commit 1', |
|
853 |
authors=['John Doe <jdoe@example.com>']) |
|
2671.2.2
by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name. |
854 |
rev = tree.branch.repository.get_revision(rev_id) |
855 |
self.assertEqual('John Doe <jdoe@example.com>', |
|
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
856 |
rev.properties['authors']) |
857 |
self.assertFalse('author' in rev.properties) |
|
3113.6.7
by Aaron Bentley
Fix commit for a checkout sharing a repo with its branch (abentley, #177592) |
858 |
|
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
859 |
def test_commit_empty_authors_list(self): |
860 |
"""Passing an empty list to authors shouldn't add the property.""" |
|
861 |
tree = self.make_branch_and_tree('foo') |
|
862 |
rev_id = tree.commit('commit 1', authors=[]) |
|
863 |
rev = tree.branch.repository.get_revision(rev_id) |
|
864 |
self.assertFalse('author' in rev.properties) |
|
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
865 |
self.assertFalse('authors' in rev.properties) |
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
866 |
|
867 |
def test_multiple_authors(self): |
|
868 |
tree = self.make_branch_and_tree('foo') |
|
869 |
rev_id = tree.commit('commit 1', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
870 |
authors=['John Doe <jdoe@example.com>', |
871 |
'Jane Rey <jrey@example.com>']) |
|
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
872 |
rev = tree.branch.repository.get_revision(rev_id) |
873 |
self.assertEqual('John Doe <jdoe@example.com>\n' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
874 |
'Jane Rey <jrey@example.com>', rev.properties['authors']) |
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
875 |
self.assertFalse('author' in rev.properties) |
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
876 |
|
877 |
def test_author_with_newline_rejected(self): |
|
878 |
tree = self.make_branch_and_tree('foo') |
|
879 |
self.assertRaises(AssertionError, tree.commit, 'commit 1', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
880 |
authors=['John\nDoe <jdoe@example.com>']) |
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
881 |
|
3113.6.7
by Aaron Bentley
Fix commit for a checkout sharing a repo with its branch (abentley, #177592) |
882 |
def test_commit_with_checkout_and_branch_sharing_repo(self): |
883 |
repo = self.make_repository('repo', shared=True) |
|
884 |
# make_branch_and_tree ignores shared repos
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
885 |
branch = controldir.ControlDir.create_branch_convenience('repo/branch') |
3113.6.7
by Aaron Bentley
Fix commit for a checkout sharing a repo with its branch (abentley, #177592) |
886 |
tree2 = branch.create_checkout('repo/tree2') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
887 |
tree2.commit('message', rev_id=b'rev1') |
6973.5.2
by Jelmer Vernooij
Add more bees. |
888 |
self.assertTrue(tree2.branch.repository.has_revision(b'rev1')) |
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
889 |
|
890 |
||
891 |
class FilterExcludedTests(TestCase): |
|
892 |
||
893 |
def test_add_file_not_excluded(self): |
|
894 |
changes = [ |
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
895 |
InventoryTreeChange( |
7322.1.7
by Jelmer Vernooij
Fix remaining tests. |
896 |
'fid', (None, 'newpath'), |
897 |
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'), |
|
898 |
('file', 'file'), (True, True))] |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
899 |
self.assertEqual(changes, list( |
900 |
filter_excluded(changes, ['otherpath']))) |
|
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
901 |
|
902 |
def test_add_file_excluded(self): |
|
903 |
changes = [ |
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
904 |
InventoryTreeChange( |
7322.1.7
by Jelmer Vernooij
Fix remaining tests. |
905 |
'fid', (None, 'newpath'), |
906 |
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'), |
|
907 |
('file', 'file'), (True, True))] |
|
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
908 |
self.assertEqual([], list(filter_excluded(changes, ['newpath']))) |
909 |
||
910 |
def test_delete_file_excluded(self): |
|
911 |
changes = [ |
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
912 |
InventoryTreeChange( |
7322.1.7
by Jelmer Vernooij
Fix remaining tests. |
913 |
'fid', ('somepath', None), |
914 |
0, (False, None), ('pid', None), ('newpath', None), |
|
915 |
('file', None), (True, None))] |
|
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
916 |
self.assertEqual([], list(filter_excluded(changes, ['somepath']))) |
917 |
||
918 |
def test_move_from_or_to_excluded(self): |
|
919 |
changes = [ |
|
7490.120.3
by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange. |
920 |
InventoryTreeChange( |
7322.1.7
by Jelmer Vernooij
Fix remaining tests. |
921 |
'fid', ('oldpath', 'newpath'), |
922 |
0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'), |
|
923 |
('file', 'file'), (True, True))] |
|
6699.1.1
by Jelmer Vernooij
Support excludes with "bzr commit -x". |
924 |
self.assertEqual([], list(filter_excluded(changes, ['oldpath']))) |
925 |
self.assertEqual([], list(filter_excluded(changes, ['newpath']))) |