6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006-2012, 2016 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
16 |
|
17 |
||
18 |
"""Tests for the commit CLI of bzr."""
|
|
19 |
||
5765.1.3
by John Arbash Meinel
We missed a test case that was asserting the old string. |
20 |
import doctest |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
21 |
import os |
5167.1.1
by Parth Malwankar
commit command can now accept message (-m) same as a unicode filename |
22 |
import re |
2804.4.1
by Alexander Belchenko
some win32-specific fixes for selftest |
23 |
import sys |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
24 |
|
5765.1.3
by John Arbash Meinel
We missed a test case that was asserting the old string. |
25 |
from testtools.matchers import DocTestMatches |
26 |
||
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
27 |
from bzrlib import ( |
5609.31.1
by mbp at sourcefrog
Blackbox tests for no identity set must disable whoami inference |
28 |
config, |
2846.2.1
by Alexander Belchenko
merge approved chunks |
29 |
osutils, |
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
30 |
ignores, |
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
31 |
msgeditor, |
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
32 |
)
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
33 |
from bzrlib.controldir import ControlDir |
2804.4.1
by Alexander Belchenko
some win32-specific fixes for selftest |
34 |
from bzrlib.tests import ( |
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
35 |
test_foreign, |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
36 |
features, |
2804.4.1
by Alexander Belchenko
some win32-specific fixes for selftest |
37 |
)
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
38 |
from bzrlib.tests import TestCaseWithTransport |
6352.2.3
by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/. |
39 |
from bzrlib.tests.matchers import ContainsNoVfsCalls |
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
40 |
|
41 |
||
42 |
class TestCommit(TestCaseWithTransport): |
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
43 |
|
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
44 |
def test_05_empty_commit(self): |
45 |
"""Commit of tree with no versioned files should fail"""
|
|
46 |
# 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. |
47 |
self.make_branch_and_tree('.') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
48 |
self.build_tree(['hello.txt']) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
49 |
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 |
50 |
self.assertEqual('', out) |
5765.1.3
by John Arbash Meinel
We missed a test case that was asserting the old string. |
51 |
# Two ugly bits here.
|
52 |
# 1) We really don't want 'aborting commit write group' anymore.
|
|
53 |
# 2) bzr: ERROR: is a really long line, so we wrap it with '\'
|
|
54 |
self.assertThat( |
|
55 |
err, |
|
56 |
DocTestMatches("""\ |
|
57 |
Committing to: ...
|
|
58 |
bzr: ERROR: No changes to commit.\ |
|
59 |
Please 'bzr add' the files you want to commit,\ |
|
60 |
or use --unchanged to force an empty commit.
|
|
61 |
""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF)) |
|
2089.1.1
by wang
If a commit fails, the commit message is stored in a file at the root of |
62 |
|
63 |
def test_commit_success(self): |
|
64 |
"""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. |
65 |
self.make_branch_and_tree('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
66 |
self.run_bzr('commit --unchanged -m message') |
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
67 |
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 |
68 |
|
69 |
# same for unicode messages
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
70 |
self.run_bzr(["commit", "--unchanged", "-m", u'foo\xb5']) |
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
71 |
self.assertEqual('', self.run_bzr('unknowns')[0]) |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
72 |
|
5777.6.4
by Jelmer Vernooij
Add test for lossy commit to native branch. |
73 |
def test_commit_lossy_native(self): |
74 |
"""A --lossy option to commit is supported."""
|
|
75 |
self.make_branch_and_tree('.') |
|
76 |
self.run_bzr('commit --lossy --unchanged -m message') |
|
77 |
self.assertEqual('', self.run_bzr('unknowns')[0]) |
|
78 |
||
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
79 |
def test_commit_lossy_foreign(self): |
5777.6.6
by Jelmer Vernooij
Add lossy tests. |
80 |
test_foreign.register_dummy_foreign_for_test(self) |
81 |
self.make_branch_and_tree('.', |
|
82 |
format=test_foreign.DummyForeignVcsDirFormat()) |
|
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
83 |
self.run_bzr('commit --lossy --unchanged -m message') |
5777.6.6
by Jelmer Vernooij
Add lossy tests. |
84 |
output = self.run_bzr('revision-info')[0] |
85 |
self.assertTrue(output.startswith('1 dummy-')) |
|
5777.6.5
by Jelmer Vernooij
Add tests for lossy commit. |
86 |
|
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
87 |
def test_commit_with_path(self): |
88 |
"""Commit tree with path of root specified"""
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
89 |
a_tree = self.make_branch_and_tree('a') |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
90 |
self.build_tree(['a/a_file']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
91 |
a_tree.add('a_file') |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
92 |
self.run_bzr(['commit', '-m', 'first commit', 'a']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
93 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
94 |
b_tree = a_tree.bzrdir.sprout('b').open_workingtree() |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
95 |
self.build_tree_contents([('b/a_file', 'changes in b')]) |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
96 |
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. |
97 |
|
98 |
self.build_tree_contents([('a/a_file', 'new contents')]) |
|
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
99 |
self.run_bzr(['commit', '-m', 'change in a', 'a']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
100 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
101 |
b_tree.merge_from_branch(a_tree.branch) |
2738.4.2
by Daniel Watkins
Now test for conflicts where appropriate. |
102 |
self.assertEqual(len(b_tree.conflicts()), 1) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
103 |
self.run_bzr('resolved b/a_file') |
2552.2.5
by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings. |
104 |
self.run_bzr(['commit', '-m', 'merge into b', 'b']) |
1704.2.11
by Martin Pool
Handle 'bzr commit DIR' when dir contains pending merges. |
105 |
|
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
106 |
def test_10_verbose_commit(self): |
107 |
"""Add one file and examine verbose commit output"""
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
108 |
tree = self.make_branch_and_tree('.') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
109 |
self.build_tree(['hello.txt']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
110 |
tree.add("hello.txt") |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
111 |
out,err = self.run_bzr('commit -m added') |
112 |
self.assertEqual('', out) |
|
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
113 |
self.assertContainsRe(err, '^Committing to: .*\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
114 |
'added hello.txt\n' |
115 |
'Committed revision 1.\n$',) |
|
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
116 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
117 |
def prepare_simple_history(self): |
118 |
"""Prepare and return a working tree with one commit of one file"""
|
|
119 |
# Commit with modified file should say so
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
120 |
wt = ControlDir.create_standalone_workingtree('.') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
121 |
self.build_tree(['hello.txt', 'extra.txt']) |
122 |
wt.add(['hello.txt']) |
|
123 |
wt.commit(message='added') |
|
124 |
return wt |
|
125 |
||
126 |
def test_verbose_commit_modified(self): |
|
127 |
# Verbose commit of modified file should say so
|
|
128 |
wt = self.prepare_simple_history() |
|
129 |
self.build_tree_contents([('hello.txt', 'new contents')]) |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
130 |
out, err = self.run_bzr('commit -m modified') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
131 |
self.assertEqual('', out) |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
132 |
self.assertContainsRe(err, '^Committing to: .*\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
133 |
'modified hello\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
134 |
'Committed revision 2\.\n$') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
135 |
|
5167.1.4
by Parth Malwankar
show_warning now uses 'replace' option for encoding the message. |
136 |
def test_unicode_commit_message_is_filename(self): |
5167.1.1
by Parth Malwankar
commit command can now accept message (-m) same as a unicode filename |
137 |
"""Unicode commit message same as a filename (Bug #563646).
|
138 |
"""
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
139 |
self.requireFeature(features.UnicodeFilenameFeature) |
5167.1.1
by Parth Malwankar
commit command can now accept message (-m) same as a unicode filename |
140 |
file_name = u'\N{euro sign}' |
141 |
self.run_bzr(['init']) |
|
6437.20.3
by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version |
142 |
with open(file_name, 'w') as f: f.write('hello world') |
5167.1.1
by Parth Malwankar
commit command can now accept message (-m) same as a unicode filename |
143 |
self.run_bzr(['add']) |
144 |
out, err = self.run_bzr(['commit', '-m', file_name]) |
|
145 |
reflags = re.MULTILINE|re.DOTALL|re.UNICODE |
|
5167.1.4
by Parth Malwankar
show_warning now uses 'replace' option for encoding the message. |
146 |
te = osutils.get_terminal_encoding() |
147 |
self.assertContainsRe(err.decode(te), |
|
148 |
u'The commit message is a file name:', |
|
5167.1.1
by Parth Malwankar
commit command can now accept message (-m) same as a unicode filename |
149 |
flags=reflags) |
150 |
||
5167.1.6
by Parth Malwankar
fixed comment. |
151 |
# Run same test with a filename that causes encode
|
5167.1.5
by Parth Malwankar
added test to handle case if filename cannot be shown in terminal encoding |
152 |
# error for the terminal encoding. We do this
|
153 |
# by forcing terminal encoding of ascii for
|
|
154 |
# osutils.get_terminal_encoding which is used
|
|
155 |
# by ui.text.show_warning
|
|
156 |
default_get_terminal_enc = osutils.get_terminal_encoding |
|
157 |
try: |
|
5320.2.7
by Robert Collins
Sanity check that new_trace_file in pop_log_file is valid, and also fix a test that monkey patched get_terminal_encoding. |
158 |
osutils.get_terminal_encoding = lambda trace=None: 'ascii' |
5167.1.5
by Parth Malwankar
added test to handle case if filename cannot be shown in terminal encoding |
159 |
file_name = u'foo\u1234' |
6437.20.3
by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version |
160 |
with open(file_name, 'w') as f: f.write('hello world') |
5167.1.5
by Parth Malwankar
added test to handle case if filename cannot be shown in terminal encoding |
161 |
self.run_bzr(['add']) |
162 |
out, err = self.run_bzr(['commit', '-m', file_name]) |
|
163 |
reflags = re.MULTILINE|re.DOTALL|re.UNICODE |
|
164 |
te = osutils.get_terminal_encoding() |
|
165 |
self.assertContainsRe(err.decode(te, 'replace'), |
|
166 |
u'The commit message is a file name:', |
|
167 |
flags=reflags) |
|
168 |
finally: |
|
169 |
osutils.get_terminal_encoding = default_get_terminal_enc |
|
170 |
||
6345.1.1
by Martin Packman
Add tests for non-ascii unversioned file error during commit |
171 |
def test_non_ascii_file_unversioned_utf8(self): |
172 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
173 |
tree = self.make_branch_and_tree(".") |
|
174 |
self.build_tree(["f"]) |
|
175 |
tree.add(["f"]) |
|
176 |
out, err = self.run_bzr(["commit", "-m", "Wrong filename", u"\xa7"], |
|
177 |
encoding="utf-8", retcode=3) |
|
178 |
self.assertContainsRe(err, "(?m)not versioned: \"\xc2\xa7\"$") |
|
179 |
||
180 |
def test_non_ascii_file_unversioned_iso_8859_5(self): |
|
181 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
182 |
tree = self.make_branch_and_tree(".") |
|
183 |
self.build_tree(["f"]) |
|
184 |
tree.add(["f"]) |
|
185 |
out, err = self.run_bzr(["commit", "-m", "Wrong filename", u"\xa7"], |
|
186 |
encoding="iso-8859-5", retcode=3) |
|
187 |
self.expectFailure("Error messages are always written as UTF-8", |
|
188 |
self.assertNotContainsString, err, "\xc2\xa7") |
|
189 |
self.assertContainsRe(err, "(?m)not versioned: \"\xfd\"$") |
|
190 |
||
4795.5.12
by Gioele Barabucci
Non-interactive warning for forgotten -m parameter |
191 |
def test_warn_about_forgotten_commit_message(self): |
4795.5.8
by Gioele Barabucci
Test commit cancellation in presence of a suspect -m parameter |
192 |
"""Test that the lack of -m parameter is caught"""
|
193 |
wt = self.make_branch_and_tree('.') |
|
194 |
self.build_tree(['one', 'two']) |
|
195 |
wt.add(['two']) |
|
4795.5.12
by Gioele Barabucci
Non-interactive warning for forgotten -m parameter |
196 |
out, err = self.run_bzr('commit -m one two') |
197 |
self.assertContainsRe(err, "The commit message is a file name") |
|
4795.5.8
by Gioele Barabucci
Test commit cancellation in presence of a suspect -m parameter |
198 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
199 |
def test_verbose_commit_renamed(self): |
200 |
# Verbose commit of renamed file should say so
|
|
201 |
wt = self.prepare_simple_history() |
|
202 |
wt.rename_one('hello.txt', 'gutentag.txt') |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
203 |
out, err = self.run_bzr('commit -m renamed') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
204 |
self.assertEqual('', out) |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
205 |
self.assertContainsRe(err, '^Committing to: .*\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
206 |
'renamed hello\.txt => gutentag\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
207 |
'Committed revision 2\.$\n') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
208 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
209 |
def test_verbose_commit_moved(self): |
210 |
# Verbose commit of file moved to new directory should say so
|
|
211 |
wt = self.prepare_simple_history() |
|
212 |
os.mkdir('subdir') |
|
213 |
wt.add(['subdir']) |
|
214 |
wt.rename_one('hello.txt', 'subdir/hello.txt') |
|
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
215 |
out, err = self.run_bzr('commit -m renamed') |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
216 |
self.assertEqual('', out) |
4183.5.5
by Robert Collins
Enable record_iter_changes for cases where it can work. |
217 |
self.assertEqual(set([ |
218 |
'Committing to: %s/' % osutils.getcwd(), |
|
219 |
'added subdir', |
|
220 |
'renamed hello.txt => subdir/hello.txt', |
|
221 |
'Committed revision 2.', |
|
222 |
'', |
|
223 |
]), set(err.split('\n'))) |
|
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
224 |
|
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
225 |
def test_verbose_commit_with_unknown(self): |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
226 |
"""Unknown files should not be listed by default in verbose output"""
|
227 |
# Is that really the best policy?
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
228 |
wt = ControlDir.create_standalone_workingtree('.') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
229 |
self.build_tree(['hello.txt', 'extra.txt']) |
1669.2.1
by Martin Pool
verbose commit now specifically identifies modified/renamed/reparented files |
230 |
wt.add(['hello.txt']) |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
231 |
out,err = self.run_bzr('commit -m added') |
1616.1.3
by Martin Pool
Clean up cut&pasted test for verbose commit |
232 |
self.assertEqual('', out) |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
233 |
self.assertContainsRe(err, '^Committing to: .*\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
234 |
'added hello\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
235 |
'Committed revision 1\.\n$') |
2789.2.1
by Ian Clatworthy
Make commit less verbose by default |
236 |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
237 |
def test_verbose_commit_with_unchanged(self): |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
238 |
"""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. |
239 |
tree = self.make_branch_and_tree('.') |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
240 |
self.build_tree(['hello.txt', 'unchanged.txt']) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
241 |
tree.add('unchanged.txt') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
242 |
self.run_bzr('commit -m unchanged unchanged.txt') |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
243 |
tree.add("hello.txt") |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
244 |
out,err = self.run_bzr('commit -m added') |
1616.1.4
by Martin Pool
Verbose commit shouldn't talk about every unchanged file. |
245 |
self.assertEqual('', out) |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
246 |
self.assertContainsRe(err, '^Committing to: .*\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
247 |
'added hello\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
248 |
'Committed revision 2\.$\n') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
249 |
|
2747.6.13
by Daniel Watkins
Renamed test to reflect what it is actually doing. |
250 |
def test_verbose_commit_includes_master_location(self): |
2747.6.4
by Daniel Watkins
Modified test as suggested on-list. |
251 |
"""Location of master is displayed when committing to bound branch"""
|
2747.6.2
by Daniel Watkins
Added test for behaviour. |
252 |
a_tree = self.make_branch_and_tree('a') |
253 |
self.build_tree(['a/b']) |
|
254 |
a_tree.add('b') |
|
255 |
a_tree.commit(message='Initial message') |
|
256 |
||
257 |
b_tree = a_tree.branch.create_checkout('b') |
|
2804.4.1
by Alexander Belchenko
some win32-specific fixes for selftest |
258 |
expected = "%s/" % (osutils.abspath('a'), ) |
2747.6.4
by Daniel Watkins
Modified test as suggested on-list. |
259 |
out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b') |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
260 |
self.assertEqual(err, 'Committing to: %s\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
261 |
'Committed revision 2.\n' % expected) |
2747.6.2
by Daniel Watkins
Added test for behaviour. |
262 |
|
4634.94.4
by John Arbash Meinel
Fix bug #433779, sanitize '\r' characters in commit. |
263 |
def test_commit_sanitizes_CR_in_message(self): |
264 |
# See bug #433779, basically Emacs likes to pass '\r\n' style line
|
|
265 |
# endings to 'bzr commit -m ""' which breaks because we don't allow
|
|
266 |
# '\r' in commit messages. (Mostly because of issues where XML style
|
|
267 |
# formats arbitrarily strip it out of the data while parsing.)
|
|
268 |
# To make life easier for users, we just always translate '\r\n' =>
|
|
269 |
# '\n'. And '\r' => '\n'.
|
|
270 |
a_tree = self.make_branch_and_tree('a') |
|
271 |
self.build_tree(['a/b']) |
|
272 |
a_tree.add('b') |
|
273 |
self.run_bzr(['commit', |
|
274 |
'-m', 'a string\r\n\r\nwith mixed\r\rendings\n'], |
|
275 |
working_dir='a') |
|
276 |
rev_id = a_tree.branch.last_revision() |
|
277 |
rev = a_tree.branch.repository.get_revision(rev_id) |
|
278 |
self.assertEqualDiff('a string\n\nwith mixed\n\nendings\n', |
|
279 |
rev.message) |
|
280 |
||
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
281 |
def test_commit_merge_reports_all_modified_files(self): |
282 |
# the commit command should show all the files that are shown by
|
|
283 |
# bzr diff or bzr status when committing, even when they were not
|
|
284 |
# changed by the user but rather through doing a merge.
|
|
285 |
this_tree = self.make_branch_and_tree('this') |
|
286 |
# we need a bunch of files and dirs, to perform one action on each.
|
|
287 |
self.build_tree([ |
|
288 |
'this/dirtorename/', |
|
289 |
'this/dirtoreparent/', |
|
290 |
'this/dirtoleave/', |
|
291 |
'this/dirtoremove/', |
|
292 |
'this/filetoreparent', |
|
293 |
'this/filetorename', |
|
294 |
'this/filetomodify', |
|
295 |
'this/filetoremove', |
|
296 |
'this/filetoleave'] |
|
297 |
)
|
|
298 |
this_tree.add([ |
|
299 |
'dirtorename', |
|
300 |
'dirtoreparent', |
|
301 |
'dirtoleave', |
|
302 |
'dirtoremove', |
|
303 |
'filetoreparent', |
|
304 |
'filetorename', |
|
305 |
'filetomodify', |
|
306 |
'filetoremove', |
|
307 |
'filetoleave'] |
|
308 |
)
|
|
309 |
this_tree.commit('create_files') |
|
310 |
other_dir = this_tree.bzrdir.sprout('other') |
|
311 |
other_tree = other_dir.open_workingtree() |
|
312 |
other_tree.lock_write() |
|
313 |
# perform the needed actions on the files and dirs.
|
|
314 |
try: |
|
315 |
other_tree.rename_one('dirtorename', 'renameddir') |
|
316 |
other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir') |
|
317 |
other_tree.rename_one('filetorename', 'renamedfile') |
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
318 |
other_tree.rename_one('filetoreparent', |
319 |
'renameddir/reparentedfile') |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
320 |
other_tree.remove(['dirtoremove', 'filetoremove']) |
321 |
self.build_tree_contents([ |
|
2738.4.5
by Daniel Watkins
Fixed whitespace issues. |
322 |
('other/newdir/',), |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
323 |
('other/filetomodify', 'new content'), |
324 |
('other/newfile', 'new file content')]) |
|
325 |
other_tree.add('newfile') |
|
326 |
other_tree.add('newdir/') |
|
327 |
other_tree.commit('modify all sample files and dirs.') |
|
328 |
finally: |
|
329 |
other_tree.unlock() |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
330 |
this_tree.merge_from_branch(other_tree.branch) |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
331 |
out, err = self.run_bzr('commit -m added', working_dir='this') |
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
332 |
self.assertEqual('', out) |
4183.5.5
by Robert Collins
Enable record_iter_changes for cases where it can work. |
333 |
self.assertEqual(set([ |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
334 |
'Committing to: %s/' % osutils.pathjoin(osutils.getcwd(), 'this'), |
4183.5.5
by Robert Collins
Enable record_iter_changes for cases where it can work. |
335 |
'modified filetomodify', |
336 |
'added newdir', |
|
337 |
'added newfile', |
|
338 |
'renamed dirtorename => renameddir', |
|
339 |
'renamed filetorename => renamedfile', |
|
340 |
'renamed dirtoreparent => renameddir/reparenteddir', |
|
341 |
'renamed filetoreparent => renameddir/reparentedfile', |
|
342 |
'deleted dirtoremove', |
|
343 |
'deleted filetoremove', |
|
344 |
'Committed revision 2.', |
|
345 |
''
|
|
346 |
]), set(err.split('\n'))) |
|
1668.1.5
by Martin Pool
[broken] fix up display of files changed by a commit |
347 |
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
348 |
def test_empty_commit_message(self): |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
349 |
tree = self.make_branch_and_tree('.') |
350 |
self.build_tree_contents([('foo.c', 'int main() {}')]) |
|
351 |
tree.add('foo.c') |
|
6064.1.1
by Jelmer Vernooij
Allow committing with an explicit empty commit message. |
352 |
self.run_bzr('commit -m ""') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
353 |
|
354 |
def test_other_branch_commit(self): |
|
355 |
# this branch is to ensure consistent behaviour, whether we're run
|
|
356 |
# inside a branch, or not.
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
357 |
outer_tree = self.make_branch_and_tree('.') |
358 |
inner_tree = self.make_branch_and_tree('branch') |
|
359 |
self.build_tree_contents([ |
|
360 |
('branch/foo.c', 'int main() {}'), |
|
361 |
('branch/bar.c', 'int main() {}')]) |
|
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
362 |
inner_tree.add(['foo.c', 'bar.c']) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
363 |
# 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 |
364 |
self.run_bzr('commit -m newstuff branch/foo.c .', retcode=3) |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
365 |
# can commit to branch - records foo.c only
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
366 |
self.run_bzr('commit -m newstuff branch/foo.c') |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
367 |
# can commit to branch - records bar.c
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
368 |
self.run_bzr('commit -m newstuff branch') |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
369 |
# No changes left
|
370 |
self.run_bzr_error(["No changes to commit"], 'commit -m newstuff branch') |
|
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
371 |
|
372 |
def test_out_of_date_tree_commit(self): |
|
373 |
# check we get an error code and a clear message committing with an out
|
|
374 |
# of date checkout
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
375 |
tree = self.make_branch_and_tree('branch') |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
376 |
# make a checkout
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
377 |
checkout = tree.branch.create_checkout('checkout', lightweight=True) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
378 |
# 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. |
379 |
tree.commit('message branch', allow_pointless=True) |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
380 |
# now commit to the checkout should emit
|
381 |
# 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 |
382 |
output = self.run_bzr('commit --unchanged -m checkout_message ' |
1508.1.22
by Robert Collins
implement out of date working tree checks in commit. |
383 |
'checkout', retcode=3) |
384 |
self.assertEqual(output, |
|
385 |
('', |
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
386 |
"bzr: ERROR: Working tree is out of date, please "
|
387 |
"run 'bzr update'.\n")) |
|
1587.1.8
by Robert Collins
Local commits on unbound branches fail. |
388 |
|
389 |
def test_local_commit_unbound(self): |
|
390 |
# a --local commit on an unbound branch is an error
|
|
391 |
self.make_branch_and_tree('.') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
392 |
out, err = self.run_bzr('commit --local', retcode=3) |
1587.1.8
by Robert Collins
Local commits on unbound branches fail. |
393 |
self.assertEqualDiff('', out) |
394 |
self.assertEqualDiff('bzr: ERROR: Cannot perform local-only commits ' |
|
395 |
'on unbound branches.\n', err) |
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
396 |
|
397 |
def test_commit_a_text_merge_in_a_checkout(self): |
|
398 |
# checkouts perform multiple actions in a transaction across bond
|
|
399 |
# branches and their master, and have been observed to fail in the
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
400 |
# past. This is a user story reported to fail in bug #43959 where
|
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
401 |
# a merge done in a checkout (using the update command) failed to
|
402 |
# commit correctly.
|
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
403 |
trunk = self.make_branch_and_tree('trunk') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
404 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
405 |
u1 = trunk.branch.create_checkout('u1') |
4985.3.17
by Vincent Ladeuil
Some cleanup. |
406 |
self.build_tree_contents([('u1/hosts', 'initial contents\n')]) |
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
407 |
u1.add('hosts') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
408 |
self.run_bzr('commit -m add-hosts u1') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
409 |
|
2664.13.2
by Daniel Watkins
tests.blackbox.test_commit now uses internals where appropriate. |
410 |
u2 = trunk.branch.create_checkout('u2') |
4985.3.17
by Vincent Ladeuil
Some cleanup. |
411 |
self.build_tree_contents([('u2/hosts', 'altered in u2\n')]) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
412 |
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) |
413 |
|
414 |
# make an offline commits
|
|
4985.3.17
by Vincent Ladeuil
Some cleanup. |
415 |
self.build_tree_contents([('u1/hosts', 'first offline change in u1\n')]) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
416 |
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) |
417 |
|
418 |
# now try to pull in online work from u2, and then commit our offline
|
|
419 |
# work as a merge
|
|
420 |
# retcode 1 as we expect a text conflict
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
421 |
self.run_bzr('update u1', retcode=1) |
4985.3.17
by Vincent Ladeuil
Some cleanup. |
422 |
self.assertFileEqual('''\ |
423 |
<<<<<<< TREE
|
|
424 |
first offline change in u1
|
|
425 |
=======
|
|
426 |
altered in u2
|
|
427 |
>>>>>>> MERGE-SOURCE
|
|
428 |
''', |
|
4985.3.10
by Gerard Krol
Reformat long lines |
429 |
'u1/hosts') |
4985.3.1
by Gerard Krol
Werkt wel ok |
430 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
431 |
self.run_bzr('resolved u1/hosts') |
1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
432 |
# add a text change here to represent resolving the merge conflicts in
|
433 |
# favour of a new version of the file not identical to either the u1
|
|
434 |
# version or the u2 version.
|
|
435 |
self.build_tree_contents([('u1/hosts', 'merge resolution\n')]) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
436 |
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 |
437 |
|
3602.1.1
by Robert Collins
Add support for -x or --exclude to bzr commit, fixing bug 3117. (Robert Collins) |
438 |
def test_commit_exclude_excludes_modified_files(self): |
439 |
"""Commit -x foo should ignore changes to foo."""
|
|
440 |
tree = self.make_branch_and_tree('.') |
|
441 |
self.build_tree(['a', 'b', 'c']) |
|
442 |
tree.smart_add(['.']) |
|
443 |
out, err = self.run_bzr(['commit', '-m', 'test', '-x', 'b']) |
|
444 |
self.assertFalse('added b' in out) |
|
445 |
self.assertFalse('added b' in err) |
|
3602.1.4
by Robert Collins
Andrew's review feedback. |
446 |
# If b was excluded it will still be 'added' in status.
|
3602.1.1
by Robert Collins
Add support for -x or --exclude to bzr commit, fixing bug 3117. (Robert Collins) |
447 |
out, err = self.run_bzr(['added']) |
448 |
self.assertEqual('b\n', out) |
|
449 |
self.assertEqual('', err) |
|
450 |
||
451 |
def test_commit_exclude_twice_uses_both_rules(self): |
|
452 |
"""Commit -x foo -x bar should ignore changes to foo and bar."""
|
|
453 |
tree = self.make_branch_and_tree('.') |
|
454 |
self.build_tree(['a', 'b', 'c']) |
|
455 |
tree.smart_add(['.']) |
|
456 |
out, err = self.run_bzr(['commit', '-m', 'test', '-x', 'b', '-x', 'c']) |
|
457 |
self.assertFalse('added b' in out) |
|
458 |
self.assertFalse('added c' in out) |
|
459 |
self.assertFalse('added b' in err) |
|
460 |
self.assertFalse('added c' in err) |
|
3602.1.4
by Robert Collins
Andrew's review feedback. |
461 |
# If b was excluded it will still be 'added' in status.
|
3602.1.1
by Robert Collins
Add support for -x or --exclude to bzr commit, fixing bug 3117. (Robert Collins) |
462 |
out, err = self.run_bzr(['added']) |
3602.1.4
by Robert Collins
Andrew's review feedback. |
463 |
self.assertTrue('b\n' in out) |
464 |
self.assertTrue('c\n' in out) |
|
3602.1.1
by Robert Collins
Add support for -x or --exclude to bzr commit, fixing bug 3117. (Robert Collins) |
465 |
self.assertEqual('', err) |
466 |
||
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
467 |
def test_commit_respects_spec_for_removals(self): |
468 |
"""Commit with a file spec should only commit removals that match"""
|
|
469 |
t = self.make_branch_and_tree('.') |
|
470 |
self.build_tree(['file-a', 'dir-a/', 'dir-a/file-b']) |
|
471 |
t.add(['file-a', 'dir-a', 'dir-a/file-b']) |
|
472 |
t.commit('Create') |
|
473 |
t.remove(['file-a', 'dir-a/file-b']) |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
474 |
result = self.run_bzr('commit . -m removed-file-b', |
475 |
working_dir='dir-a')[1] |
|
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
476 |
self.assertNotContainsRe(result, 'file-a') |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
477 |
result = self.run_bzr('status', working_dir='dir-a')[0] |
1551.7.24
by Aaron Bentley
Ensure commit respects file spec when committing removals |
478 |
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 |
479 |
|
480 |
def test_strict_commit(self): |
|
481 |
"""Commit with --strict works if everything is known"""
|
|
1551.9.5
by Aaron Bentley
Revert broken save-commit-message code |
482 |
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 |
483 |
tree = self.make_branch_and_tree('tree') |
484 |
self.build_tree(['tree/a']) |
|
485 |
tree.add('a') |
|
486 |
# A simple change should just work
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
487 |
self.run_bzr('commit --strict -m adding-a', working_dir='tree') |
2116.2.1
by John Arbash Meinel
Add commit --strict tests, and add a default ignore so that commit --strict works again |
488 |
|
489 |
def test_strict_commit_no_changes(self): |
|
490 |
"""commit --strict gives "no changes" if there is nothing to commit"""
|
|
491 |
tree = self.make_branch_and_tree('tree') |
|
492 |
self.build_tree(['tree/a']) |
|
493 |
tree.add('a') |
|
494 |
tree.commit('adding a') |
|
495 |
||
496 |
# With no changes, it should just be 'no changes'
|
|
497 |
# Make sure that commit is failing because there is nothing to do
|
|
4351.1.2
by Ian Clatworthy
tweak grammar in error message |
498 |
self.run_bzr_error(['No changes to commit'], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
499 |
'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 |
500 |
working_dir='tree') |
501 |
||
502 |
# But --strict doesn't care if you supply --unchanged
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
503 |
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 |
504 |
working_dir='tree') |
505 |
||
506 |
def test_strict_commit_unknown(self): |
|
507 |
"""commit --strict fails if a file is unknown"""
|
|
508 |
tree = self.make_branch_and_tree('tree') |
|
509 |
self.build_tree(['tree/a']) |
|
510 |
tree.add('a') |
|
511 |
tree.commit('adding a') |
|
512 |
||
513 |
# Add one file so there is a change, but forget the other
|
|
514 |
self.build_tree(['tree/b', 'tree/c']) |
|
515 |
tree.add('b') |
|
516 |
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. |
517 |
'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 |
518 |
working_dir='tree') |
519 |
||
520 |
# --no-strict overrides --strict
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
521 |
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 |
522 |
working_dir='tree') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
523 |
|
524 |
def test_fixes_bug_output(self): |
|
525 |
"""commit --fixes=lp:23452 succeeds without output."""
|
|
2376.4.22
by Jonathan Lange
Variety of whitespace cleanups, tightening of tests and docstring changes in |
526 |
tree = self.make_branch_and_tree('tree') |
527 |
self.build_tree(['tree/hello.txt']) |
|
528 |
tree.add('hello.txt') |
|
2376.4.12
by Jonathan Lange
Update NEWS file. |
529 |
output, err = self.run_bzr( |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
530 |
'commit -m hello --fixes=lp:23452 tree/hello.txt') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
531 |
self.assertEqual('', output) |
3052.4.1
by Matt Nordhoff
bzr commit: don't print the revision number twice. (Bug #172612) |
532 |
self.assertContainsRe(err, 'Committing to: .*\n' |
2747.6.7
by Daniel Watkins
Modify tests to reflect change in commit output. |
533 |
'added hello\.txt\n' |
2789.2.11
by Ian Clatworthy
remove more reporting stuff |
534 |
'Committed revision 1\.\n') |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
535 |
|
2453.2.1
by Martin Pool
Don't set the bugs property unless bugs are actually set |
536 |
def test_no_bugs_no_properties(self): |
537 |
"""If no bugs are fixed, the bugs property is not set.
|
|
538 |
||
539 |
see https://beta.launchpad.net/bzr/+bug/109613
|
|
540 |
"""
|
|
541 |
tree = self.make_branch_and_tree('tree') |
|
542 |
self.build_tree(['tree/hello.txt']) |
|
543 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
544 |
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 |
545 |
# Get the revision properties, ignoring the branch-nick property, which
|
546 |
# we don't care about for this test.
|
|
547 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
548 |
properties = dict(last_rev.properties) |
|
549 |
del properties['branch-nick'] |
|
550 |
self.assertFalse('bugs' in properties) |
|
551 |
||
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
552 |
def test_fixes_bug_sets_property(self): |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
553 |
"""commit --fixes=lp:234 sets the lp:234 revprop to 'fixed'."""
|
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
554 |
tree = self.make_branch_and_tree('tree') |
555 |
self.build_tree(['tree/hello.txt']) |
|
556 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
557 |
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. |
558 |
|
559 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
560 |
# we don't care about for this test.
|
|
561 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
562 |
properties = dict(last_rev.properties) |
|
563 |
del properties['branch-nick'] |
|
564 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
565 |
self.assertEqual({'bugs': 'https://launchpad.net/bugs/234 fixed'}, |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
566 |
properties) |
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
567 |
|
568 |
def test_fixes_multiple_bugs_sets_properties(self): |
|
569 |
"""--fixes can be used more than once to show that bugs are fixed."""
|
|
570 |
tree = self.make_branch_and_tree('tree') |
|
571 |
self.build_tree(['tree/hello.txt']) |
|
572 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
573 |
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=lp:235' |
574 |
' tree/hello.txt') |
|
2376.4.1
by jml at canonical
Blackbox-driven --fixes option to commit. |
575 |
|
576 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
577 |
# we don't care about for this test.
|
|
578 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
579 |
properties = dict(last_rev.properties) |
|
580 |
del properties['branch-nick'] |
|
581 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
582 |
self.assertEqual( |
2376.4.21
by Jonathan Lange
Change the bugs separator to \n from , |
583 |
{'bugs': 'https://launchpad.net/bugs/123 fixed\n' |
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
584 |
'https://launchpad.net/bugs/235 fixed'}, |
585 |
properties) |
|
2376.4.7
by jml at canonical
- Add docstrings to tests. |
586 |
|
587 |
def test_fixes_bug_with_alternate_trackers(self): |
|
588 |
"""--fixes can be used on a properly configured branch to mark bug
|
|
589 |
fixes on multiple trackers.
|
|
590 |
"""
|
|
591 |
tree = self.make_branch_and_tree('tree') |
|
592 |
tree.branch.get_config().set_user_option( |
|
593 |
'trac_twisted_url', 'http://twistedmatrix.com/trac') |
|
594 |
self.build_tree(['tree/hello.txt']) |
|
595 |
tree.add('hello.txt') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
596 |
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=twisted:235 tree/') |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
597 |
|
598 |
# Get the revision properties, ignoring the branch-nick property, which
|
|
599 |
# we don't care about for this test.
|
|
600 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
601 |
properties = dict(last_rev.properties) |
|
602 |
del properties['branch-nick'] |
|
603 |
||
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
604 |
self.assertEqual( |
2376.4.21
by Jonathan Lange
Change the bugs separator to \n from , |
605 |
{'bugs': 'https://launchpad.net/bugs/123 fixed\n' |
2376.4.18
by Jonathan Lange
Store all bug fix URLs in a single property. |
606 |
'http://twistedmatrix.com/trac/ticket/235 fixed'}, |
607 |
properties) |
|
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
608 |
|
609 |
def test_fixes_unknown_bug_prefix(self): |
|
610 |
tree = self.make_branch_and_tree('tree') |
|
611 |
self.build_tree(['tree/hello.txt']) |
|
612 |
tree.add('hello.txt') |
|
613 |
self.run_bzr_error( |
|
614 |
["Unrecognized bug %s. Commit refused." % 'xxx:123'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
615 |
'commit -m add-b --fixes=xxx:123', |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
616 |
working_dir='tree') |
617 |
||
6120.1.1
by Jelmer Vernooij
Support a default bug tracker. |
618 |
def test_fixes_bug_with_default_tracker(self): |
619 |
"""commit --fixes=234 uses the default bug tracker."""
|
|
620 |
tree = self.make_branch_and_tree('tree') |
|
621 |
self.build_tree(['tree/hello.txt']) |
|
622 |
tree.add('hello.txt') |
|
623 |
self.run_bzr_error( |
|
624 |
["bzr: ERROR: No tracker specified for bug 123. Use the form " |
|
625 |
"'tracker:id' or specify a default bug tracker using the "
|
|
6120.1.2
by Jelmer Vernooij
Doc doc doc. |
626 |
"`bugtracker` option.\n" |
6120.1.1
by Jelmer Vernooij
Support a default bug tracker. |
627 |
"See \"bzr help bugs\" for more information on this feature. " |
628 |
"Commit refused."], |
|
629 |
'commit -m add-b --fixes=123', |
|
630 |
working_dir='tree') |
|
6463.1.1
by Jelmer Vernooij
Migrate 'bugtracker' setting to config stacks. |
631 |
tree.branch.get_config_stack().set("bugtracker", "lp") |
6120.1.1
by Jelmer Vernooij
Support a default bug tracker. |
632 |
self.run_bzr('commit -m hello --fixes=234 tree/hello.txt') |
633 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
6120.1.3
by Jelmer Vernooij
Review feedback from vila |
634 |
self.assertEqual('https://launchpad.net/bugs/234 fixed', |
635 |
last_rev.properties['bugs']) |
|
6120.1.1
by Jelmer Vernooij
Support a default bug tracker. |
636 |
|
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
637 |
def test_fixes_invalid_bug_number(self): |
638 |
tree = self.make_branch_and_tree('tree') |
|
639 |
self.build_tree(['tree/hello.txt']) |
|
640 |
tree.add('hello.txt') |
|
641 |
self.run_bzr_error( |
|
3535.10.9
by James Westby
Make the improved messages show up in the UI. |
642 |
["Did not understand bug identifier orange: Must be an integer. " |
643 |
"See \"bzr help bugs\" for more information on this feature.\n" |
|
644 |
"Commit refused."], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
645 |
'commit -m add-b --fixes=lp:orange', |
2376.4.2
by jml at canonical
More sophisticated error handling for --fixes option |
646 |
working_dir='tree') |
2376.4.7
by jml at canonical
- Add docstrings to tests. |
647 |
|
648 |
def test_fixes_invalid_argument(self): |
|
649 |
"""Raise an appropriate error when the fixes argument isn't tag:id."""
|
|
650 |
tree = self.make_branch_and_tree('tree') |
|
651 |
self.build_tree(['tree/hello.txt']) |
|
652 |
tree.add('hello.txt') |
|
653 |
self.run_bzr_error( |
|
6120.1.1
by Jelmer Vernooij
Support a default bug tracker. |
654 |
[r"Invalid bug orange:apples:bananas. Must be in the form of " |
655 |
r"'tracker:id'\. See \"bzr help bugs\" for more information on " |
|
656 |
r"this feature.\nCommit refused\."], |
|
657 |
'commit -m add-b --fixes=orange:apples:bananas', |
|
2376.4.7
by jml at canonical
- Add docstrings to tests. |
658 |
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. |
659 |
|
660 |
def test_no_author(self): |
|
661 |
"""If the author is not specified, the author property is not set."""
|
|
662 |
tree = self.make_branch_and_tree('tree') |
|
663 |
self.build_tree(['tree/hello.txt']) |
|
664 |
tree.add('hello.txt') |
|
665 |
self.run_bzr( 'commit -m hello tree/hello.txt') |
|
666 |
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. |
667 |
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. |
668 |
self.assertFalse('author' in properties) |
669 |
||
670 |
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. |
671 |
"""commit --author='John Doe <jdoe@example.com>' sets the author
|
672 |
revprop.
|
|
673 |
"""
|
|
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. |
674 |
tree = self.make_branch_and_tree('tree') |
675 |
self.build_tree(['tree/hello.txt']) |
|
676 |
tree.add('hello.txt') |
|
3099.2.1
by John Arbash Meinel
Allow 'bzr commit --author' to take a unicode string. |
677 |
self.run_bzr(["commit", '-m', 'hello', |
678 |
'--author', u'John D\xf6 <jdoe@example.com>', |
|
679 |
"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. |
680 |
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. |
681 |
properties = last_rev.properties |
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
682 |
self.assertEqual(u'John D\xf6 <jdoe@example.com>', properties['authors']) |
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. |
683 |
|
684 |
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. |
685 |
"""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. |
686 |
tree = self.make_branch_and_tree('tree') |
687 |
self.build_tree(['tree/hello.txt']) |
|
688 |
tree.add('hello.txt') |
|
2671.2.4
by Lukáš Lalinský
Fixed broken test_author_* blackbox tests. |
689 |
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. |
690 |
"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. |
691 |
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. |
692 |
properties = last_rev.properties |
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
693 |
self.assertEqual('John Doe', properties['authors']) |
2833.2.1
by Alexander Belchenko
XFAIL test for bug #140419 |
694 |
|
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
695 |
def test_multiple_authors(self): |
696 |
"""Multiple authors can be specyfied, and all are stored."""
|
|
697 |
tree = self.make_branch_and_tree('tree') |
|
698 |
self.build_tree(['tree/hello.txt']) |
|
699 |
tree.add('hello.txt') |
|
700 |
out, err = self.run_bzr("commit -m hello --author='John Doe' " |
|
701 |
"--author='Jane Rey' tree/hello.txt") |
|
702 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
703 |
properties = last_rev.properties |
|
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
704 |
self.assertEqual('John Doe\nJane Rey', properties['authors']) |
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
705 |
|
4766.2.2
by Andrew Bennetts
Add tests, and capture timezone offset as well as timestamp. |
706 |
def test_commit_time(self): |
707 |
tree = self.make_branch_and_tree('tree') |
|
708 |
self.build_tree(['tree/hello.txt']) |
|
709 |
tree.add('hello.txt') |
|
710 |
out, err = self.run_bzr("commit -m hello " |
|
711 |
"--commit-time='2009-10-10 08:00:00 +0100' tree/hello.txt") |
|
712 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
713 |
self.assertEqual( |
|
714 |
'Sat 2009-10-10 08:00:00 +0100', |
|
715 |
osutils.format_date(last_rev.timestamp, last_rev.timezone)) |
|
716 |
||
717 |
def test_commit_time_bad_time(self): |
|
718 |
tree = self.make_branch_and_tree('tree') |
|
719 |
self.build_tree(['tree/hello.txt']) |
|
720 |
tree.add('hello.txt') |
|
721 |
out, err = self.run_bzr("commit -m hello " |
|
722 |
"--commit-time='NOT A TIME' tree/hello.txt", retcode=3) |
|
723 |
self.assertStartsWith( |
|
724 |
err, "bzr: ERROR: Could not parse --commit-time:") |
|
725 |
||
6280.2.1
by Matt Giuca
bzrlib.timestamp: More robust handling of time stamp string. (LP: #892657) |
726 |
def test_commit_time_missing_tz(self): |
727 |
tree = self.make_branch_and_tree('tree') |
|
728 |
self.build_tree(['tree/hello.txt']) |
|
729 |
tree.add('hello.txt') |
|
730 |
out, err = self.run_bzr("commit -m hello " |
|
731 |
"--commit-time='2009-10-10 08:00:00' tree/hello.txt", retcode=3) |
|
732 |
self.assertStartsWith( |
|
733 |
err, "bzr: ERROR: Could not parse --commit-time:") |
|
734 |
# Test that it is actually checking and does not simply crash with
|
|
735 |
# some other exception
|
|
6280.2.3
by Matt Giuca
bzrlib.timestamp: Better error message if the string is missing a timezone offset. |
736 |
self.assertContainsString(err, "missing a timezone offset") |
6280.2.1
by Matt Giuca
bzrlib.timestamp: More robust handling of time stamp string. (LP: #892657) |
737 |
|
2833.2.1
by Alexander Belchenko
XFAIL test for bug #140419 |
738 |
def test_partial_commit_with_renames_in_tree(self): |
2833.2.2
by Alexander Belchenko
Bug #140419 fixed by Robert Collins |
739 |
# this test illustrates bug #140419
|
2833.2.1
by Alexander Belchenko
XFAIL test for bug #140419 |
740 |
t = self.make_branch_and_tree('.') |
741 |
self.build_tree(['dir/', 'dir/a', 'test']) |
|
742 |
t.add(['dir/', 'dir/a', 'test']) |
|
743 |
t.commit('initial commit') |
|
744 |
# important part: file dir/a should change parent
|
|
745 |
# and should appear before old parent
|
|
746 |
# then during partial commit we have error
|
|
747 |
# parent_id {dir-XXX} not in inventory
|
|
748 |
t.rename_one('dir/a', 'a') |
|
749 |
self.build_tree_contents([('test', 'changes in test')]) |
|
2833.2.2
by Alexander Belchenko
Bug #140419 fixed by Robert Collins |
750 |
# partial commit
|
751 |
out, err = self.run_bzr('commit test -m "partial commit"') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
752 |
self.assertEqual('', out) |
2833.2.2
by Alexander Belchenko
Bug #140419 fixed by Robert Collins |
753 |
self.assertContainsRe(err, r'modified test\nCommitted revision 2.') |
2872.5.1
by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701). |
754 |
|
755 |
def test_commit_readonly_checkout(self): |
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
756 |
# https://bugs.launchpad.net/bzr/+bug/129701
|
2872.5.1
by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701). |
757 |
# "UnlockableTransport error trying to commit in checkout of readonly
|
758 |
# branch"
|
|
759 |
self.make_branch('master') |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
760 |
master = ControlDir.open_from_transport( |
2872.5.1
by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701). |
761 |
self.get_readonly_transport('master')).open_branch() |
762 |
master.create_checkout('checkout') |
|
763 |
out, err = self.run_bzr(['commit', '--unchanged', '-mfoo', 'checkout'], |
|
764 |
retcode=3) |
|
765 |
self.assertContainsRe(err, |
|
2872.5.3
by Martin Pool
Pass back LockFailed from smart server lock methods |
766 |
r'^bzr: ERROR: Cannot lock.*readonly transport') |
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
767 |
|
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
768 |
def setup_editor(self): |
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
769 |
# Test that commit template hooks work
|
770 |
if sys.platform == "win32": |
|
771 |
f = file('fed.bat', 'w') |
|
772 |
f.write('@rem dummy fed') |
|
773 |
f.close() |
|
5570.3.12
by Vincent Ladeuil
Replace osutils.set_or_unset_env calls with self.overrideEnv. |
774 |
self.overrideEnv('BZR_EDITOR', "fed.bat") |
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
775 |
else: |
776 |
f = file('fed.sh', 'wb') |
|
777 |
f.write('#!/bin/sh\n') |
|
778 |
f.close() |
|
779 |
os.chmod('fed.sh', 0755) |
|
5570.3.12
by Vincent Ladeuil
Replace osutils.set_or_unset_env calls with self.overrideEnv. |
780 |
self.overrideEnv('BZR_EDITOR', "./fed.sh") |
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
781 |
|
782 |
def setup_commit_with_template(self): |
|
783 |
self.setup_editor() |
|
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
784 |
msgeditor.hooks.install_named_hook("commit_message_template", |
785 |
lambda commit_obj, msg: "save me some typing\n", None) |
|
786 |
tree = self.make_branch_and_tree('tree') |
|
787 |
self.build_tree(['tree/hello.txt']) |
|
788 |
tree.add('hello.txt') |
|
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
789 |
return tree |
790 |
||
6064.1.1
by Jelmer Vernooij
Allow committing with an explicit empty commit message. |
791 |
def test_edit_empty_message(self): |
792 |
tree = self.make_branch_and_tree('tree') |
|
793 |
self.setup_editor() |
|
794 |
self.build_tree(['tree/hello.txt']) |
|
795 |
tree.add('hello.txt') |
|
796 |
out, err = self.run_bzr("commit tree/hello.txt", retcode=3, |
|
797 |
stdin="y\n") |
|
798 |
self.assertContainsRe(err, |
|
6064.1.4
by Jelmer Vernooij
Fix capitalization. |
799 |
"bzr: ERROR: Empty commit message specified") |
6064.1.1
by Jelmer Vernooij
Allow committing with an explicit empty commit message. |
800 |
|
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
801 |
def test_commit_hook_template_accepted(self): |
802 |
tree = self.setup_commit_with_template() |
|
5137.1.1
by Robert Collins
* ``bzr commit`` will prompt before using a commit message that was |
803 |
out, err = self.run_bzr("commit tree/hello.txt", stdin="y\n") |
3825.2.2
by Jelmer Vernooij
Add blackbox test for commit hook templates. |
804 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
805 |
self.assertEqual('save me some typing\n', last_rev.message) |
|
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
806 |
|
807 |
def test_commit_hook_template_rejected(self): |
|
808 |
tree = self.setup_commit_with_template() |
|
809 |
expected = tree.last_revision() |
|
6045.1.6
by paulbrianstewart at gmail
Added punctuation to the commit message |
810 |
out, err = self.run_bzr_error(["Empty commit message specified." |
6045.1.1
by Paul Stewart
Changed the empty commit message to ask the user either enter a commit message or use --message ' ' to leave a blank commit message |
811 |
" Please specify a commit message with either"
|
812 |
" --message or --file or leave a blank message"
|
|
6045.1.6
by paulbrianstewart at gmail
Added punctuation to the commit message |
813 |
" with --message \"\"."], |
5137.1.2
by Robert Collins
Review feedback: add comment about return value and an additional test. |
814 |
"commit tree/hello.txt", stdin="n\n") |
815 |
self.assertEqual(expected, tree.last_revision()) |
|
5187.2.4
by Parth Malwankar
added tests. |
816 |
|
5912.4.10
by Jonathan Riddell
add test for set_commit_message hook |
817 |
def test_set_commit_message(self): |
818 |
msgeditor.hooks.install_named_hook("set_commit_message", |
|
819 |
lambda commit_obj, msg: "save me some typing\n", None) |
|
820 |
tree = self.make_branch_and_tree('tree') |
|
821 |
self.build_tree(['tree/hello.txt']) |
|
822 |
tree.add('hello.txt') |
|
823 |
out, err = self.run_bzr("commit tree/hello.txt") |
|
824 |
last_rev = tree.branch.repository.get_revision(tree.last_revision()) |
|
825 |
self.assertEqual('save me some typing\n', last_rev.message) |
|
826 |
||
5187.2.4
by Parth Malwankar
added tests. |
827 |
def test_commit_without_username(self): |
828 |
"""Ensure commit error if username is not set.
|
|
829 |
"""
|
|
830 |
self.run_bzr(['init', 'foo']) |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
831 |
with open('foo/foo.txt', 'w') as f: |
832 |
f.write('hello') |
|
833 |
self.run_bzr(['add'], working_dir='foo') |
|
5570.3.12
by Vincent Ladeuil
Replace osutils.set_or_unset_env calls with self.overrideEnv. |
834 |
self.overrideEnv('EMAIL', None) |
835 |
self.overrideEnv('BZR_EMAIL', None) |
|
5609.31.1
by mbp at sourcefrog
Blackbox tests for no identity set must disable whoami inference |
836 |
# Also, make sure that it's not inferred from mailname.
|
837 |
self.overrideAttr(config, '_auto_user_id', |
|
838 |
lambda: (None, None)) |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
839 |
self.run_bzr_error( |
840 |
['Unable to determine your name'], |
|
841 |
['commit', '-m', 'initial'], working_dir='foo') |
|
5050.7.1
by Parth Malwankar
added test case for recursion error |
842 |
|
843 |
def test_commit_recursive_checkout(self): |
|
844 |
"""Ensure that a commit to a recursive checkout fails cleanly.
|
|
845 |
"""
|
|
846 |
self.run_bzr(['init', 'test_branch']) |
|
847 |
self.run_bzr(['checkout', 'test_branch', 'test_checkout']) |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
848 |
self.run_bzr(['bind', '.'], working_dir='test_checkout') # bind to self |
849 |
with open('test_checkout/foo.txt', 'w') as f: |
|
850 |
f.write('hello') |
|
851 |
self.run_bzr(['add'], working_dir='test_checkout') |
|
852 |
out, err = self.run_bzr_error( |
|
853 |
['Branch.*test_checkout.*appears to be bound to itself'], |
|
854 |
['commit', '-m', 'addedfoo'], working_dir='test_checkout') |
|
6323.2.2
by Jelmer Vernooij
Add hpss call count for committing to a lightweight checkout. |
855 |
|
6379.9.1
by Rory Yorke
Added test case to reproduce error (test_mv_dirs_non_ascii). |
856 |
def test_mv_dirs_non_ascii(self): |
857 |
"""Move directory with non-ascii name and containing files.
|
|
6379.9.4
by Rory Yorke
Code fixes following review. |
858 |
|
6379.9.1
by Rory Yorke
Added test case to reproduce error (test_mv_dirs_non_ascii). |
859 |
Regression test for bug 185211.
|
860 |
"""
|
|
861 |
tree = self.make_branch_and_tree('.') |
|
6426.5.1
by Martin Packman
Use a non-ascii character in test for bug 185211 that is the same in NFC and NFD |
862 |
self.build_tree([u'abc\xa7/', u'abc\xa7/foo']) |
6379.9.1
by Rory Yorke
Added test case to reproduce error (test_mv_dirs_non_ascii). |
863 |
|
6426.5.1
by Martin Packman
Use a non-ascii character in test for bug 185211 that is the same in NFC and NFD |
864 |
tree.add([u'abc\xa7/', u'abc\xa7/foo']) |
6379.9.4
by Rory Yorke
Code fixes following review. |
865 |
tree.commit('checkin') |
6379.9.1
by Rory Yorke
Added test case to reproduce error (test_mv_dirs_non_ascii). |
866 |
|
6426.5.1
by Martin Packman
Use a non-ascii character in test for bug 185211 that is the same in NFC and NFD |
867 |
tree.rename_one(u'abc\xa7','abc') |
6379.9.1
by Rory Yorke
Added test case to reproduce error (test_mv_dirs_non_ascii). |
868 |
|
869 |
self.run_bzr('ci -m "non-ascii mv"') |
|
870 |
||
6323.2.2
by Jelmer Vernooij
Add hpss call count for committing to a lightweight checkout. |
871 |
|
872 |
class TestSmartServerCommit(TestCaseWithTransport): |
|
873 |
||
874 |
def test_commit_to_lightweight(self): |
|
875 |
self.setup_smart_server_with_call_log() |
|
876 |
t = self.make_branch_and_tree('from') |
|
877 |
for count in range(9): |
|
878 |
t.commit(message='commit %d' % count) |
|
879 |
out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'), |
|
880 |
'target']) |
|
881 |
self.reset_smart_call_log() |
|
882 |
self.build_tree(['target/afile']) |
|
883 |
self.run_bzr(['add', 'target/afile']) |
|
884 |
out, err = self.run_bzr(['commit', '-m', 'do something', 'target']) |
|
885 |
# This figure represent the amount of work to perform this use case. It
|
|
886 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
887 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
888 |
# become necessary for this use case. Please do not adjust this number
|
|
889 |
# upwards without agreement from bzr's network support maintainers.
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
890 |
self.assertLength(211, self.hpss_calls) |
6366.1.4
by Jelmer Vernooij
Test connection count calls for most blackbox commands. |
891 |
self.assertLength(2, self.hpss_connections) |
6352.2.2
by Jelmer Vernooij
Use new NoVfsCalls matcher in blackbox tests. |
892 |
self.expectFailure("commit still uses VFS calls", |
6352.2.3
by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/. |
893 |
self.assertThat, self.hpss_calls, ContainsNoVfsCalls) |