330
331
wtb.commit('Commit two', rev_id=b'b@r-0-2')
331
332
wtb.commit('Commit three', rev_id=b'b@r-0-3')
334
334
self.assertEqual((1, b'a@r-0-1'),
335
335
spec_in_history('revno:1:a/', ba))
336
336
# The argument of in_history should be ignored since it is
397
397
revision_id = u'\N{SNOWMAN}'.encode('utf-8')
398
398
self.tree.commit('unicode', rev_id=revision_id)
399
399
self.assertInHistoryIs(3, revision_id, u'revid:\N{SNOWMAN}')
400
self.assertInHistoryIs(3, revision_id, 'revid:' + revision_id.decode('utf-8'))
400
self.assertInHistoryIs(3, revision_id, 'revid:' +
401
revision_id.decode('utf-8'))
402
403
def test_as_revision_id(self):
403
404
self.assertAsRevisionId(b'r1', 'revid:r1')
518
519
new_tree = self.make_branch_and_tree('new_tree')
519
520
new_tree.commit('Commit one', rev_id=b'new_r1',
520
timestamp=time.time() - 60*60*24)
521
timestamp=time.time() - 60 * 60 * 24)
521
522
new_tree.commit('Commit two', rev_id=b'new_r2')
522
523
new_tree.commit('Commit three', rev_id=b'new_r3')
543
544
def test_day(self):
544
545
now = datetime.datetime.now()
545
546
self.assertInHistoryIs(2, b'new_r2',
546
'date:%04d-%02d-%02d' % (now.year, now.month, now.day))
547
'date:%04d-%02d-%02d' % (now.year, now.month, now.day))
548
549
def test_as_revision_id(self):
549
550
self.assertAsRevisionId(b'new_r2', 'date:today')
635
636
self.assertTrue(self.tree.branch.repository.has_revision(b'new_r3'))
637
638
def test_no_commits(self):
638
new_tree = self.make_branch_and_tree('new_tree')
639
self.make_branch_and_tree('new_tree')
639
640
self.assertRaises(errors.NoCommits,
640
641
self.get_in_history, 'branch:new_tree')
641
642
self.assertRaises(errors.NoCommits,
660
661
self.assertInHistoryIs(None, b'alt_r2', 'submit:')
661
662
self.tree.branch.set_parent('bogus')
662
663
self.assertRaises(errors.NotBranchError, self.get_in_history,
664
665
# submit branch overrides parent branch
665
666
self.tree.branch.set_submit_branch('tree2')
666
667
self.assertInHistoryIs(None, b'alt_r2', 'submit:')
680
681
e = self.assertRaises(errors.InvalidRevisionSpec,
681
682
spec.as_revision_id, self.tree.branch)
682
683
self.assertContainsRe(str(e),
683
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
684
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
686
687
def test_in_history(self):
687
688
self.assertInHistoryIs(2, b'r2', 'mainline:revid:alt_r2')
710
711
e = self.assertRaises(errors.InvalidRevisionSpec,
711
712
spec.as_revision_id, self.tree.branch)
712
713
self.assertContainsRe(str(e),
713
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
714
" exist in branch: .*\nLine 3 has not been committed.")
714
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
715
" exist in branch: .*\nLine 3 has not been committed.")
716
717
def test_non_existent_line(self):
717
718
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:4')
718
719
e = self.assertRaises(errors.InvalidRevisionSpec,
719
720
spec.as_revision_id, self.tree.branch)
720
721
self.assertContainsRe(str(e),
721
r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
722
" exist in branch: .*\nNo such line: 4")
722
r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
723
" exist in branch: .*\nNo such line: 4")
724
725
def test_invalid_line(self):
725
726
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q')
726
727
e = self.assertRaises(errors.InvalidRevisionSpec,
727
728
spec.as_revision_id, self.tree.branch)
728
729
self.assertContainsRe(str(e),
729
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
730
" exist in branch: .*\nNo such line: q")
730
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
731
" exist in branch: .*\nNo such line: q")
732
733
def test_no_such_file(self):
733
734
spec = RevisionSpec.from_string('annotate:annotate-tree/file2:1')
734
735
e = self.assertRaises(errors.InvalidRevisionSpec,
735
736
spec.as_revision_id, self.tree.branch)
736
737
self.assertContainsRe(str(e),
737
r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
738
" exist in branch: .*\nFile 'file2' is not versioned")
738
r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
739
" exist in branch: .*\nFile 'file2' is not versioned")
740
741
def test_no_such_file_with_colon(self):
741
742
spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1')
742
743
e = self.assertRaises(errors.InvalidRevisionSpec,
743
744
spec.as_revision_id, self.tree.branch)
744
745
self.assertContainsRe(str(e),
745
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
746
" exist in branch: .*\nFile 'fi:le2' is not versioned")
746
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
747
" exist in branch: .*\nFile 'fi:le2' is not versioned")