198
190
self.assertInvalid('1.2..1', invalid_as_revision_id=False)
199
191
self.assertInvalid('1.', invalid_as_revision_id=False)
201
def test_append_dwim_revspec(self):
202
original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
203
def reset_dwim_revspecs():
204
RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
205
self.addCleanup(reset_dwim_revspecs)
206
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_bork)
207
self.assertAsRevisionId('r1', 'bork')
209
def test_append_lazy_dwim_revspec(self):
210
original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
211
def reset_dwim_revspecs():
212
RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
213
self.addCleanup(reset_dwim_revspecs)
214
RevisionSpec_dwim.append_possible_lazy_revspec(
215
"bzrlib.tests.test_revisionspec", "RevisionSpec_bork")
216
self.assertAsRevisionId('r1', 'bork')
219
194
class TestRevisionSpec_revno(TestRevisionSpec):
675
652
def test_as_revision_id(self):
676
653
self.tree.branch.set_submit_branch('tree2')
677
654
self.assertAsRevisionId('alt_r2', 'branch:tree2')
680
class TestRevisionSpec_mainline(TestRevisionSpec):
682
def test_as_revision_id(self):
683
self.assertAsRevisionId('r1', 'mainline:1')
684
self.assertAsRevisionId('r2', 'mainline:1.1.1')
685
self.assertAsRevisionId('r2', 'mainline:revid:alt_r2')
686
spec = RevisionSpec.from_string('mainline:revid:alt_r22')
687
e = self.assertRaises(errors.InvalidRevisionSpec,
688
spec.as_revision_id, self.tree.branch)
689
self.assertContainsRe(str(e),
690
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
693
def test_in_history(self):
694
self.assertInHistoryIs(2, 'r2', 'mainline:revid:alt_r2')
697
class TestRevisionSpec_annotate(TestRevisionSpec):
700
TestRevisionSpec.setUp(self)
701
self.tree = self.make_branch_and_tree('annotate-tree')
702
self.build_tree_contents([('annotate-tree/file1', '1\n')])
703
self.tree.add('file1')
704
self.tree.commit('r1', rev_id='r1')
705
self.build_tree_contents([('annotate-tree/file1', '2\n1\n')])
706
self.tree.commit('r2', rev_id='r2')
707
self.build_tree_contents([('annotate-tree/file1', '2\n1\n3\n')])
709
def test_as_revision_id_r1(self):
710
self.assertAsRevisionId('r1', 'annotate:annotate-tree/file1:2')
712
def test_as_revision_id_r2(self):
713
self.assertAsRevisionId('r2', 'annotate:annotate-tree/file1:1')
715
def test_as_revision_id_uncommitted(self):
716
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:3')
717
e = self.assertRaises(errors.InvalidRevisionSpec,
718
spec.as_revision_id, self.tree.branch)
719
self.assertContainsRe(str(e),
720
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
721
" exist in branch: .*\nLine 3 has not been committed.")
723
def test_non_existent_line(self):
724
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:4')
725
e = self.assertRaises(errors.InvalidRevisionSpec,
726
spec.as_revision_id, self.tree.branch)
727
self.assertContainsRe(str(e),
728
r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
729
" exist in branch: .*\nNo such line: 4")
731
def test_invalid_line(self):
732
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q')
733
e = self.assertRaises(errors.InvalidRevisionSpec,
734
spec.as_revision_id, self.tree.branch)
735
self.assertContainsRe(str(e),
736
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
737
" exist in branch: .*\nNo such line: q")
739
def test_no_such_file(self):
740
spec = RevisionSpec.from_string('annotate:annotate-tree/file2:1')
741
e = self.assertRaises(errors.InvalidRevisionSpec,
742
spec.as_revision_id, self.tree.branch)
743
self.assertContainsRe(str(e),
744
r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
745
" exist in branch: .*\nFile 'file2' is not versioned")
747
def test_no_such_file_with_colon(self):
748
spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1')
749
e = self.assertRaises(errors.InvalidRevisionSpec,
750
spec.as_revision_id, self.tree.branch)
751
self.assertContainsRe(str(e),
752
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
753
" exist in branch: .*\nFile 'fi:le2' is not versioned")