652
652
def test_as_revision_id(self):
653
653
self.tree.branch.set_submit_branch('tree2')
654
654
self.assertAsRevisionId('alt_r2', 'branch:tree2')
657
class TestRevisionSpec_mainline(TestRevisionSpec):
659
def test_as_revision_id(self):
660
self.assertAsRevisionId('r1', 'mainline:1')
661
self.assertAsRevisionId('r2', 'mainline:1.1.1')
662
self.assertAsRevisionId('r2', 'mainline:revid:alt_r2')
663
spec = RevisionSpec.from_string('mainline:revid:alt_r22')
664
e = self.assertRaises(errors.InvalidRevisionSpec,
665
spec.as_revision_id, self.tree.branch)
666
self.assertContainsRe(str(e),
667
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
670
def test_in_history(self):
671
self.assertInHistoryIs(2, 'r2', 'mainline:revid:alt_r2')
674
class TestRevisionSpec_annotate(TestRevisionSpec):
677
TestRevisionSpec.setUp(self)
678
self.tree = self.make_branch_and_tree('annotate-tree')
679
self.build_tree_contents([('annotate-tree/file1', '1\n')])
680
self.tree.add('file1')
681
self.tree.commit('r1', rev_id='r1')
682
self.build_tree_contents([('annotate-tree/file1', '2\n1\n')])
683
self.tree.commit('r2', rev_id='r2')
684
self.build_tree_contents([('annotate-tree/file1', '2\n1\n3\n')])
686
def test_as_revision_id_r1(self):
687
self.assertAsRevisionId('r1', 'annotate:annotate-tree/file1:2')
689
def test_as_revision_id_r2(self):
690
self.assertAsRevisionId('r2', 'annotate:annotate-tree/file1:1')
692
def test_as_revision_id_uncommitted(self):
693
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:3')
694
e = self.assertRaises(errors.InvalidRevisionSpec,
695
spec.as_revision_id, self.tree.branch)
696
self.assertContainsRe(str(e),
697
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
698
" exist in branch: .*\nLine 3 has not been committed.")
700
def test_non_existent_line(self):
701
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:4')
702
e = self.assertRaises(errors.InvalidRevisionSpec,
703
spec.as_revision_id, self.tree.branch)
704
self.assertContainsRe(str(e),
705
r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
706
" exist in branch: .*\nNo such line: 4")
708
def test_invalid_line(self):
709
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q')
710
e = self.assertRaises(errors.InvalidRevisionSpec,
711
spec.as_revision_id, self.tree.branch)
712
self.assertContainsRe(str(e),
713
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
714
" exist in branch: .*\nNo such line: q")
716
def test_no_such_file(self):
717
spec = RevisionSpec.from_string('annotate:annotate-tree/file2:1')
718
e = self.assertRaises(errors.InvalidRevisionSpec,
719
spec.as_revision_id, self.tree.branch)
720
self.assertContainsRe(str(e),
721
r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
722
" exist in branch: .*\nFile 'file2' is not versioned")
724
def test_no_such_file_with_colon(self):
725
spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1')
726
e = self.assertRaises(errors.InvalidRevisionSpec,
727
spec.as_revision_id, self.tree.branch)
728
self.assertContainsRe(str(e),
729
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
730
" exist in branch: .*\nFile 'fi:le2' is not versioned")