~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionspec.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

Show diffs side-by-side

added added

removed removed

Lines of Context:
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')
 
655
 
 
656
 
 
657
class TestRevisionSpec_mainline(TestRevisionSpec):
 
658
 
 
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"
 
668
            " branch: ")
 
669
 
 
670
    def test_in_history(self):
 
671
        self.assertInHistoryIs(2, 'r2', 'mainline:revid:alt_r2')
 
672
 
 
673
 
 
674
class TestRevisionSpec_annotate(TestRevisionSpec):
 
675
 
 
676
    def setUp(self):
 
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')])
 
685
 
 
686
    def test_as_revision_id_r1(self):
 
687
        self.assertAsRevisionId('r1', 'annotate:annotate-tree/file1:2')
 
688
 
 
689
    def test_as_revision_id_r2(self):
 
690
        self.assertAsRevisionId('r2', 'annotate:annotate-tree/file1:1')
 
691
 
 
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.")
 
699
 
 
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")
 
707
 
 
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")
 
715
 
 
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")
 
723
 
 
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")