89
81
"""Commit and check two versions of a single file."""
90
82
wt = self.make_branch_and_tree('.')
92
with open('hello', 'w') as f:
93
f.write('hello world')
84
file('hello', 'w').write('hello world')
95
rev1 = wt.commit(message='add hello')
97
with open('hello', 'w') as f:
99
rev2 = wt.commit(message='commit 2')
101
eq = self.assertEqual
86
wt.commit(message='add hello')
87
file_id = wt.path2id('hello')
89
file('hello', 'w').write('version 2')
90
wt.commit(message='commit 2')
92
eq = self.assertEquals
103
rev = b.repository.get_revision(rev1)
94
rh = b.revision_history()
95
rev = b.repository.get_revision(rh[0])
104
96
eq(rev.message, 'add hello')
106
tree1 = b.repository.revision_tree(rev1)
98
tree1 = b.repository.revision_tree(rh[0])
108
text = tree1.get_file_text('hello')
100
text = tree1.get_file_text(file_id)
110
self.assertEqual(b'hello world', text)
102
self.assertEqual('hello world', text)
112
tree2 = b.repository.revision_tree(rev2)
104
tree2 = b.repository.revision_tree(rh[1])
113
105
tree2.lock_read()
114
text = tree2.get_file_text('hello')
106
text = tree2.get_file_text(file_id)
116
self.assertEqual(b'version 2', text)
118
def test_commit_lossy_native(self):
119
"""Attempt a lossy commit to a native branch."""
120
wt = self.make_branch_and_tree('.')
122
with open('hello', 'w') as f:
123
f.write('hello world')
125
revid = wt.commit(message='add hello', rev_id=b'revid', lossy=True)
126
self.assertEqual(b'revid', revid)
128
def test_commit_lossy_foreign(self):
129
"""Attempt a lossy commit to a foreign branch."""
130
test_foreign.register_dummy_foreign_for_test(self)
131
wt = self.make_branch_and_tree('.',
132
format=test_foreign.DummyForeignVcsDirFormat())
134
with open('hello', 'w') as f:
135
f.write('hello world')
137
revid = wt.commit(message='add hello', lossy=True,
138
timestamp=1302659388, timezone=0)
139
self.assertEqual(b'dummy-v1:1302659388-0-UNKNOWN', revid)
141
def test_commit_bound_lossy_foreign(self):
142
"""Attempt a lossy commit to a bzr branch bound to a foreign branch."""
143
test_foreign.register_dummy_foreign_for_test(self)
144
foreign_branch = self.make_branch('foreign',
145
format=test_foreign.DummyForeignVcsDirFormat())
146
wt = foreign_branch.create_checkout("local")
148
with open('local/hello', 'w') as f:
149
f.write('hello world')
151
revid = wt.commit(message='add hello', lossy=True,
152
timestamp=1302659388, timezone=0)
153
self.assertEqual(b'dummy-v1:1302659388-0-0', revid)
154
self.assertEqual(b'dummy-v1:1302659388-0-0',
155
foreign_branch.last_revision())
156
self.assertEqual(b'dummy-v1:1302659388-0-0',
157
wt.branch.last_revision())
108
self.assertEqual('version 2', text)
159
110
def test_missing_commit(self):
160
111
"""Test a commit with a missing file"""
161
112
wt = self.make_branch_and_tree('.')
163
with open('hello', 'w') as f:
164
f.write('hello world')
165
wt.add(['hello'], [b'hello-id'])
114
file('hello', 'w').write('hello world')
115
wt.add(['hello'], ['hello-id'])
166
116
wt.commit(message='add hello')
168
118
os.remove('hello')
169
reporter = CapturingReporter()
170
wt.commit('removed hello', rev_id=b'rev2', reporter=reporter)
172
[('missing', u'hello'), ('deleted', u'hello')],
119
wt.commit('removed hello', rev_id='rev2')
175
tree = b.repository.revision_tree(b'rev2')
176
self.assertFalse(tree.has_filename('hello'))
121
tree = b.repository.revision_tree('rev2')
122
self.assertFalse(tree.has_id('hello-id'))
178
124
def test_partial_commit_move(self):
179
125
"""Test a partial commit where a file was renamed but not committed.
220
165
message='empty tree',
221
166
allow_pointless=False)
222
167
wt.commit(message='empty tree', allow_pointless=True)
223
self.assertEqual(b.revno(), 2)
168
self.assertEquals(b.revno(), 2)
225
170
def test_selective_delete(self):
226
171
"""Selective commit in tree with deletions"""
227
172
wt = self.make_branch_and_tree('.')
229
with open('hello', 'w') as f:
231
with open('buongia', 'w') as f:
174
file('hello', 'w').write('hello')
175
file('buongia', 'w').write('buongia')
233
176
wt.add(['hello', 'buongia'],
234
[b'hello-id', b'buongia-id'])
177
['hello-id', 'buongia-id'])
235
178
wt.commit(message='add files',
236
rev_id=b'test@rev-1')
238
181
os.remove('hello')
239
with open('buongia', 'w') as f:
182
file('buongia', 'w').write('new text')
241
183
wt.commit(message='update text',
242
specific_files=['buongia'],
243
allow_pointless=False,
244
rev_id=b'test@rev-2')
184
specific_files=['buongia'],
185
allow_pointless=False,
246
188
wt.commit(message='remove hello',
247
specific_files=['hello'],
248
allow_pointless=False,
249
rev_id=b'test@rev-3')
189
specific_files=['hello'],
190
allow_pointless=False,
251
eq = self.assertEqual
193
eq = self.assertEquals
254
tree2 = b.repository.revision_tree(b'test@rev-2')
196
tree2 = b.repository.revision_tree('test@rev-2')
255
197
tree2.lock_read()
256
198
self.addCleanup(tree2.unlock)
257
199
self.assertTrue(tree2.has_filename('hello'))
258
self.assertEqual(tree2.get_file_text('hello'), b'hello')
259
self.assertEqual(tree2.get_file_text('buongia'), b'new text')
200
self.assertEquals(tree2.get_file_text('hello-id'), 'hello')
201
self.assertEquals(tree2.get_file_text('buongia-id'), 'new text')
261
tree3 = b.repository.revision_tree(b'test@rev-3')
203
tree3 = b.repository.revision_tree('test@rev-3')
262
204
tree3.lock_read()
263
205
self.addCleanup(tree3.unlock)
264
206
self.assertFalse(tree3.has_filename('hello'))
265
self.assertEqual(tree3.get_file_text('buongia'), b'new text')
207
self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
267
209
def test_commit_rename(self):
268
210
"""Test commit of a revision where a file is renamed."""
269
211
tree = self.make_branch_and_tree('.')
271
213
self.build_tree(['hello'], line_endings='binary')
272
tree.add(['hello'], [b'hello-id'])
273
tree.commit(message='one', rev_id=b'test@rev-1', allow_pointless=False)
214
tree.add(['hello'], ['hello-id'])
215
tree.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
275
217
tree.rename_one('hello', 'fruity')
276
tree.commit(message='renamed', rev_id=b'test@rev-2',
277
allow_pointless=False)
218
tree.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
279
eq = self.assertEqual
280
tree1 = b.repository.revision_tree(b'test@rev-1')
220
eq = self.assertEquals
221
tree1 = b.repository.revision_tree('test@rev-1')
281
222
tree1.lock_read()
282
223
self.addCleanup(tree1.unlock)
283
eq(tree1.id2path(b'hello-id'), 'hello')
284
eq(tree1.get_file_text('hello'), b'contents of hello\n')
224
eq(tree1.id2path('hello-id'), 'hello')
225
eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
285
226
self.assertFalse(tree1.has_filename('fruity'))
286
self.check_tree_shape(tree1, ['hello'])
287
eq(tree1.get_file_revision('hello'), b'test@rev-1')
227
self.check_inventory_shape(tree1.inventory, ['hello'])
228
ie = tree1.inventory['hello-id']
229
eq(ie.revision, 'test@rev-1')
289
tree2 = b.repository.revision_tree(b'test@rev-2')
231
tree2 = b.repository.revision_tree('test@rev-2')
290
232
tree2.lock_read()
291
233
self.addCleanup(tree2.unlock)
292
eq(tree2.id2path(b'hello-id'), 'fruity')
293
eq(tree2.get_file_text('fruity'), b'contents of hello\n')
294
self.check_tree_shape(tree2, ['fruity'])
295
eq(tree2.get_file_revision('fruity'), b'test@rev-2')
234
eq(tree2.id2path('hello-id'), 'fruity')
235
eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
236
self.check_inventory_shape(tree2.inventory, ['fruity'])
237
ie = tree2.inventory['hello-id']
238
eq(ie.revision, 'test@rev-2')
297
240
def test_reused_rev_id(self):
298
241
"""Test that a revision id cannot be reused in a branch"""
299
242
wt = self.make_branch_and_tree('.')
301
wt.commit('initial', rev_id=b'test@rev-1', allow_pointless=True)
244
wt.commit('initial', rev_id='test@rev-1', allow_pointless=True)
302
245
self.assertRaises(Exception,
304
247
message='reused id',
305
rev_id=b'test@rev-1',
306
249
allow_pointless=True)
308
251
def test_commit_move(self):
309
252
"""Test commit of revisions with moved files and directories"""
310
eq = self.assertEqual
253
eq = self.assertEquals
311
254
wt = self.make_branch_and_tree('.')
314
257
self.build_tree(['hello', 'a/', 'b/'])
315
wt.add(['hello', 'a', 'b'], [b'hello-id', b'a-id', b'b-id'])
258
wt.add(['hello', 'a', 'b'], ['hello-id', 'a-id', 'b-id'])
316
259
wt.commit('initial', rev_id=r1, allow_pointless=False)
317
260
wt.move(['hello'], 'a')
319
262
wt.commit('two', rev_id=r2, allow_pointless=False)
322
self.check_tree_shape(wt, ['a/', 'a/hello', 'b/'])
265
self.check_inventory_shape(wt.read_working_inventory(),
266
['a/', 'a/hello', 'b/'])
326
270
wt.move(['b'], 'a')
328
272
wt.commit('three', rev_id=r3, allow_pointless=False)
331
self.check_tree_shape(wt,
332
['a/', 'a/hello', 'a/b/'])
333
self.check_tree_shape(b.repository.revision_tree(r3),
334
['a/', 'a/hello', 'a/b/'])
275
self.check_inventory_shape(wt.read_working_inventory(),
276
['a/', 'a/hello', 'a/b/'])
277
self.check_inventory_shape(b.repository.get_inventory(r3),
278
['a/', 'a/hello', 'a/b/'])
338
282
wt.move(['a/hello'], 'a/b')
340
284
wt.commit('four', rev_id=r4, allow_pointless=False)
343
self.check_tree_shape(wt, ['a/', 'a/b/hello', 'a/b/'])
287
self.check_inventory_shape(wt.read_working_inventory(),
288
['a/', 'a/b/hello', 'a/b/'])
347
292
inv = b.repository.get_inventory(r4)
348
eq(inv.get_entry(b'hello-id').revision, r4)
349
eq(inv.get_entry(b'a-id').revision, r1)
350
eq(inv.get_entry(b'b-id').revision, r3)
293
eq(inv['hello-id'].revision, r4)
294
eq(inv['a-id'].revision, r1)
295
eq(inv['b-id'].revision, r3)
352
297
def test_removed_commit(self):
353
298
"""Commit with a removed file"""
354
299
wt = self.make_branch_and_tree('.')
356
with open('hello', 'w') as f:
357
f.write('hello world')
358
wt.add(['hello'], [b'hello-id'])
301
file('hello', 'w').write('hello world')
302
wt.add(['hello'], ['hello-id'])
359
303
wt.commit(message='add hello')
360
304
wt.remove('hello')
361
wt.commit('removed hello', rev_id=b'rev2')
305
wt.commit('removed hello', rev_id='rev2')
363
tree = b.repository.revision_tree(b'rev2')
364
self.assertFalse(tree.has_filename('hello'))
307
tree = b.repository.revision_tree('rev2')
308
self.assertFalse(tree.has_id('hello-id'))
366
310
def test_committed_ancestry(self):
367
311
"""Test commit appends revisions to ancestry."""
371
315
for i in range(4):
372
with open('hello', 'w') as f:
373
f.write((str(i) * 4) + '\n')
316
file('hello', 'w').write((str(i) * 4) + '\n')
375
wt.add(['hello'], [b'hello-id'])
376
rev_id = b'test@rev-%d' % (i + 1)
318
wt.add(['hello'], ['hello-id'])
319
rev_id = 'test@rev-%d' % (i+1)
377
320
rev_ids.append(rev_id)
378
wt.commit(message='rev %d' % (i + 1),
321
wt.commit(message='rev %d' % (i+1),
323
eq = self.assertEquals
324
eq(b.revision_history(), rev_ids)
380
325
for i in range(4):
381
self.assertThat(rev_ids[:i + 1],
382
MatchesAncestry(b.repository, rev_ids[i]))
326
anc = b.repository.get_ancestry(rev_ids[i])
327
eq(anc, [None] + rev_ids[:i+1])
384
329
def test_commit_new_subdir_child_selective(self):
385
330
wt = self.make_branch_and_tree('.')
387
332
self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
388
333
wt.add(['dir', 'dir/file1', 'dir/file2'],
389
[b'dirid', b'file1id', b'file2id'])
390
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id=b'1')
391
inv = b.repository.get_inventory(b'1')
392
self.assertEqual(b'1', inv.get_entry(b'dirid').revision)
393
self.assertEqual(b'1', inv.get_entry(b'file1id').revision)
334
['dirid', 'file1id', 'file2id'])
335
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
336
inv = b.repository.get_inventory('1')
337
self.assertEqual('1', inv['dirid'].revision)
338
self.assertEqual('1', inv['file1id'].revision)
394
339
# FIXME: This should raise a KeyError I think, rbc20051006
395
self.assertRaises(BzrError, inv.get_entry, b'file2id')
340
self.assertRaises(BzrError, inv.__getitem__, 'file2id')
397
342
def test_strict_commit(self):
398
343
"""Try and commit with unknown files and strict = True, should fail."""
399
from ..errors import StrictCommitFailed
344
from bzrlib.errors import StrictCommitFailed
400
345
wt = self.make_branch_and_tree('.')
402
with open('hello', 'w') as f:
403
f.write('hello world')
347
file('hello', 'w').write('hello world')
405
with open('goodbye', 'w') as f:
406
f.write('goodbye cruel world!')
349
file('goodbye', 'w').write('goodbye cruel world!')
407
350
self.assertRaises(StrictCommitFailed, wt.commit,
408
message='add hello but not goodbye', strict=True)
351
message='add hello but not goodbye', strict=True)
410
353
def test_strict_commit_without_unknowns(self):
411
354
"""Try and commit with no unknown files and strict = True,
356
from bzrlib.errors import StrictCommitFailed
413
357
wt = self.make_branch_and_tree('.')
415
with open('hello', 'w') as f:
416
f.write('hello world')
359
file('hello', 'w').write('hello world')
418
361
wt.commit(message='add hello', strict=True)
434
375
wt = self.make_branch_and_tree('.')
436
with open('hello', 'w') as f:
437
f.write('hello world')
377
file('hello', 'w').write('hello world')
439
379
wt.commit(message='add hello', strict=False)
441
381
def test_signed_commit(self):
443
import breezy.commit as commit
444
oldstrategy = breezy.gpg.GPGStrategy
383
import bzrlib.commit as commit
384
oldstrategy = bzrlib.gpg.GPGStrategy
445
385
wt = self.make_branch_and_tree('.')
446
386
branch = wt.branch
447
wt.commit("base", allow_pointless=True, rev_id=b'A')
448
self.assertFalse(branch.repository.has_signature_for_revision_id(b'A'))
387
wt.commit("base", allow_pointless=True, rev_id='A')
388
self.failIf(branch.repository.has_signature_for_revision_id('A'))
450
from ..bzr.testament import Testament
390
from bzrlib.testament import Testament
451
391
# monkey patch gpg signing mechanism
452
breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
453
conf = config.MemoryStack(b'''
454
create_signatures=always
456
commit.Commit(config_stack=conf).commit(
457
message="base", allow_pointless=True, rev_id=b'B',
392
bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
393
commit.Commit(config=MustSignConfig(branch)).commit(message="base",
394
allow_pointless=True,
461
return breezy.gpg.LoopbackGPGStrategy(None).sign(
462
text, breezy.gpg.MODE_CLEAR)
398
return bzrlib.gpg.LoopbackGPGStrategy(None).sign(text)
463
399
self.assertEqual(sign(Testament.from_revision(branch.repository,
464
b'B').as_short_text()),
465
branch.repository.get_signature_text(b'B'))
400
'B').as_short_text()),
401
branch.repository.get_signature_text('B'))
467
breezy.gpg.GPGStrategy = oldstrategy
403
bzrlib.gpg.GPGStrategy = oldstrategy
469
405
def test_commit_failed_signature(self):
471
import breezy.commit as commit
472
oldstrategy = breezy.gpg.GPGStrategy
407
import bzrlib.commit as commit
408
oldstrategy = bzrlib.gpg.GPGStrategy
473
409
wt = self.make_branch_and_tree('.')
474
410
branch = wt.branch
475
wt.commit("base", allow_pointless=True, rev_id=b'A')
476
self.assertFalse(branch.repository.has_signature_for_revision_id(b'A'))
411
wt.commit("base", allow_pointless=True, rev_id='A')
412
self.failIf(branch.repository.has_signature_for_revision_id('A'))
414
from bzrlib.testament import Testament
478
415
# monkey patch gpg signing mechanism
479
breezy.gpg.GPGStrategy = breezy.gpg.DisabledGPGStrategy
480
conf = config.MemoryStack(b'''
481
create_signatures=always
483
self.assertRaises(breezy.gpg.SigningFailed,
484
commit.Commit(config_stack=conf).commit,
416
bzrlib.gpg.GPGStrategy = bzrlib.gpg.DisabledGPGStrategy
417
config = MustSignConfig(branch)
418
self.assertRaises(SigningFailed,
419
commit.Commit(config=config).commit,
486
421
allow_pointless=True,
489
424
branch = Branch.open(self.get_url('.'))
490
self.assertEqual(branch.last_revision(), b'A')
491
self.assertFalse(branch.repository.has_revision(b'B'))
425
self.assertEqual(branch.revision_history(), ['A'])
426
self.failIf(branch.repository.has_revision('B'))
493
breezy.gpg.GPGStrategy = oldstrategy
428
bzrlib.gpg.GPGStrategy = oldstrategy
495
430
def test_commit_invokes_hooks(self):
496
import breezy.commit as commit
431
import bzrlib.commit as commit
497
432
wt = self.make_branch_and_tree('.')
498
433
branch = wt.branch
501
435
def called(branch, rev_id):
502
436
calls.append('called')
503
breezy.ahook = called
437
bzrlib.ahook = called
505
conf = config.MemoryStack(b'post_commit=breezy.ahook breezy.ahook')
506
commit.Commit(config_stack=conf).commit(
507
message="base", allow_pointless=True, rev_id=b'A',
439
config = BranchWithHooks(branch)
440
commit.Commit(config=config).commit(
442
allow_pointless=True,
443
rev_id='A', working_tree = wt)
509
444
self.assertEqual(['called', 'called'], calls)
513
448
def test_commit_object_doesnt_set_nick(self):
514
449
# using the Commit object directly does not set the branch nick.
515
450
wt = self.make_branch_and_tree('.')
517
452
c.commit(working_tree=wt, message='empty tree', allow_pointless=True)
518
self.assertEqual(wt.branch.revno(), 1)
453
self.assertEquals(wt.branch.revno(), 1)
519
454
self.assertEqual({},
520
455
wt.branch.repository.get_revision(
521
wt.branch.last_revision()).properties)
456
wt.branch.last_revision()).properties)
523
458
def test_safe_master_lock(self):
524
459
os.mkdir('master')
664
598
tree = self.make_branch_and_tree('.')
665
599
self.build_tree(['a'])
667
tree.commit('added a', rev_id=b'a1')
601
tree.commit('added a', rev_id='a1')
669
rev = tree.branch.repository.get_revision(b'a1')
603
rev = tree.branch.repository.get_revision('a1')
670
604
timestamp = rev.timestamp
671
605
timestamp_1ms = round(timestamp, 3)
672
606
self.assertEqual(timestamp_1ms, timestamp)
674
def assertBasisTreeKind(self, kind, tree, path):
608
def assertBasisTreeKind(self, kind, tree, file_id):
675
609
basis = tree.basis_tree()
676
610
basis.lock_read()
678
self.assertEqual(kind, basis.kind(path))
612
self.assertEqual(kind, basis.kind(file_id))
682
def test_unsupported_symlink_commit(self):
683
self.requireFeature(SymlinkFeature)
684
tree = self.make_branch_and_tree('.')
685
self.build_tree(['hello'])
687
tree.commit('added hello', rev_id=b'hello_id')
688
os.symlink('hello', 'foo')
690
tree.commit('added foo', rev_id=b'foo_id')
692
trace.push_log_file(log)
693
os_symlink = getattr(os, 'symlink', None)
696
# At this point as bzr thinks symlinks are not supported
697
# we should get a warning about symlink foo and bzr should
698
# not think its removed.
700
self.build_tree(['world'])
702
tree.commit('added world', rev_id=b'world_id')
705
os.symlink = os_symlink
706
self.assertContainsRe(
708
b'Ignoring "foo" as symlinks are not '
709
b'supported on this filesystem\\.')
711
616
def test_commit_kind_changes(self):
712
617
self.requireFeature(SymlinkFeature)
713
618
tree = self.make_branch_and_tree('.')
714
619
os.symlink('target', 'name')
715
tree.add('name', b'a-file-id')
620
tree.add('name', 'a-file-id')
716
621
tree.commit('Added a symlink')
717
self.assertBasisTreeKind('symlink', tree, 'name')
622
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
719
624
os.unlink('name')
720
625
self.build_tree(['name'])
721
626
tree.commit('Changed symlink to file')
722
self.assertBasisTreeKind('file', tree, 'name')
627
self.assertBasisTreeKind('file', tree, 'a-file-id')
724
629
os.unlink('name')
725
630
os.symlink('target', 'name')
726
631
tree.commit('file to symlink')
727
self.assertBasisTreeKind('symlink', tree, 'name')
632
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
729
634
os.unlink('name')
731
636
tree.commit('symlink to directory')
732
self.assertBasisTreeKind('directory', tree, 'name')
637
self.assertBasisTreeKind('directory', tree, 'a-file-id')
735
640
os.symlink('target', 'name')
736
641
tree.commit('directory to symlink')
737
self.assertBasisTreeKind('symlink', tree, 'name')
642
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
739
644
# prepare for directory <-> file tests
740
645
os.unlink('name')
742
647
tree.commit('symlink to directory')
743
self.assertBasisTreeKind('directory', tree, 'name')
648
self.assertBasisTreeKind('directory', tree, 'a-file-id')
746
651
self.build_tree(['name'])
747
652
tree.commit('Changed directory to file')
748
self.assertBasisTreeKind('file', tree, 'name')
653
self.assertBasisTreeKind('file', tree, 'a-file-id')
750
655
os.unlink('name')
752
657
tree.commit('file to directory')
753
self.assertBasisTreeKind('directory', tree, 'name')
658
self.assertBasisTreeKind('directory', tree, 'a-file-id')
755
660
def test_commit_unversioned_specified(self):
756
661
"""Commit should raise if specified files isn't in basis or worktree"""
870
774
def test_multiple_authors(self):
871
775
tree = self.make_branch_and_tree('foo')
872
776
rev_id = tree.commit('commit 1',
873
authors=['John Doe <jdoe@example.com>',
874
'Jane Rey <jrey@example.com>'])
777
authors=['John Doe <jdoe@example.com>',
778
'Jane Rey <jrey@example.com>'])
875
779
rev = tree.branch.repository.get_revision(rev_id)
876
780
self.assertEqual('John Doe <jdoe@example.com>\n'
877
'Jane Rey <jrey@example.com>', rev.properties['authors'])
781
'Jane Rey <jrey@example.com>', rev.properties['authors'])
878
782
self.assertFalse('author' in rev.properties)
784
def test_author_and_authors_incompatible(self):
785
tree = self.make_branch_and_tree('foo')
786
self.assertRaises(AssertionError, tree.commit, 'commit 1',
787
authors=['John Doe <jdoe@example.com>',
788
'Jane Rey <jrey@example.com>'],
789
author="Jack Me <jme@example.com>")
880
791
def test_author_with_newline_rejected(self):
881
792
tree = self.make_branch_and_tree('foo')
882
793
self.assertRaises(AssertionError, tree.commit, 'commit 1',
883
authors=['John\nDoe <jdoe@example.com>'])
794
authors=['John\nDoe <jdoe@example.com>'])
885
796
def test_commit_with_checkout_and_branch_sharing_repo(self):
886
797
repo = self.make_repository('repo', shared=True)
887
798
# make_branch_and_tree ignores shared repos
888
branch = controldir.ControlDir.create_branch_convenience('repo/branch')
799
branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
889
800
tree2 = branch.create_checkout('repo/tree2')
890
tree2.commit('message', rev_id=b'rev1')
891
self.assertTrue(tree2.branch.repository.has_revision(b'rev1'))
894
class FilterExcludedTests(TestCase):
896
def test_add_file_not_excluded(self):
899
'fid', (None, 'newpath'),
900
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
901
('file', 'file'), (True, True))]
902
self.assertEqual(changes, list(
903
filter_excluded(changes, ['otherpath'])))
905
def test_add_file_excluded(self):
908
'fid', (None, 'newpath'),
909
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
910
('file', 'file'), (True, True))]
911
self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
913
def test_delete_file_excluded(self):
916
'fid', ('somepath', None),
917
0, (False, None), ('pid', None), ('newpath', None),
918
('file', None), (True, None))]
919
self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
921
def test_move_from_or_to_excluded(self):
924
'fid', ('oldpath', 'newpath'),
925
0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
926
('file', 'file'), (True, True))]
927
self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
928
self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
801
tree2.commit('message', rev_id='rev1')
802
self.assertTrue(tree2.branch.repository.has_revision('rev1'))