/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_commit.py

  • Committer: Keir Mierle
  • Date: 2007-09-04 19:03:51 UTC
  • mto: This revision was merged to the branch mainline in revision 2824.
  • Revision ID: keir@cs.utoronto.ca-20070904190351-ug32zv9dcfqtluvi
Change ordering of clients listing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
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
 
 
22
from bzrlib import (
 
23
    ignores,
 
24
    )
 
25
from bzrlib.bzrdir import BzrDir
 
26
from bzrlib.tests.blackbox import ExternalBase
 
27
 
 
28
 
 
29
class TestCommit(ExternalBase):
 
30
 
 
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.
 
34
        self.make_branch_and_tree('.')
 
35
        self.build_tree(['hello.txt'])
 
36
        out,err = self.run_bzr('commit -m empty', retcode=3)
 
37
        self.assertEqual('', out)
 
38
        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
 
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"""
 
43
        self.make_branch_and_tree('.')
 
44
        self.run_bzr('commit --unchanged -m message')
 
45
        self.assertEqual('', self.run_bzr('unknowns')[0])
 
46
 
 
47
        # same for unicode messages
 
48
        self.run_bzr(["commit", "--unchanged", "-m", u'foo\xb5'])
 
49
        self.assertEqual('', self.run_bzr('unknowns')[0])
 
50
 
 
51
    def test_commit_with_path(self):
 
52
        """Commit tree with path of root specified"""
 
53
        a_tree = self.make_branch_and_tree('a')
 
54
        self.build_tree(['a/a_file'])
 
55
        a_tree.add('a_file')
 
56
        self.run_bzr(['commit', '-m', 'first commit', 'a'])
 
57
 
 
58
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
59
        self.build_tree_contents([('b/a_file', 'changes in b')])
 
60
        self.run_bzr(['commit', '-m', 'first commit in b', 'b'])
 
61
 
 
62
        self.build_tree_contents([('a/a_file', 'new contents')])
 
63
        self.run_bzr(['commit', '-m', 'change in a', 'a'])
 
64
 
 
65
        b_tree.merge_from_branch(a_tree.branch)
 
66
        self.assertEqual(len(b_tree.conflicts()), 1)
 
67
        self.run_bzr('resolved b/a_file')
 
68
        self.run_bzr(['commit', '-m', 'merge into b', 'b'])
 
69
 
 
70
 
 
71
    def test_10_verbose_commit(self):
 
72
        """Add one file and examine verbose commit output"""
 
73
        tree = self.make_branch_and_tree('.')
 
74
        self.build_tree(['hello.txt'])
 
75
        tree.add("hello.txt")
 
76
        out,err = self.run_bzr('commit -m added')
 
77
        self.assertEqual('', out)
 
78
        self.assertEqual('added hello.txt\n'
 
79
                         'Committed revision 1.\n',
 
80
                         err)
 
81
 
 
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')])
 
95
        out, err = self.run_bzr('commit -m modified')
 
96
        self.assertEqual('', out)
 
97
        self.assertEqual('modified hello.txt\n'
 
98
                         'Committed revision 2.\n',
 
99
                         err)
 
100
 
 
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')
 
105
        out, err = self.run_bzr('commit -m renamed')
 
106
        self.assertEqual('', out)
 
107
        self.assertEqual('renamed hello.txt => gutentag.txt\n'
 
108
                         'Committed revision 2.\n',
 
109
                         err)
 
110
 
 
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')
 
117
        out, err = self.run_bzr('commit -m renamed')
 
118
        self.assertEqual('', out)
 
119
        self.assertEqualDiff('added subdir\n'
 
120
                             'renamed hello.txt => subdir/hello.txt\n'
 
121
                             'Committed revision 2.\n',
 
122
                             err)
 
123
 
 
124
    def test_verbose_commit_with_unknown(self):
 
125
        """Unknown files should not be listed by default in verbose output"""
 
126
        # Is that really the best policy?
 
127
        wt = BzrDir.create_standalone_workingtree('.')
 
128
        self.build_tree(['hello.txt', 'extra.txt'])
 
129
        wt.add(['hello.txt'])
 
130
        out,err = self.run_bzr('commit -m added')
 
131
        self.assertEqual('', out)
 
132
        self.assertEqual('added hello.txt\n'
 
133
                         'Committed revision 1.\n',
 
134
                         err)
 
135
 
 
136
    def test_verbose_commit_with_unchanged(self):
 
137
        """Unchanged files should not be listed by default in verbose output"""
 
138
        tree = self.make_branch_and_tree('.')
 
139
        self.build_tree(['hello.txt', 'unchanged.txt'])
 
140
        tree.add('unchanged.txt')
 
141
        self.run_bzr('commit -m unchanged unchanged.txt')
 
142
        tree.add("hello.txt")
 
143
        out,err = self.run_bzr('commit -m added')
 
144
        self.assertEqual('', out)
 
145
        self.assertEqual('added hello.txt\n'
 
146
                         'Committed revision 2.\n',
 
147
                         err)
 
148
 
 
149
    def test_commit_merge_reports_all_modified_files(self):
 
150
        # the commit command should show all the files that are shown by
 
151
        # bzr diff or bzr status when committing, even when they were not
 
152
        # changed by the user but rather through doing a merge.
 
153
        this_tree = self.make_branch_and_tree('this')
 
154
        # we need a bunch of files and dirs, to perform one action on each.
 
155
        self.build_tree([
 
156
            'this/dirtorename/',
 
157
            'this/dirtoreparent/',
 
158
            'this/dirtoleave/',
 
159
            'this/dirtoremove/',
 
160
            'this/filetoreparent',
 
161
            'this/filetorename',
 
162
            'this/filetomodify',
 
163
            'this/filetoremove',
 
164
            'this/filetoleave']
 
165
            )
 
166
        this_tree.add([
 
167
            'dirtorename',
 
168
            'dirtoreparent',
 
169
            'dirtoleave',
 
170
            'dirtoremove',
 
171
            'filetoreparent',
 
172
            'filetorename',
 
173
            'filetomodify',
 
174
            'filetoremove',
 
175
            'filetoleave']
 
176
            )
 
177
        this_tree.commit('create_files')
 
178
        other_dir = this_tree.bzrdir.sprout('other')
 
179
        other_tree = other_dir.open_workingtree()
 
180
        other_tree.lock_write()
 
181
        # perform the needed actions on the files and dirs.
 
182
        try:
 
183
            other_tree.rename_one('dirtorename', 'renameddir')
 
184
            other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir')
 
185
            other_tree.rename_one('filetorename', 'renamedfile')
 
186
            other_tree.rename_one('filetoreparent',
 
187
                                  'renameddir/reparentedfile')
 
188
            other_tree.remove(['dirtoremove', 'filetoremove'])
 
189
            self.build_tree_contents([
 
190
                ('other/newdir/',),
 
191
                ('other/filetomodify', 'new content'),
 
192
                ('other/newfile', 'new file content')])
 
193
            other_tree.add('newfile')
 
194
            other_tree.add('newdir/')
 
195
            other_tree.commit('modify all sample files and dirs.')
 
196
        finally:
 
197
            other_tree.unlock()
 
198
        this_tree.merge_from_branch(other_tree.branch)
 
199
        os.chdir('this')
 
200
        out,err = self.run_bzr('commit -m added')
 
201
        os.chdir('..')
 
202
        self.assertEqual('', out)
 
203
        self.assertEqualDiff(
 
204
            'modified filetomodify\n'
 
205
            'added newdir\n'
 
206
            'added newfile\n'
 
207
            'renamed dirtorename => renameddir\n'
 
208
            'renamed dirtoreparent => renameddir/reparenteddir\n'
 
209
            'renamed filetoreparent => renameddir/reparentedfile\n'
 
210
            'renamed filetorename => renamedfile\n'
 
211
            'deleted dirtoremove\n'
 
212
            'deleted filetoremove\n'
 
213
            'Committed revision 2.\n',
 
214
            err)
 
215
 
 
216
    def test_empty_commit_message(self):
 
217
        tree = self.make_branch_and_tree('.')
 
218
        self.build_tree_contents([('foo.c', 'int main() {}')])
 
219
        tree.add('foo.c')
 
220
        self.run_bzr('commit -m ""', retcode=3)
 
221
 
 
222
    def test_unsupported_encoding_commit_message(self):
 
223
        tree = self.make_branch_and_tree('.')
 
224
        self.build_tree_contents([('foo.c', 'int main() {}')])
 
225
        tree.add('foo.c')
 
226
        out,err = self.run_bzr_subprocess('commit -m "\xff"', retcode=1,
 
227
                                                    env_changes={'LANG': 'C'})
 
228
        self.assertContainsRe(err, r'bzrlib.errors.BzrError: Parameter.*is '
 
229
                                    'unsupported by the current encoding.')
 
230
 
 
231
    def test_other_branch_commit(self):
 
232
        # this branch is to ensure consistent behaviour, whether we're run
 
233
        # inside a branch, or not.
 
234
        outer_tree = self.make_branch_and_tree('.')
 
235
        inner_tree = self.make_branch_and_tree('branch')
 
236
        self.build_tree_contents([
 
237
            ('branch/foo.c', 'int main() {}'),
 
238
            ('branch/bar.c', 'int main() {}')])
 
239
        inner_tree.add('foo.c')
 
240
        inner_tree.add('bar.c')
 
241
        # can't commit files in different trees; sane error
 
242
        self.run_bzr('commit -m newstuff branch/foo.c .', retcode=3)
 
243
        self.run_bzr('commit -m newstuff branch/foo.c')
 
244
        self.run_bzr('commit -m newstuff branch')
 
245
        self.run_bzr('commit -m newstuff branch', retcode=3)
 
246
 
 
247
    def test_out_of_date_tree_commit(self):
 
248
        # check we get an error code and a clear message committing with an out
 
249
        # of date checkout
 
250
        tree = self.make_branch_and_tree('branch')
 
251
        # make a checkout
 
252
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
 
253
        # commit to the original branch to make the checkout out of date
 
254
        tree.commit('message branch', allow_pointless=True)
 
255
        # now commit to the checkout should emit
 
256
        # ERROR: Out of date with the branch, 'bzr update' is suggested
 
257
        output = self.run_bzr('commit --unchanged -m checkout_message '
 
258
                             'checkout', retcode=3)
 
259
        self.assertEqual(output,
 
260
                         ('',
 
261
                          "bzr: ERROR: Working tree is out of date, please "
 
262
                          "run 'bzr update'.\n"))
 
263
 
 
264
    def test_local_commit_unbound(self):
 
265
        # a --local commit on an unbound branch is an error
 
266
        self.make_branch_and_tree('.')
 
267
        out, err = self.run_bzr('commit --local', retcode=3)
 
268
        self.assertEqualDiff('', out)
 
269
        self.assertEqualDiff('bzr: ERROR: Cannot perform local-only commits '
 
270
                             'on unbound branches.\n', err)
 
271
 
 
272
    def test_commit_a_text_merge_in_a_checkout(self):
 
273
        # checkouts perform multiple actions in a transaction across bond
 
274
        # branches and their master, and have been observed to fail in the
 
275
        # past. This is a user story reported to fail in bug #43959 where 
 
276
        # a merge done in a checkout (using the update command) failed to
 
277
        # commit correctly.
 
278
        trunk = self.make_branch_and_tree('trunk')
 
279
 
 
280
        u1 = trunk.branch.create_checkout('u1')
 
281
        self.build_tree_contents([('u1/hosts', 'initial contents')])
 
282
        u1.add('hosts')
 
283
        self.run_bzr('commit -m add-hosts u1')
 
284
 
 
285
        u2 = trunk.branch.create_checkout('u2')
 
286
        self.build_tree_contents([('u2/hosts', 'altered in u2')])
 
287
        self.run_bzr('commit -m checkin-from-u2 u2')
 
288
 
 
289
        # make an offline commits
 
290
        self.build_tree_contents([('u1/hosts', 'first offline change in u1')])
 
291
        self.run_bzr('commit -m checkin-offline --local u1')
 
292
 
 
293
        # now try to pull in online work from u2, and then commit our offline
 
294
        # work as a merge
 
295
        # retcode 1 as we expect a text conflict
 
296
        self.run_bzr('update u1', retcode=1)
 
297
        self.run_bzr('resolved u1/hosts')
 
298
        # add a text change here to represent resolving the merge conflicts in
 
299
        # favour of a new version of the file not identical to either the u1
 
300
        # version or the u2 version.
 
301
        self.build_tree_contents([('u1/hosts', 'merge resolution\n')])
 
302
        self.run_bzr('commit -m checkin-merge-of-the-offline-work-from-u1 u1')
 
303
 
 
304
    def test_commit_respects_spec_for_removals(self):
 
305
        """Commit with a file spec should only commit removals that match"""
 
306
        t = self.make_branch_and_tree('.')
 
307
        self.build_tree(['file-a', 'dir-a/', 'dir-a/file-b'])
 
308
        t.add(['file-a', 'dir-a', 'dir-a/file-b'])
 
309
        t.commit('Create')
 
310
        t.remove(['file-a', 'dir-a/file-b'])
 
311
        os.chdir('dir-a')
 
312
        result = self.run_bzr('commit . -m removed-file-b')[1]
 
313
        self.assertNotContainsRe(result, 'file-a')
 
314
        result = self.run_bzr('status')[0]
 
315
        self.assertContainsRe(result, 'removed:\n  file-a')
 
316
 
 
317
    def test_strict_commit(self):
 
318
        """Commit with --strict works if everything is known"""
 
319
        ignores._set_user_ignores([])
 
320
        tree = self.make_branch_and_tree('tree')
 
321
        self.build_tree(['tree/a'])
 
322
        tree.add('a')
 
323
        # A simple change should just work
 
324
        self.run_bzr('commit --strict -m adding-a',
 
325
                     working_dir='tree')
 
326
 
 
327
    def test_strict_commit_no_changes(self):
 
328
        """commit --strict gives "no changes" if there is nothing to commit"""
 
329
        tree = self.make_branch_and_tree('tree')
 
330
        self.build_tree(['tree/a'])
 
331
        tree.add('a')
 
332
        tree.commit('adding a')
 
333
 
 
334
        # With no changes, it should just be 'no changes'
 
335
        # Make sure that commit is failing because there is nothing to do
 
336
        self.run_bzr_error(['no changes to commit'],
 
337
                           'commit --strict -m no-changes',
 
338
                           working_dir='tree')
 
339
 
 
340
        # But --strict doesn't care if you supply --unchanged
 
341
        self.run_bzr('commit --strict --unchanged -m no-changes',
 
342
                     working_dir='tree')
 
343
 
 
344
    def test_strict_commit_unknown(self):
 
345
        """commit --strict fails if a file is unknown"""
 
346
        tree = self.make_branch_and_tree('tree')
 
347
        self.build_tree(['tree/a'])
 
348
        tree.add('a')
 
349
        tree.commit('adding a')
 
350
 
 
351
        # Add one file so there is a change, but forget the other
 
352
        self.build_tree(['tree/b', 'tree/c'])
 
353
        tree.add('b')
 
354
        self.run_bzr_error(['Commit refused because there are unknown files'],
 
355
                           'commit --strict -m add-b',
 
356
                           working_dir='tree')
 
357
 
 
358
        # --no-strict overrides --strict
 
359
        self.run_bzr('commit --strict -m add-b --no-strict',
 
360
                     working_dir='tree')
 
361
 
 
362
    def test_fixes_bug_output(self):
 
363
        """commit --fixes=lp:23452 succeeds without output."""
 
364
        tree = self.make_branch_and_tree('tree')
 
365
        self.build_tree(['tree/hello.txt'])
 
366
        tree.add('hello.txt')
 
367
        output, err = self.run_bzr(
 
368
            'commit -m hello --fixes=lp:23452 tree/hello.txt')
 
369
        self.assertEqual('', output)
 
370
        self.assertEqual('added hello.txt\nCommitted revision 1.\n', err)
 
371
 
 
372
    def test_no_bugs_no_properties(self):
 
373
        """If no bugs are fixed, the bugs property is not set.
 
374
 
 
375
        see https://beta.launchpad.net/bzr/+bug/109613
 
376
        """
 
377
        tree = self.make_branch_and_tree('tree')
 
378
        self.build_tree(['tree/hello.txt'])
 
379
        tree.add('hello.txt')
 
380
        self.run_bzr( 'commit -m hello tree/hello.txt')
 
381
        # Get the revision properties, ignoring the branch-nick property, which
 
382
        # we don't care about for this test.
 
383
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
384
        properties = dict(last_rev.properties)
 
385
        del properties['branch-nick']
 
386
        self.assertFalse('bugs' in properties)
 
387
 
 
388
    def test_fixes_bug_sets_property(self):
 
389
        """commit --fixes=lp:234 sets the lp:234 revprop to 'fixed'."""
 
390
        tree = self.make_branch_and_tree('tree')
 
391
        self.build_tree(['tree/hello.txt'])
 
392
        tree.add('hello.txt')
 
393
        self.run_bzr('commit -m hello --fixes=lp:234 tree/hello.txt')
 
394
 
 
395
        # Get the revision properties, ignoring the branch-nick property, which
 
396
        # we don't care about for this test.
 
397
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
398
        properties = dict(last_rev.properties)
 
399
        del properties['branch-nick']
 
400
 
 
401
        self.assertEqual({'bugs': 'https://launchpad.net/bugs/234 fixed'},
 
402
                         properties)
 
403
 
 
404
    def test_fixes_multiple_bugs_sets_properties(self):
 
405
        """--fixes can be used more than once to show that bugs are fixed."""
 
406
        tree = self.make_branch_and_tree('tree')
 
407
        self.build_tree(['tree/hello.txt'])
 
408
        tree.add('hello.txt')
 
409
        self.run_bzr('commit -m hello --fixes=lp:123 --fixes=lp:235'
 
410
                     ' tree/hello.txt')
 
411
 
 
412
        # Get the revision properties, ignoring the branch-nick property, which
 
413
        # we don't care about for this test.
 
414
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
415
        properties = dict(last_rev.properties)
 
416
        del properties['branch-nick']
 
417
 
 
418
        self.assertEqual(
 
419
            {'bugs': 'https://launchpad.net/bugs/123 fixed\n'
 
420
                     'https://launchpad.net/bugs/235 fixed'},
 
421
            properties)
 
422
 
 
423
    def test_fixes_bug_with_alternate_trackers(self):
 
424
        """--fixes can be used on a properly configured branch to mark bug
 
425
        fixes on multiple trackers.
 
426
        """
 
427
        tree = self.make_branch_and_tree('tree')
 
428
        tree.branch.get_config().set_user_option(
 
429
            'trac_twisted_url', 'http://twistedmatrix.com/trac')
 
430
        self.build_tree(['tree/hello.txt'])
 
431
        tree.add('hello.txt')
 
432
        self.run_bzr('commit -m hello --fixes=lp:123 --fixes=twisted:235 tree/')
 
433
 
 
434
        # Get the revision properties, ignoring the branch-nick property, which
 
435
        # we don't care about for this test.
 
436
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
437
        properties = dict(last_rev.properties)
 
438
        del properties['branch-nick']
 
439
 
 
440
        self.assertEqual(
 
441
            {'bugs': 'https://launchpad.net/bugs/123 fixed\n'
 
442
                     'http://twistedmatrix.com/trac/ticket/235 fixed'},
 
443
            properties)
 
444
 
 
445
    def test_fixes_unknown_bug_prefix(self):
 
446
        tree = self.make_branch_and_tree('tree')
 
447
        self.build_tree(['tree/hello.txt'])
 
448
        tree.add('hello.txt')
 
449
        self.run_bzr_error(
 
450
            ["Unrecognized bug %s. Commit refused." % 'xxx:123'],
 
451
            'commit -m add-b --fixes=xxx:123',
 
452
            working_dir='tree')
 
453
 
 
454
    def test_fixes_invalid_bug_number(self):
 
455
        tree = self.make_branch_and_tree('tree')
 
456
        self.build_tree(['tree/hello.txt'])
 
457
        tree.add('hello.txt')
 
458
        self.run_bzr_error(
 
459
            ["Invalid bug identifier for %s. Commit refused." % 'lp:orange'],
 
460
            'commit -m add-b --fixes=lp:orange',
 
461
            working_dir='tree')
 
462
 
 
463
    def test_fixes_invalid_argument(self):
 
464
        """Raise an appropriate error when the fixes argument isn't tag:id."""
 
465
        tree = self.make_branch_and_tree('tree')
 
466
        self.build_tree(['tree/hello.txt'])
 
467
        tree.add('hello.txt')
 
468
        self.run_bzr_error(
 
469
            [r"Invalid bug orange. Must be in the form of 'tag:id'\. "
 
470
             r"Commit refused\."],
 
471
            'commit -m add-b --fixes=orange',
 
472
            working_dir='tree')
 
473
 
 
474
    def test_no_author(self):
 
475
        """If the author is not specified, the author property is not set."""
 
476
        tree = self.make_branch_and_tree('tree')
 
477
        self.build_tree(['tree/hello.txt'])
 
478
        tree.add('hello.txt')
 
479
        self.run_bzr( 'commit -m hello tree/hello.txt')
 
480
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
481
        properties = last_rev.properties
 
482
        self.assertFalse('author' in properties)
 
483
 
 
484
    def test_author_sets_property(self):
 
485
        """commit --author='John Doe <jdoe@example.com>' sets the author
 
486
           revprop.
 
487
        """
 
488
        tree = self.make_branch_and_tree('tree')
 
489
        self.build_tree(['tree/hello.txt'])
 
490
        tree.add('hello.txt')
 
491
        self.run_bzr("commit -m hello --author='John Doe <jdoe@example.com>' "
 
492
                     "tree/hello.txt")
 
493
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
494
        properties = last_rev.properties
 
495
        self.assertEqual('John Doe <jdoe@example.com>', properties['author'])
 
496
 
 
497
    def test_author_no_email(self):
 
498
        """Author's name without an email address is allowed, too."""
 
499
        tree = self.make_branch_and_tree('tree')
 
500
        self.build_tree(['tree/hello.txt'])
 
501
        tree.add('hello.txt')
 
502
        out, err = self.run_bzr("commit -m hello --author='John Doe' "
 
503
                                "tree/hello.txt")
 
504
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
505
        properties = last_rev.properties
 
506
        self.assertEqual('John Doe', properties['author'])