bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2005, 2006 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
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 |
#
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
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 |
#
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
18 |
"""Tests for the commit CLI of bzr."""
|
|
19 |
||
20 |
import os |
|
21 |
||
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
22 |
from bzrlib import ( |
23 |
ignores, |
|
24 |
)
|
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
25 |
from bzrlib.bzrdir import BzrDir |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
26 |
from bzrlib.tests.blackbox import ExternalBase |
27 |
||
28 |
||
29 |
class TestCommit(ExternalBase): |
|
30 |
||
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
31 |
def test_05_empty_commit(self): |
32 |
"""Commit of tree with no versioned files should fail""" |
|
33 |
# If forced, it should succeed, but this is not tested here.
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
34 |
self.make_branch_and_tree('.') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
35 |
self.build_tree(['hello.txt']) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
36 |
out,err = self.run_bzr('commit -m empty', retcode=3) |
2089.1.1
by wang
If a commit fails, the commit message is stored in a file at the root of |
37 |
self.assertEqual('', out) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
38 |
self.assertContainsRe(err, 'bzr: ERROR: no changes to commit\.' |
2089.1.1
by wang
If a commit fails, the commit message is stored in a file at the root of |
39 |
' use --unchanged to commit anyhow\n') |
40 |
||
41 |
def test_commit_success(self): |
|
42 |
"""Successful commit should not leave behind a bzr-commit-* file""" |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
43 |
self.make_branch_and_tree('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
44 |
self.run_bzr('commit --unchanged -m message') |
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
45 |
self.assertEqual('', self.run_bzr('unknowns')[0]) |
2089.1.1
by wang
If a commit fails, the commit message is stored in a file at the root of |
46 |
|
47 |
# same for unicode messages
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
48 |
self.run_bzr(["commit", "--unchanged", "-m", u'foo\xb5']) |
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
49 |
self.assertEqual('', self.run_bzr('unknowns')[0]) |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
50 |
|
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
51 |
def test_commit_with_path(self): |
52 |
"""Commit tree with path of root specified""" |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
53 |
a_tree = self.make_branch_and_tree('a') |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
54 |
self.build_tree(['a/a_file']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
55 |
a_tree.add('a_file') |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
56 |
self.run_bzr(['commit', '-m', 'first commit', 'a']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
57 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
58 |
b_tree = a_tree.bzrdir.sprout('b').open_workingtree() |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
59 |
self.build_tree_contents([('b/a_file', 'changes in b')]) |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
60 |
self.run_bzr(['commit', '-m', 'first commit in b', 'b']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
61 |
|
62 |
self.build_tree_contents([('a/a_file', 'new contents')]) |
|
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
63 |
self.run_bzr(['commit', '-m', 'change in a', 'a']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
64 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
65 |
b_tree.merge_from_branch(a_tree.branch) |
2738.4.2
by Daniel Watkins
Now test for conflicts where appropriate. |
66 |
self.assertEqual(len(b_tree.conflicts()), 1) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
67 |
self.run_bzr('resolved b/a_file') |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
68 |
self.run_bzr(['commit', '-m', 'merge into b', 'b']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
69 |
|
70 |
||
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
71 |
def test_10_verbose_commit(self): |
72 |
"""Add one file and examine verbose commit output""" |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
73 |
tree = self.make_branch_and_tree('.') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
74 |
self.build_tree(['hello.txt']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
75 |
tree.add("hello.txt") |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
76 |
out,err = self.run_bzr('commit -m added') |
77 |
self.assertEqual('', out) |
|
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
78 |
self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
79 |
'added hello.txt\n' |
80 |
'Committed revision 1.\n$',) |
|
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
81 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
82 |
def prepare_simple_history(self): |
83 |
"""Prepare and return a working tree with one commit of one file""" |
|
84 |
# Commit with modified file should say so
|
|
85 |
wt = BzrDir.create_standalone_workingtree('.') |
|
86 |
self.build_tree(['hello.txt', 'extra.txt']) |
|
87 |
wt.add(['hello.txt']) |
|
88 |
wt.commit(message='added') |
|
89 |
return wt |
|
90 |
||
91 |
def test_verbose_commit_modified(self): |
|
92 |
# Verbose commit of modified file should say so
|
|
93 |
wt = self.prepare_simple_history() |
|
94 |
self.build_tree_contents([('hello.txt', 'new contents')]) |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
95 |
out, err = self.run_bzr('commit -m modified') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
96 |
self.assertEqual('', out) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
97 |
self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n' |
98 |
'modified hello\.txt\n' |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
99 |
'Committed revision 2\.\n$') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
100 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
101 |
def test_verbose_commit_renamed(self): |
102 |
# Verbose commit of renamed file should say so
|
|
103 |
wt = self.prepare_simple_history() |
|
104 |
wt.rename_one('hello.txt', 'gutentag.txt') |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
105 |
out, err = self.run_bzr('commit -m renamed') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
106 |
self.assertEqual('', out) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
107 |
self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n' |
108 |
'renamed hello\.txt => gutentag\.txt\n' |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
109 |
'Committed revision 2\.$\n') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
110 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
111 |
def test_verbose_commit_moved(self): |
112 |
# Verbose commit of file moved to new directory should say so
|
|
113 |
wt = self.prepare_simple_history() |
|
114 |
os.mkdir('subdir') |
|
115 |
wt.add(['subdir']) |
|
116 |
wt.rename_one('hello.txt', 'subdir/hello.txt') |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
117 |
out, err = self.run_bzr('commit -m renamed') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
118 |
self.assertEqual('', out) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
119 |
self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n' |
120 |
'added subdir\n' |
|
121 |
'renamed hello\.txt => subdir/hello\.txt\n' |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
122 |
'Committed revision 2\.\n$') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
123 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
124 |
def test_verbose_commit_with_unknown(self): |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
125 |
"""Unknown files should not be listed by default in verbose output""" |
126 |
# Is that really the best policy?
|
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
127 |
wt = BzrDir.create_standalone_workingtree('.') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
128 |
self.build_tree(['hello.txt', 'extra.txt']) |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
129 |
wt.add(['hello.txt']) |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
130 |
out,err = self.run_bzr('commit -m added') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
131 |
self.assertEqual('', out) |
2789.2.7
by Ian Clatworthy
merge bzr.dev including updates to test_commit |
132 |
self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
133 |
'added hello\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
134 |
'Committed revision 1\.\n$') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
135 |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
136 |
def test_verbose_commit_with_unchanged(self): |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
137 |
"""Unchanged files should not be listed by default in verbose output""" |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
138 |
tree = self.make_branch_and_tree('.') |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
139 |
self.build_tree(['hello.txt', 'unchanged.txt']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
140 |
tree.add('unchanged.txt') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
141 |
self.run_bzr('commit -m unchanged unchanged.txt') |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
142 |
tree.add("hello.txt") |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
143 |
out,err = self.run_bzr('commit -m added') |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
144 |
self.assertEqual('', out) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
145 |
self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n' |
146 |
'added hello\.txt\n' |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
147 |
'Committed revision 2\.$\n') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
148 |
|
2747.6.13
by Daniel Watkins
Renamed test to reflect what it is actually doing. |
149 |
def test_verbose_commit_includes_master_location(self): |
2747.6.4
by Daniel Watkins
Modified test as suggested on-list. |
150 |
"""Location of master is displayed when committing to bound branch""" |
2747.6.2
by Daniel Watkins
Added test for behaviour. |
151 |
a_tree = self.make_branch_and_tree('a') |
152 |
self.build_tree(['a/b']) |
|
153 |
a_tree.add('b') |
|
154 |
a_tree.commit(message='Initial message') |
|
155 |
||
156 |
b_tree = a_tree.branch.create_checkout('b') |
|
2747.6.12
by Daniel Watkins
Modified tests to match new output. |
157 |
expected = "%s/" % (os.path.abspath('a'), ) |
2747.6.4
by Daniel Watkins
Modified test as suggested on-list. |
158 |
out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b') |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
159 |
self.assertEqual(err, 'Committing revision 2 to "%s".\n' |
160 |
'Committed revision 2.\n' % expected) |
|
2747.6.2
by Daniel Watkins
Added test for behaviour. |
161 |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
162 |
def test_commit_merge_reports_all_modified_files(self): |
163 |
# the commit command should show all the files that are shown by
|
|
164 |
# bzr diff or bzr status when committing, even when they were not
|
|
165 |
# changed by the user but rather through doing a merge.
|
|
166 |
this_tree = self.make_branch_and_tree('this') |
|
167 |
# we need a bunch of files and dirs, to perform one action on each.
|
|
168 |
self.build_tree([ |
|
169 |
'this/dirtorename/', |
|
170 |
'this/dirtoreparent/', |
|
171 |
'this/dirtoleave/', |
|
172 |
'this/dirtoremove/', |
|
173 |
'this/filetoreparent', |
|
174 |
'this/filetorename', |
|
175 |
'this/filetomodify', |
|
176 |
'this/filetoremove', |
|
177 |
'this/filetoleave'] |
|
178 |
)
|
|
179 |
this_tree.add([ |
|
180 |
'dirtorename', |
|
181 |
'dirtoreparent', |
|
182 |
'dirtoleave', |
|
183 |
'dirtoremove', |
|
184 |
'filetoreparent', |
|
185 |
'filetorename', |
|
186 |
'filetomodify', |
|
187 |
'filetoremove', |
|
188 |
'filetoleave'] |
|
189 |
)
|
|
190 |
this_tree.commit('create_files') |
|
191 |
other_dir = this_tree.bzrdir.sprout('other') |
|
192 |
other_tree = other_dir.open_workingtree() |
|
193 |
other_tree.lock_write() |
|
194 |
# perform the needed actions on the files and dirs.
|
|
195 |
try: |
|
196 |
other_tree.rename_one('dirtorename', 'renameddir') |
|
197 |
other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir') |
|
198 |
other_tree.rename_one('filetorename', 'renamedfile') |
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
199 |
other_tree.rename_one('filetoreparent', |
200 |
'renameddir/reparentedfile') |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
201 |
other_tree.remove(['dirtoremove', 'filetoremove']) |
202 |
self.build_tree_contents([ |
|
2738.4.5
by Daniel Watkins
Fixed whitespace issues. |
203 |
('other/newdir/',), |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
204 |
('other/filetomodify', 'new content'), |
205 |
('other/newfile', 'new file content')]) |
|
206 |
other_tree.add('newfile') |
|
207 |
other_tree.add('newdir/') |
|
208 |
other_tree.commit('modify all sample files and dirs.') |
|
209 |
finally: |
|
210 |
other_tree.unlock() |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
211 |
this_tree.merge_from_branch(other_tree.branch) |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
212 |
os.chdir('this') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
213 |
out,err = self.run_bzr('commit -m added') |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
214 |
self.assertEqual('', out) |
2747.6.12
by Daniel Watkins
Modified tests to match new output. |
215 |
expected = '%s/' % (os.getcwd(), ) |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
216 |
self.assertEqualDiff( |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
217 |
'Committing revision 2 to "%s".\n' |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
218 |
'modified filetomodify\n' |
219 |
'added newdir\n' |
|
220 |
'added newfile\n' |
|
221 |
'renamed dirtorename => renameddir\n' |
|
222 |
'renamed dirtoreparent => renameddir/reparenteddir\n' |
|
223 |
'renamed filetoreparent => renameddir/reparentedfile\n' |
|
2484.1.25
by John Arbash Meinel
[merge] bzr.dev 2612 |
224 |
'renamed filetorename => renamedfile\n' |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
225 |
'deleted dirtoremove\n' |
226 |
'deleted filetoremove\n' |
|
2747.6.12
by Daniel Watkins
Modified tests to match new output. |
227 |
'Committed revision 2.\n' % (expected, ), |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
228 |
err) |
229 |
||
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
230 |
def test_empty_commit_message(self): |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
231 |
tree = self.make_branch_and_tree('.') |
232 |
self.build_tree_contents([('foo.c', 'int main() {}')]) |
|
233 |
tree.add('foo.c') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
234 |
self.run_bzr('commit -m ""', retcode=3) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
235 |
|
2625.9.2
by Daniel Watkins
Added test to ensure correct error message is given if an unencodable commit message is given at the command line. |
236 |
def test_unsupported_encoding_commit_message(self): |
237 |
tree = self.make_branch_and_tree('.') |
|
238 |
self.build_tree_contents([('foo.c', 'int main() {}')]) |
|
239 |
tree.add('foo.c') |
|
240 |
out,err = self.run_bzr_subprocess('commit -m "\xff"', retcode=1, |
|
241 |
env_changes={'LANG': 'C'}) |
|
242 |
self.assertContainsRe(err, r'bzrlib.errors.BzrError: Parameter.*is ' |
|
243 |
'unsupported by the current encoding.') |
|
244 |
||
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
245 |
def test_other_branch_commit(self): |
246 |
# this branch is to ensure consistent behaviour, whether we're run
|
|
247 |
# inside a branch, or not.
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
248 |
outer_tree = self.make_branch_and_tree('.') |
249 |
inner_tree = self.make_branch_and_tree('branch') |
|
250 |
self.build_tree_contents([ |
|
251 |
('branch/foo.c', 'int main() {}'), |
|
252 |
('branch/bar.c', 'int main() {}')]) |
|
253 |
inner_tree.add('foo.c') |
|
254 |
inner_tree.add('bar.c') |
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
255 |
# can't commit files in different trees; sane error
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
256 |
self.run_bzr('commit -m newstuff branch/foo.c .', retcode=3) |
257 |
self.run_bzr('commit -m newstuff branch/foo.c') |
|
258 |
self.run_bzr('commit -m newstuff branch') |
|
259 |
self.run_bzr('commit -m newstuff branch', retcode=3) |
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
260 |
|
261 |
def test_out_of_date_tree_commit(self): |
|
262 |
# check we get an error code and a clear message committing with an out
|
|
263 |
# of date checkout
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
264 |
tree = self.make_branch_and_tree('branch') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
265 |
# make a checkout
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
266 |
checkout = tree.branch.create_checkout('checkout', lightweight=True) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
267 |
# commit to the original branch to make the checkout out of date
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
268 |
tree.commit('message branch', allow_pointless=True) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
269 |
# now commit to the checkout should emit
|
270 |
# ERROR: Out of date with the branch, 'bzr update' is suggested
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
271 |
output = self.run_bzr('commit --unchanged -m checkout_message ' |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
272 |
'checkout', retcode=3) |
273 |
self.assertEqual(output, |
|
274 |
('', |
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
275 |
"bzr: ERROR: Working tree is out of date, please "
|
276 |
"run 'bzr update'.\n")) |
|
1587.1.8
by Robert Collins
Local commits on unbound branches fail. |
277 |
|
278 |
def test_local_commit_unbound(self): |
|
279 |
# a --local commit on an unbound branch is an error
|
|
280 |
self.make_branch_and_tree('.') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
281 |
out, err = self.run_bzr('commit --local', retcode=3) |
1587.1.8
by Robert Collins
Local commits on unbound branches fail. |
282 |
self.assertEqualDiff('', out) |
283 |
self.assertEqualDiff('bzr: ERROR: Cannot perform local-only commits ' |
|
284 |
'on unbound branches.\n', err) |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
285 |
|
286 |
def test_commit_a_text_merge_in_a_checkout(self): |
|
287 |
# checkouts perform multiple actions in a transaction across bond
|
|
288 |
# branches and their master, and have been observed to fail in the
|
|
289 |
# past. This is a user story reported to fail in bug #43959 where
|
|
290 |
# a merge done in a checkout (using the update command) failed to
|
|
291 |
# commit correctly.
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
292 |
trunk = self.make_branch_and_tree('trunk') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
293 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
294 |
u1 = trunk.branch.create_checkout('u1') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
295 |
self.build_tree_contents([('u1/hosts', 'initial contents')]) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
296 |
u1.add('hosts') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
297 |
self.run_bzr('commit -m add-hosts u1') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
298 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
299 |
u2 = trunk.branch.create_checkout('u2') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
300 |
self.build_tree_contents([('u2/hosts', 'altered in u2')]) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
301 |
self.run_bzr('commit -m checkin-from-u2 u2') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
302 |
|
303 |
# make an offline commits
|
|
304 |
self.build_tree_contents([('u1/hosts', 'first offline change in u1')]) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
305 |
self.run_bzr('commit -m checkin-offline --local u1') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
306 |
|
307 |
# now try to pull in online work from u2, and then commit our offline
|
|
308 |
# work as a merge
|
|
309 |
# retcode 1 as we expect a text conflict
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
310 |
self.run_bzr('update u1', retcode=1) |
311 |
self.run_bzr('resolved u1/hosts') |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
312 |
# add a text change here to represent resolving the merge conflicts in
|
313 |
# favour of a new version of the file not identical to either the u1
|
|
314 |
# version or the u2 version.
|
|
315 |
self.build_tree_contents([('u1/hosts', 'merge resolution\n')]) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
316 |
self.run_bzr('commit -m checkin-merge-of-the-offline-work-from-u1 u1') |
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
317 |
|
318 |
def test_commit_respects_spec_for_removals(self): |
|
319 |
"""Commit with a file spec should only commit removals that match""" |
|
320 |
t = self.make_branch_and_tree('.') |
|
321 |
self.build_tree(['file-a', 'dir-a/', 'dir-a/file-b']) |
|
322 |
t.add(['file-a', 'dir-a', 'dir-a/file-b']) |
|
323 |
t.commit('Create') |
|
324 |
t.remove(['file-a', 'dir-a/file-b']) |
|
325 |
os.chdir('dir-a') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
326 |
result = self.run_bzr('commit . -m removed-file-b')[1] |
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
327 |
self.assertNotContainsRe(result, 'file-a') |
328 |
result = self.run_bzr('status')[0] |
|
329 |
self.assertContainsRe(result, 'removed:\n file-a') |
|
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
330 |
|
331 |
def test_strict_commit(self): |
|
332 |
"""Commit with --strict works if everything is known""" |
|
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
333 |
ignores._set_user_ignores([]) |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
334 |
tree = self.make_branch_and_tree('tree') |
335 |
self.build_tree(['tree/a']) |
|
336 |
tree.add('a') |
|
337 |
# A simple change should just work
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
338 |
self.run_bzr('commit --strict -m adding-a', |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
339 |
working_dir='tree') |
340 |
||
341 |
def test_strict_commit_no_changes(self): |
|
342 |
"""commit --strict gives "no changes" if there is nothing to commit""" |
|
343 |
tree = self.make_branch_and_tree('tree') |
|
344 |
self.build_tree(['tree/a']) |
|
345 |
tree.add('a') |
|
346 |
tree.commit('adding a') |
|
347 |
||
348 |
# With no changes, it should just be 'no changes'
|
|
349 |
# Make sure that commit is failing because there is nothing to do
|
|
350 |
self.run_bzr_error(['no changes to commit'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
351 |
'commit --strict -m no-changes', |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
352 |
working_dir='tree') |
353 |
||
354 |
# But --strict doesn't care if you supply --unchanged
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
355 |
self.run_bzr('commit --strict --unchanged -m no-changes', |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
356 |
working_dir='tree') |
357 |
||
358 |
def test_strict_commit_unknown(self): |
|
359 |
"""commit --strict fails if a file is unknown""" |
|
360 |
tree = self.make_branch_and_tree('tree') |
|
361 |
self.build_tree(['tree/a']) |
|
362 |
tree.add('a') |
|
363 |
tree.commit('adding a') |
|
364 |
||
365 |
# Add one file so there is a change, but forget the other
|
|
366 |
self.build_tree(['tree/b', 'tree/c']) |
|
367 |
tree.add('b') |
|
368 |
self.run_bzr_error(['Commit refused because there are unknown files'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
369 |
'commit --strict -m add-b', |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
370 |
working_dir='tree') |
371 |
||
372 |
# --no-strict overrides --strict
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
373 |
self.run_bzr('commit --strict -m add-b --no-strict', |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
374 |
working_dir='tree') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
375 |
|
376 |
def test_fixes_bug_output(self): |
|
377 |
"""commit --fixes=lp:23452 succeeds without output.""" |
|
2376.4.22
by Jonathan Lange
Variety of whitespace cleanups, tightening of tests and docstring changes in |
378 |
tree = self.make_branch_and_tree('tree') |
379 |
self.build_tree(['tree/hello.txt']) |
|
380 |
tree.add('hello.txt') |
|
2376.4.12
by Jonathan Lange
Update NEWS file. |
381 |
output, err = self.run_bzr( |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
382 |
'commit -m hello --fixes=lp:23452 tree/hello.txt') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
383 |
self.assertEqual('', output) |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
384 |
self.assertContainsRe(err, 'Committing revision 1 to ".*"\.\n' |
385 |
'added hello\.txt\n' |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
386 |
'Committed revision 1\.\n') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
387 |
|
2453.2.1
by Martin Pool
Don't set the bugs property unless bugs are actually set |
388 |
def test_no_bugs_no_properties(self): |
389 |
"""If no bugs are fixed, the bugs property is not set. |
|
390 |
||
391 |
see https://beta.launchpad.net/bzr/+bug/109613
|
|
392 |
"""
|
|
393 |
tree = self.make_branch_and_tree('tree') |
|
394 |
self.build_tree(['tree/hello.txt']) |
|
395 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
396 |
self.run_bzr( 'commit -m hello tree/hello.txt') |
2453.2.1
by Martin Pool
Don't set the bugs property unless bugs are actually set |
397 |
# Get the revision properties, ignoring the branch-nick property, which
|
398 |
# we don't care about for this test.
|
|
399 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
400 |
properties = dict(last_rev.properties) |
|
401 |
del properties['branch-nick'] |
|
402 |
self.assertFalse('bugs' in properties) |
|
403 |
||
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
404 |
def test_fixes_bug_sets_property(self): |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
405 |
"""commit --fixes=lp:234 sets the lp:234 revprop to 'fixed'.""" |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
406 |
tree = self.make_branch_and_tree('tree') |
407 |
self.build_tree(['tree/hello.txt']) |
|
408 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
409 |
self.run_bzr('commit -m hello --fixes=lp:234 tree/hello.txt') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
410 |
|
411 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
412 |
# we don't care about for this test.
|
|
413 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
414 |
properties = dict(last_rev.properties) |
|
415 |
del properties['branch-nick'] |
|
416 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
417 |
self.assertEqual({'bugs': 'https://launchpad.net/bugs/234 fixed'}, |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
418 |
properties) |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
419 |
|
420 |
def test_fixes_multiple_bugs_sets_properties(self): |
|
421 |
"""--fixes can be used more than once to show that bugs are fixed.""" |
|
422 |
tree = self.make_branch_and_tree('tree') |
|
423 |
self.build_tree(['tree/hello.txt']) |
|
424 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
425 |
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=lp:235' |
426 |
' tree/hello.txt') |
|
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
427 |
|
428 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
429 |
# we don't care about for this test.
|
|
430 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
431 |
properties = dict(last_rev.properties) |
|
432 |
del properties['branch-nick'] |
|
433 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
434 |
self.assertEqual( |
2376.4.21
by Jonathan Lange
Change the bugs separator to \n from , |
435 |
{'bugs': 'https://launchpad.net/bugs/123 fixed\n' |
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
436 |
'https://launchpad.net/bugs/235 fixed'}, |
437 |
properties) |
|
2376.4.7
by jml at canonical
- Add docstrings to tests. |
438 |
|
439 |
def test_fixes_bug_with_alternate_trackers(self): |
|
440 |
"""--fixes can be used on a properly configured branch to mark bug |
|
441 |
fixes on multiple trackers.
|
|
442 |
"""
|
|
443 |
tree = self.make_branch_and_tree('tree') |
|
444 |
tree.branch.get_config().set_user_option( |
|
445 |
'trac_twisted_url', 'http://twistedmatrix.com/trac') |
|
446 |
self.build_tree(['tree/hello.txt']) |
|
447 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
448 |
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=twisted:235 tree/') |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
449 |
|
450 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
451 |
# we don't care about for this test.
|
|
452 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
453 |
properties = dict(last_rev.properties) |
|
454 |
del properties['branch-nick'] |
|
455 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
456 |
self.assertEqual( |
2376.4.21
by Jonathan Lange
Change the bugs separator to \n from , |
457 |
{'bugs': 'https://launchpad.net/bugs/123 fixed\n' |
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
458 |
'http://twistedmatrix.com/trac/ticket/235 fixed'}, |
459 |
properties) |
|
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
460 |
|
461 |
def test_fixes_unknown_bug_prefix(self): |
|
462 |
tree = self.make_branch_and_tree('tree') |
|
463 |
self.build_tree(['tree/hello.txt']) |
|
464 |
tree.add('hello.txt') |
|
465 |
self.run_bzr_error( |
|
466 |
["Unrecognized bug %s. Commit refused." % 'xxx:123'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
467 |
'commit -m add-b --fixes=xxx:123', |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
468 |
working_dir='tree') |
469 |
||
470 |
def test_fixes_invalid_bug_number(self): |
|
471 |
tree = self.make_branch_and_tree('tree') |
|
472 |
self.build_tree(['tree/hello.txt']) |
|
473 |
tree.add('hello.txt') |
|
474 |
self.run_bzr_error( |
|
2376.4.7
by jml at canonical
- Add docstrings to tests. |
475 |
["Invalid bug identifier for %s. Commit refused." % 'lp:orange'], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
476 |
'commit -m add-b --fixes=lp:orange', |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
477 |
working_dir='tree') |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
478 |
|
479 |
def test_fixes_invalid_argument(self): |
|
480 |
"""Raise an appropriate error when the fixes argument isn't tag:id.""" |
|
481 |
tree = self.make_branch_and_tree('tree') |
|
482 |
self.build_tree(['tree/hello.txt']) |
|
483 |
tree.add('hello.txt') |
|
484 |
self.run_bzr_error( |
|
2376.4.13
by Jonathan Lange
Some stylistic cleanups |
485 |
[r"Invalid bug orange. Must be in the form of 'tag:id'\. " |
486 |
r"Commit refused\."], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
487 |
'commit -m add-b --fixes=orange', |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
488 |
working_dir='tree') |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
489 |
|
490 |
def test_no_author(self): |
|
491 |
"""If the author is not specified, the author property is not set.""" |
|
492 |
tree = self.make_branch_and_tree('tree') |
|
493 |
self.build_tree(['tree/hello.txt']) |
|
494 |
tree.add('hello.txt') |
|
495 |
self.run_bzr( 'commit -m hello tree/hello.txt') |
|
496 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
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. |
497 |
properties = last_rev.properties |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
498 |
self.assertFalse('author' in properties) |
499 |
||
500 |
def test_author_sets_property(self): |
|
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. |
501 |
"""commit --author='John Doe <jdoe@example.com>' sets the author |
502 |
revprop.
|
|
503 |
"""
|
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
504 |
tree = self.make_branch_and_tree('tree') |
505 |
self.build_tree(['tree/hello.txt']) |
|
506 |
tree.add('hello.txt') |
|
2671.2.4
by Lukáš Lalinský
Fixed broken test_author_* blackbox tests. |
507 |
self.run_bzr("commit -m hello --author='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. |
508 |
"tree/hello.txt") |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
509 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
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. |
510 |
properties = last_rev.properties |
511 |
self.assertEqual('John Doe <jdoe@example.com>', properties['author']) |
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
512 |
|
513 |
def test_author_no_email(self): |
|
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. |
514 |
"""Author's name without an email address is allowed, too.""" |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
515 |
tree = self.make_branch_and_tree('tree') |
516 |
self.build_tree(['tree/hello.txt']) |
|
517 |
tree.add('hello.txt') |
|
2671.2.4
by Lukáš Lalinský
Fixed broken test_author_* blackbox tests. |
518 |
out, err = self.run_bzr("commit -m hello --author='John Doe' " |
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. |
519 |
"tree/hello.txt") |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
520 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
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. |
521 |
properties = last_rev.properties |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
522 |
self.assertEqual('John Doe', properties['author']) |