106
98
tree1 = b.repository.revision_tree(rev1)
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
104
tree2 = b.repository.revision_tree(rev2)
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)
108
self.assertEqual('version 2', text)
118
110
def test_commit_lossy_native(self):
119
111
"""Attempt a lossy commit to a native branch."""
120
112
wt = self.make_branch_and_tree('.')
122
with open('hello', 'w') as f:
123
f.write('hello world')
114
with file('hello', 'w') as f: f.write('hello world')
125
revid = wt.commit(message='add hello', rev_id=b'revid', lossy=True)
126
self.assertEqual(b'revid', revid)
116
revid = wt.commit(message='add hello', rev_id='revid', lossy=True)
117
self.assertEqual('revid', revid)
128
119
def test_commit_lossy_foreign(self):
129
120
"""Attempt a lossy commit to a foreign branch."""
130
121
test_foreign.register_dummy_foreign_for_test(self)
131
122
wt = self.make_branch_and_tree('.',
132
format=test_foreign.DummyForeignVcsDirFormat())
123
format=test_foreign.DummyForeignVcsDirFormat())
134
with open('hello', 'w') as f:
135
f.write('hello world')
125
with file('hello', 'w') as f: f.write('hello world')
137
127
revid = wt.commit(message='add hello', lossy=True,
138
timestamp=1302659388, timezone=0)
139
self.assertEqual(b'dummy-v1:1302659388-0-UNKNOWN', revid)
128
timestamp=1302659388, timezone=0)
129
self.assertEqual('dummy-v1:1302659388.0-0-UNKNOWN', revid)
141
131
def test_commit_bound_lossy_foreign(self):
142
132
"""Attempt a lossy commit to a bzr branch bound to a foreign branch."""
143
133
test_foreign.register_dummy_foreign_for_test(self)
144
134
foreign_branch = self.make_branch('foreign',
145
format=test_foreign.DummyForeignVcsDirFormat())
135
format=test_foreign.DummyForeignVcsDirFormat())
146
136
wt = foreign_branch.create_checkout("local")
148
with open('local/hello', 'w') as f:
149
f.write('hello world')
138
with file('local/hello', 'w') as f: f.write('hello world')
151
140
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())
141
timestamp=1302659388, timezone=0)
142
self.assertEqual('dummy-v1:1302659388.0-0-0', revid)
143
self.assertEqual('dummy-v1:1302659388.0-0-0',
144
foreign_branch.last_revision())
145
self.assertEqual('dummy-v1:1302659388.0-0-0',
146
wt.branch.last_revision())
159
148
def test_missing_commit(self):
160
149
"""Test a commit with a missing file"""
161
150
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'])
152
with file('hello', 'w') as f: f.write('hello world')
153
wt.add(['hello'], ['hello-id'])
166
154
wt.commit(message='add hello')
168
156
os.remove('hello')
169
157
reporter = CapturingReporter()
170
wt.commit('removed hello', rev_id=b'rev2', reporter=reporter)
158
wt.commit('removed hello', rev_id='rev2', reporter=reporter)
171
159
self.assertEqual(
172
160
[('missing', u'hello'), ('deleted', u'hello')],
175
tree = b.repository.revision_tree(b'rev2')
176
self.assertFalse(tree.has_filename('hello'))
163
tree = b.repository.revision_tree('rev2')
164
self.assertFalse(tree.has_id('hello-id'))
178
166
def test_partial_commit_move(self):
179
167
"""Test a partial commit where a file was renamed but not committed.
189
177
self.build_tree(['annotate/', 'annotate/foo.py',
190
178
'olive/', 'olive/dialog.py'
192
180
wt.add(['annotate', 'olive', 'annotate/foo.py', 'olive/dialog.py'])
193
181
wt.commit(message='add files')
194
182
wt.rename_one("olive/dialog.py", "aaa")
195
self.build_tree_contents([('annotate/foo.py', b'modified\n')])
183
self.build_tree_contents([('annotate/foo.py', 'modified\n')])
196
184
wt.commit('renamed hello', specific_files=["annotate"])
198
186
def test_pointless_commit(self):
199
187
"""Commit refuses unless there are changes or it's forced."""
200
188
wt = self.make_branch_and_tree('.')
202
with open('hello', 'w') as f:
190
with file('hello', 'w') as f: f.write('hello')
204
191
wt.add(['hello'])
205
192
wt.commit(message='add hello')
206
193
self.assertEqual(b.revno(), 1)
226
213
"""Selective commit in tree with deletions"""
227
214
wt = self.make_branch_and_tree('.')
229
with open('hello', 'w') as f:
231
with open('buongia', 'w') as f:
216
with file('hello', 'w') as f: f.write('hello')
217
with file('buongia', 'w') as f: f.write('buongia')
233
218
wt.add(['hello', 'buongia'],
234
[b'hello-id', b'buongia-id'])
219
['hello-id', 'buongia-id'])
235
220
wt.commit(message='add files',
236
rev_id=b'test@rev-1')
238
223
os.remove('hello')
239
with open('buongia', 'w') as f:
224
with file('buongia', 'w') as f: f.write('new text')
241
225
wt.commit(message='update text',
242
specific_files=['buongia'],
243
allow_pointless=False,
244
rev_id=b'test@rev-2')
226
specific_files=['buongia'],
227
allow_pointless=False,
246
230
wt.commit(message='remove hello',
247
specific_files=['hello'],
248
allow_pointless=False,
249
rev_id=b'test@rev-3')
231
specific_files=['hello'],
232
allow_pointless=False,
251
235
eq = self.assertEqual
254
tree2 = b.repository.revision_tree(b'test@rev-2')
238
tree2 = b.repository.revision_tree('test@rev-2')
255
239
tree2.lock_read()
256
240
self.addCleanup(tree2.unlock)
257
241
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')
242
self.assertEqual(tree2.get_file_text('hello-id'), 'hello')
243
self.assertEqual(tree2.get_file_text('buongia-id'), 'new text')
261
tree3 = b.repository.revision_tree(b'test@rev-3')
245
tree3 = b.repository.revision_tree('test@rev-3')
262
246
tree3.lock_read()
263
247
self.addCleanup(tree3.unlock)
264
248
self.assertFalse(tree3.has_filename('hello'))
265
self.assertEqual(tree3.get_file_text('buongia'), b'new text')
249
self.assertEqual(tree3.get_file_text('buongia-id'), 'new text')
267
251
def test_commit_rename(self):
268
252
"""Test commit of a revision where a file is renamed."""
269
253
tree = self.make_branch_and_tree('.')
271
255
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)
256
tree.add(['hello'], ['hello-id'])
257
tree.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
275
259
tree.rename_one('hello', 'fruity')
276
tree.commit(message='renamed', rev_id=b'test@rev-2',
277
allow_pointless=False)
260
tree.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
279
262
eq = self.assertEqual
280
tree1 = b.repository.revision_tree(b'test@rev-1')
263
tree1 = b.repository.revision_tree('test@rev-1')
281
264
tree1.lock_read()
282
265
self.addCleanup(tree1.unlock)
283
eq(tree1.id2path(b'hello-id'), 'hello')
284
eq(tree1.get_file_text('hello'), b'contents of hello\n')
266
eq(tree1.id2path('hello-id'), 'hello')
267
eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
285
268
self.assertFalse(tree1.has_filename('fruity'))
286
269
self.check_tree_shape(tree1, ['hello'])
287
eq(tree1.get_file_revision('hello'), b'test@rev-1')
270
eq(tree1.get_file_revision('hello-id'), 'test@rev-1')
289
tree2 = b.repository.revision_tree(b'test@rev-2')
272
tree2 = b.repository.revision_tree('test@rev-2')
290
273
tree2.lock_read()
291
274
self.addCleanup(tree2.unlock)
292
eq(tree2.id2path(b'hello-id'), 'fruity')
293
eq(tree2.get_file_text('fruity'), b'contents of hello\n')
275
eq(tree2.id2path('hello-id'), 'fruity')
276
eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
294
277
self.check_tree_shape(tree2, ['fruity'])
295
eq(tree2.get_file_revision('fruity'), b'test@rev-2')
278
eq(tree2.get_file_revision('hello-id'), 'test@rev-2')
297
280
def test_reused_rev_id(self):
298
281
"""Test that a revision id cannot be reused in a branch"""
299
282
wt = self.make_branch_and_tree('.')
301
wt.commit('initial', rev_id=b'test@rev-1', allow_pointless=True)
284
wt.commit('initial', rev_id='test@rev-1', allow_pointless=True)
302
285
self.assertRaises(Exception,
304
287
message='reused id',
305
rev_id=b'test@rev-1',
306
289
allow_pointless=True)
308
291
def test_commit_move(self):
347
330
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)
331
eq(inv['hello-id'].revision, r4)
332
eq(inv['a-id'].revision, r1)
333
eq(inv['b-id'].revision, r3)
352
335
def test_removed_commit(self):
353
336
"""Commit with a removed file"""
354
337
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'])
339
with file('hello', 'w') as f: f.write('hello world')
340
wt.add(['hello'], ['hello-id'])
359
341
wt.commit(message='add hello')
360
342
wt.remove('hello')
361
wt.commit('removed hello', rev_id=b'rev2')
343
wt.commit('removed hello', rev_id='rev2')
363
tree = b.repository.revision_tree(b'rev2')
364
self.assertFalse(tree.has_filename('hello'))
345
tree = b.repository.revision_tree('rev2')
346
self.assertFalse(tree.has_id('hello-id'))
366
348
def test_committed_ancestry(self):
367
349
"""Test commit appends revisions to ancestry."""
371
353
for i in range(4):
372
with open('hello', 'w') as f:
373
f.write((str(i) * 4) + '\n')
354
with file('hello', 'w') as f: f.write((str(i) * 4) + '\n')
375
wt.add(['hello'], [b'hello-id'])
376
rev_id = b'test@rev-%d' % (i + 1)
356
wt.add(['hello'], ['hello-id'])
357
rev_id = 'test@rev-%d' % (i+1)
377
358
rev_ids.append(rev_id)
378
wt.commit(message='rev %d' % (i + 1),
359
wt.commit(message='rev %d' % (i+1),
380
361
for i in range(4):
381
self.assertThat(rev_ids[:i + 1],
382
MatchesAncestry(b.repository, rev_ids[i]))
362
self.assertThat(rev_ids[:i+1],
363
MatchesAncestry(b.repository, rev_ids[i]))
384
365
def test_commit_new_subdir_child_selective(self):
385
366
wt = self.make_branch_and_tree('.')
387
368
self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
388
369
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)
370
['dirid', 'file1id', 'file2id'])
371
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
372
inv = b.repository.get_inventory('1')
373
self.assertEqual('1', inv['dirid'].revision)
374
self.assertEqual('1', inv['file1id'].revision)
394
375
# FIXME: This should raise a KeyError I think, rbc20051006
395
self.assertRaises(BzrError, inv.get_entry, b'file2id')
376
self.assertRaises(BzrError, inv.__getitem__, 'file2id')
397
378
def test_strict_commit(self):
398
379
"""Try and commit with unknown files and strict = True, should fail."""
399
380
from ..errors import StrictCommitFailed
400
381
wt = self.make_branch_and_tree('.')
402
with open('hello', 'w') as f:
403
f.write('hello world')
383
with file('hello', 'w') as f: f.write('hello world')
405
with open('goodbye', 'w') as f:
406
f.write('goodbye cruel world!')
385
with file('goodbye', 'w') as f: f.write('goodbye cruel world!')
407
386
self.assertRaises(StrictCommitFailed, wt.commit,
408
message='add hello but not goodbye', strict=True)
387
message='add hello but not goodbye', strict=True)
410
389
def test_strict_commit_without_unknowns(self):
411
390
"""Try and commit with no unknown files and strict = True,
413
392
wt = self.make_branch_and_tree('.')
415
with open('hello', 'w') as f:
416
f.write('hello world')
394
with file('hello', 'w') as f: f.write('hello world')
418
396
wt.commit(message='add hello', strict=True)
444
419
oldstrategy = breezy.gpg.GPGStrategy
445
420
wt = self.make_branch_and_tree('.')
446
421
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'))
422
wt.commit("base", allow_pointless=True, rev_id='A')
423
self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
450
from ..bzr.testament import Testament
425
from ..testament import Testament
451
426
# monkey patch gpg signing mechanism
452
427
breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
453
conf = config.MemoryStack(b'''
428
conf = config.MemoryStack('''
429
gpg_signing_command=cat -
454
430
create_signatures=always
456
432
commit.Commit(config_stack=conf).commit(
457
message="base", allow_pointless=True, rev_id=b'B',
433
message="base", allow_pointless=True, rev_id='B',
461
return breezy.gpg.LoopbackGPGStrategy(None).sign(
462
text, breezy.gpg.MODE_CLEAR)
436
return breezy.gpg.LoopbackGPGStrategy(None).sign(text)
463
437
self.assertEqual(sign(Testament.from_revision(branch.repository,
464
b'B').as_short_text()),
465
branch.repository.get_signature_text(b'B'))
438
'B').as_short_text()),
439
branch.repository.get_signature_text('B'))
467
441
breezy.gpg.GPGStrategy = oldstrategy
472
446
oldstrategy = breezy.gpg.GPGStrategy
473
447
wt = self.make_branch_and_tree('.')
474
448
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'))
449
wt.commit("base", allow_pointless=True, rev_id='A')
450
self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
478
452
# monkey patch gpg signing mechanism
479
453
breezy.gpg.GPGStrategy = breezy.gpg.DisabledGPGStrategy
480
conf = config.MemoryStack(b'''
454
conf = config.MemoryStack('''
455
gpg_signing_command=cat -
481
456
create_signatures=always
483
self.assertRaises(breezy.gpg.SigningFailed,
458
self.assertRaises(SigningFailed,
484
459
commit.Commit(config_stack=conf).commit,
486
461
allow_pointless=True,
489
464
branch = Branch.open(self.get_url('.'))
490
self.assertEqual(branch.last_revision(), b'A')
491
self.assertFalse(branch.repository.has_revision(b'B'))
465
self.assertEqual(branch.last_revision(), 'A')
466
self.assertFalse(branch.repository.has_revision('B'))
493
468
breezy.gpg.GPGStrategy = oldstrategy
539
516
bound_tree = self.make_branch_and_tree('bound')
540
517
bound_tree.branch.bind(master_branch)
542
self.build_tree_contents(
543
[('bound/content_file', b'initial contents\n')])
519
self.build_tree_contents([('bound/content_file', 'initial contents\n')])
544
520
bound_tree.add(['content_file'])
545
521
bound_tree.commit(message='woo!')
547
other_bzrdir = master_branch.controldir.sprout('other')
523
other_bzrdir = master_branch.bzrdir.sprout('other')
548
524
other_tree = other_bzrdir.open_workingtree()
550
526
# do a commit to the other branch changing the content file so
551
527
# that our commit after merging will have a merged revision in the
552
528
# content file history.
553
self.build_tree_contents(
554
[('other/content_file', b'change in other\n')])
529
self.build_tree_contents([('other/content_file', 'change in other\n')])
555
530
other_tree.commit('change in other')
557
532
# do a merge into the bound branch from other, and then change the
558
533
# content file locally to force a new revision (rather than using the
559
534
# revision from other). This forces extra processing in commit.
560
535
bound_tree.merge_from_branch(other_tree.branch)
561
self.build_tree_contents(
562
[('bound/content_file', b'change in bound\n')])
536
self.build_tree_contents([('bound/content_file', 'change in bound\n')])
564
538
# before #34959 was fixed, this failed with 'revision not present in
565
539
# weave' when trying to implicitly push from the bound branch to the master
601
575
other_tree.rename_one('dirtorename', 'renameddir')
602
576
other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir')
603
577
other_tree.rename_one('filetorename', 'renamedfile')
604
other_tree.rename_one(
605
'filetoreparent', 'renameddir/reparentedfile')
578
other_tree.rename_one('filetoreparent', 'renameddir/reparentedfile')
606
579
other_tree.remove(['dirtoremove', 'filetoremove'])
607
580
self.build_tree_contents([
608
581
('other/newdir/', ),
609
('other/filetomodify', b'new content'),
610
('other/newfile', b'new file content')])
582
('other/filetomodify', 'new content'),
583
('other/newfile', 'new file content')])
611
584
other_tree.add('newfile')
612
585
other_tree.add('newdir/')
613
586
other_tree.commit('modify all sample files and dirs.')
661
637
tree = self.make_branch_and_tree('.')
662
638
self.build_tree(['a'])
664
tree.commit('added a', rev_id=b'a1')
640
tree.commit('added a', rev_id='a1')
666
rev = tree.branch.repository.get_revision(b'a1')
642
rev = tree.branch.repository.get_revision('a1')
667
643
timestamp = rev.timestamp
668
644
timestamp_1ms = round(timestamp, 3)
669
645
self.assertEqual(timestamp_1ms, timestamp)
671
def assertBasisTreeKind(self, kind, tree, path):
647
def assertBasisTreeKind(self, kind, tree, file_id):
672
648
basis = tree.basis_tree()
673
649
basis.lock_read()
675
self.assertEqual(kind, basis.kind(path))
651
self.assertEqual(kind, basis.kind(file_id))
679
def test_unsupported_symlink_commit(self):
680
self.requireFeature(SymlinkFeature)
681
tree = self.make_branch_and_tree('.')
682
self.build_tree(['hello'])
684
tree.commit('added hello', rev_id=b'hello_id')
685
os.symlink('hello', 'foo')
687
tree.commit('added foo', rev_id=b'foo_id')
689
trace.push_log_file(log)
690
os_symlink = getattr(os, 'symlink', None)
693
# At this point as bzr thinks symlinks are not supported
694
# we should get a warning about symlink foo and bzr should
695
# not think its removed.
697
self.build_tree(['world'])
699
tree.commit('added world', rev_id=b'world_id')
702
os.symlink = os_symlink
703
self.assertContainsRe(
705
b'Ignoring "foo" as symlinks are not '
706
b'supported on this filesystem\\.')
708
655
def test_commit_kind_changes(self):
709
656
self.requireFeature(SymlinkFeature)
710
657
tree = self.make_branch_and_tree('.')
711
658
os.symlink('target', 'name')
712
tree.add('name', b'a-file-id')
659
tree.add('name', 'a-file-id')
713
660
tree.commit('Added a symlink')
714
self.assertBasisTreeKind('symlink', tree, 'name')
661
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
716
663
os.unlink('name')
717
664
self.build_tree(['name'])
718
665
tree.commit('Changed symlink to file')
719
self.assertBasisTreeKind('file', tree, 'name')
666
self.assertBasisTreeKind('file', tree, 'a-file-id')
721
668
os.unlink('name')
722
669
os.symlink('target', 'name')
723
670
tree.commit('file to symlink')
724
self.assertBasisTreeKind('symlink', tree, 'name')
671
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
726
673
os.unlink('name')
728
675
tree.commit('symlink to directory')
729
self.assertBasisTreeKind('directory', tree, 'name')
676
self.assertBasisTreeKind('directory', tree, 'a-file-id')
732
679
os.symlink('target', 'name')
733
680
tree.commit('directory to symlink')
734
self.assertBasisTreeKind('symlink', tree, 'name')
681
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
736
683
# prepare for directory <-> file tests
737
684
os.unlink('name')
739
686
tree.commit('symlink to directory')
740
self.assertBasisTreeKind('directory', tree, 'name')
687
self.assertBasisTreeKind('directory', tree, 'a-file-id')
743
690
self.build_tree(['name'])
744
691
tree.commit('Changed directory to file')
745
self.assertBasisTreeKind('file', tree, 'name')
692
self.assertBasisTreeKind('file', tree, 'a-file-id')
747
694
os.unlink('name')
749
696
tree.commit('file to directory')
750
self.assertBasisTreeKind('directory', tree, 'name')
697
self.assertBasisTreeKind('directory', tree, 'a-file-id')
752
699
def test_commit_unversioned_specified(self):
753
700
"""Commit should raise if specified files isn't in basis or worktree"""
813
759
tree = self.make_branch_and_tree('foo')
814
760
# pending merge would turn into a left parent
815
761
tree.commit('commit 1')
816
tree.add_parent_tree_id(b'example')
762
tree.add_parent_tree_id('example')
817
763
self.build_tree(['foo/bar', 'foo/baz'])
818
764
tree.add(['bar', 'baz'])
819
err = self.assertRaises(CannotCommitSelectedFileMerge,
820
tree.commit, 'commit 2', specific_files=['bar', 'baz'])
765
err = self.assertRaises(errors.CannotCommitSelectedFileMerge,
766
tree.commit, 'commit 2', specific_files=['bar', 'baz'])
821
767
self.assertEqual(['bar', 'baz'], err.files)
822
768
self.assertEqual('Selected-file commit of merges is not supported'
823
769
' yet: files bar, baz', str(err))
867
813
def test_multiple_authors(self):
868
814
tree = self.make_branch_and_tree('foo')
869
815
rev_id = tree.commit('commit 1',
870
authors=['John Doe <jdoe@example.com>',
871
'Jane Rey <jrey@example.com>'])
816
authors=['John Doe <jdoe@example.com>',
817
'Jane Rey <jrey@example.com>'])
872
818
rev = tree.branch.repository.get_revision(rev_id)
873
819
self.assertEqual('John Doe <jdoe@example.com>\n'
874
'Jane Rey <jrey@example.com>', rev.properties['authors'])
820
'Jane Rey <jrey@example.com>', rev.properties['authors'])
875
821
self.assertFalse('author' in rev.properties)
877
823
def test_author_with_newline_rejected(self):
878
824
tree = self.make_branch_and_tree('foo')
879
825
self.assertRaises(AssertionError, tree.commit, 'commit 1',
880
authors=['John\nDoe <jdoe@example.com>'])
826
authors=['John\nDoe <jdoe@example.com>'])
882
828
def test_commit_with_checkout_and_branch_sharing_repo(self):
883
829
repo = self.make_repository('repo', shared=True)
884
830
# make_branch_and_tree ignores shared repos
885
831
branch = controldir.ControlDir.create_branch_convenience('repo/branch')
886
832
tree2 = branch.create_checkout('repo/tree2')
887
tree2.commit('message', rev_id=b'rev1')
888
self.assertTrue(tree2.branch.repository.has_revision(b'rev1'))
891
class FilterExcludedTests(TestCase):
893
def test_add_file_not_excluded(self):
896
'fid', (None, 'newpath'),
897
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
898
('file', 'file'), (True, True))]
899
self.assertEqual(changes, list(
900
filter_excluded(changes, ['otherpath'])))
902
def test_add_file_excluded(self):
905
'fid', (None, 'newpath'),
906
0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
907
('file', 'file'), (True, True))]
908
self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
910
def test_delete_file_excluded(self):
913
'fid', ('somepath', None),
914
0, (False, None), ('pid', None), ('newpath', None),
915
('file', None), (True, None))]
916
self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
918
def test_move_from_or_to_excluded(self):
921
'fid', ('oldpath', 'newpath'),
922
0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
923
('file', 'file'), (True, True))]
924
self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
925
self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
833
tree2.commit('message', rev_id='rev1')
834
self.assertTrue(tree2.branch.repository.has_revision('rev1'))