118
118
with open('hello', 'w') as f: f.write('hello world')
120
revid = wt.commit(message='add hello', rev_id='revid', lossy=True)
120
revid = wt.commit(message='add hello', rev_id=b'revid', lossy=True)
121
121
self.assertEqual('revid', revid)
123
123
def test_commit_lossy_foreign(self):
154
154
wt = self.make_branch_and_tree('.')
156
156
with open('hello', 'w') as f: f.write('hello world')
157
wt.add(['hello'], ['hello-id'])
157
wt.add(['hello'], [b'hello-id'])
158
158
wt.commit(message='add hello')
160
160
os.remove('hello')
161
161
reporter = CapturingReporter()
162
wt.commit('removed hello', rev_id='rev2', reporter=reporter)
162
wt.commit('removed hello', rev_id=b'rev2', reporter=reporter)
163
163
self.assertEqual(
164
164
[('missing', u'hello'), ('deleted', u'hello')],
167
167
tree = b.repository.revision_tree('rev2')
168
self.assertFalse(tree.has_id('hello-id'))
168
self.assertFalse(tree.has_id(b'hello-id'))
170
170
def test_partial_commit_move(self):
171
171
"""Test a partial commit where a file was renamed but not committed.
184
184
wt.add(['annotate', 'olive', 'annotate/foo.py', 'olive/dialog.py'])
185
185
wt.commit(message='add files')
186
186
wt.rename_one("olive/dialog.py", "aaa")
187
self.build_tree_contents([('annotate/foo.py', 'modified\n')])
187
self.build_tree_contents([('annotate/foo.py', b'modified\n')])
188
188
wt.commit('renamed hello', specific_files=["annotate"])
190
190
def test_pointless_commit(self):
222
222
wt.add(['hello', 'buongia'],
223
223
['hello-id', 'buongia-id'])
224
224
wt.commit(message='add files',
225
rev_id=b'test@rev-1')
227
227
os.remove('hello')
228
228
with open('buongia', 'w') as f: f.write('new text')
229
229
wt.commit(message='update text',
230
230
specific_files=['buongia'],
231
231
allow_pointless=False,
232
rev_id=b'test@rev-2')
234
234
wt.commit(message='remove hello',
235
235
specific_files=['hello'],
236
236
allow_pointless=False,
237
rev_id=b'test@rev-3')
239
239
eq = self.assertEqual
257
257
tree = self.make_branch_and_tree('.')
259
259
self.build_tree(['hello'], line_endings='binary')
260
tree.add(['hello'], ['hello-id'])
261
tree.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
260
tree.add(['hello'], [b'hello-id'])
261
tree.commit(message='one', rev_id=b'test@rev-1', allow_pointless=False)
263
263
tree.rename_one('hello', 'fruity')
264
tree.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
264
tree.commit(message='renamed', rev_id=b'test@rev-2', allow_pointless=False)
266
266
eq = self.assertEqual
267
tree1 = b.repository.revision_tree('test@rev-1')
267
tree1 = b.repository.revision_tree(b'test@rev-1')
268
268
tree1.lock_read()
269
269
self.addCleanup(tree1.unlock)
270
eq(tree1.id2path('hello-id'), 'hello')
270
eq(tree1.id2path(b'hello-id'), 'hello')
271
271
eq(tree1.get_file_text('hello'), 'contents of hello\n')
272
272
self.assertFalse(tree1.has_filename('fruity'))
273
273
self.check_tree_shape(tree1, ['hello'])
274
eq(tree1.get_file_revision('hello'), 'test@rev-1')
274
eq(tree1.get_file_revision('hello'), b'test@rev-1')
276
tree2 = b.repository.revision_tree('test@rev-2')
276
tree2 = b.repository.revision_tree(b'test@rev-2')
277
277
tree2.lock_read()
278
278
self.addCleanup(tree2.unlock)
279
eq(tree2.id2path('hello-id'), 'fruity')
279
eq(tree2.id2path(b'hello-id'), 'fruity')
280
280
eq(tree2.get_file_text('fruity'), 'contents of hello\n')
281
281
self.check_tree_shape(tree2, ['fruity'])
282
eq(tree2.get_file_revision('fruity'), 'test@rev-2')
282
eq(tree2.get_file_revision('fruity'), b'test@rev-2')
284
284
def test_reused_rev_id(self):
285
285
"""Test that a revision id cannot be reused in a branch"""
286
286
wt = self.make_branch_and_tree('.')
288
wt.commit('initial', rev_id='test@rev-1', allow_pointless=True)
288
wt.commit('initial', rev_id=b'test@rev-1', allow_pointless=True)
289
289
self.assertRaises(Exception,
291
291
message='reused id',
292
rev_id=b'test@rev-1',
293
293
allow_pointless=True)
295
295
def test_commit_move(self):
297
297
eq = self.assertEqual
298
298
wt = self.make_branch_and_tree('.')
301
301
self.build_tree(['hello', 'a/', 'b/'])
302
wt.add(['hello', 'a', 'b'], ['hello-id', 'a-id', 'b-id'])
302
wt.add(['hello', 'a', 'b'], [b'hello-id', b'a-id', b'b-id'])
303
303
wt.commit('initial', rev_id=r1, allow_pointless=False)
304
304
wt.move(['hello'], 'a')
306
306
wt.commit('two', rev_id=r2, allow_pointless=False)
334
334
inv = b.repository.get_inventory(r4)
335
eq(inv['hello-id'].revision, r4)
336
eq(inv['a-id'].revision, r1)
337
eq(inv['b-id'].revision, r3)
335
eq(inv[b'hello-id'].revision, r4)
336
eq(inv[b'a-id'].revision, r1)
337
eq(inv[b'b-id'].revision, r3)
339
339
def test_removed_commit(self):
340
340
"""Commit with a removed file"""
341
341
wt = self.make_branch_and_tree('.')
343
343
with open('hello', 'w') as f: f.write('hello world')
344
wt.add(['hello'], ['hello-id'])
344
wt.add(['hello'], [b'hello-id'])
345
345
wt.commit(message='add hello')
346
346
wt.remove('hello')
347
wt.commit('removed hello', rev_id='rev2')
347
wt.commit('removed hello', rev_id=b'rev2')
349
349
tree = b.repository.revision_tree('rev2')
350
350
self.assertFalse(tree.has_id('hello-id'))
357
357
for i in range(4):
358
358
with open('hello', 'w') as f: f.write((str(i) * 4) + '\n')
360
wt.add(['hello'], ['hello-id'])
360
wt.add(['hello'], [b'hello-id'])
361
361
rev_id = 'test@rev-%d' % (i+1)
362
362
rev_ids.append(rev_id)
363
363
wt.commit(message='rev %d' % (i+1),
372
372
self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
373
373
wt.add(['dir', 'dir/file1', 'dir/file2'],
374
374
['dirid', 'file1id', 'file2id'])
375
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
375
wt.commit('dir/file1', specific_files=['dir/file1'], rev_id=b'1')
376
376
inv = b.repository.get_inventory('1')
377
377
self.assertEqual('1', inv['dirid'].revision)
378
378
self.assertEqual('1', inv['file1id'].revision)
423
423
oldstrategy = breezy.gpg.GPGStrategy
424
424
wt = self.make_branch_and_tree('.')
425
425
branch = wt.branch
426
wt.commit("base", allow_pointless=True, rev_id='A')
426
wt.commit("base", allow_pointless=True, rev_id=b'A')
427
427
self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
429
429
from ..testament import Testament
433
433
create_signatures=always
435
435
commit.Commit(config_stack=conf).commit(
436
message="base", allow_pointless=True, rev_id='B',
436
message="base", allow_pointless=True, rev_id=b'B',
439
439
return breezy.gpg.LoopbackGPGStrategy(None).sign(text)
449
449
oldstrategy = breezy.gpg.GPGStrategy
450
450
wt = self.make_branch_and_tree('.')
451
451
branch = wt.branch
452
wt.commit("base", allow_pointless=True, rev_id='A')
452
wt.commit("base", allow_pointless=True, rev_id=b'A')
453
453
self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
455
455
# monkey patch gpg signing mechanism
481
481
conf = config.MemoryStack('post_commit=breezy.ahook breezy.ahook')
482
482
commit.Commit(config_stack=conf).commit(
483
message = "base", allow_pointless=True, rev_id='A',
483
message = "base", allow_pointless=True, rev_id=b'A',
484
484
working_tree = wt)
485
485
self.assertEqual(['called', 'called'], calls)
518
518
bound_tree = self.make_branch_and_tree('bound')
519
519
bound_tree.branch.bind(master_branch)
521
self.build_tree_contents([('bound/content_file', 'initial contents\n')])
521
self.build_tree_contents([('bound/content_file', b'initial contents\n')])
522
522
bound_tree.add(['content_file'])
523
523
bound_tree.commit(message='woo!')
528
528
# do a commit to the other branch changing the content file so
529
529
# that our commit after merging will have a merged revision in the
530
530
# content file history.
531
self.build_tree_contents([('other/content_file', 'change in other\n')])
531
self.build_tree_contents([('other/content_file', b'change in other\n')])
532
532
other_tree.commit('change in other')
534
534
# do a merge into the bound branch from other, and then change the
535
535
# content file locally to force a new revision (rather than using the
536
536
# revision from other). This forces extra processing in commit.
537
537
bound_tree.merge_from_branch(other_tree.branch)
538
self.build_tree_contents([('bound/content_file', 'change in bound\n')])
538
self.build_tree_contents([('bound/content_file', b'change in bound\n')])
540
540
# before #34959 was fixed, this failed with 'revision not present in
541
541
# weave' when trying to implicitly push from the bound branch to the master
581
581
other_tree.remove(['dirtoremove', 'filetoremove'])
582
582
self.build_tree_contents([
583
583
('other/newdir/', ),
584
('other/filetomodify', 'new content'),
585
('other/newfile', 'new file content')])
584
('other/filetomodify', b'new content'),
585
('other/newfile', b'new file content')])
586
586
other_tree.add('newfile')
587
587
other_tree.add('newdir/')
588
588
other_tree.commit('modify all sample files and dirs.')
658
658
self.requireFeature(SymlinkFeature)
659
659
tree = self.make_branch_and_tree('.')
660
660
os.symlink('target', 'name')
661
tree.add('name', 'a-file-id')
661
tree.add('name', b'a-file-id')
662
662
tree.commit('Added a symlink')
663
663
self.assertBasisTreeKind('symlink', tree, 'name')
832
832
# make_branch_and_tree ignores shared repos
833
833
branch = controldir.ControlDir.create_branch_convenience('repo/branch')
834
834
tree2 = branch.create_checkout('repo/tree2')
835
tree2.commit('message', rev_id='rev1')
835
tree2.commit('message', rev_id=b'rev1')
836
836
self.assertTrue(tree2.branch.repository.has_revision('rev1'))