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