1
# Copyright (C) 2004, 2005, 2006 by Canonical Ltd
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
from bzrlib.builtins import merge
25
from bzrlib.tests import TestCaseWithTransport
26
from bzrlib.revisionspec import RevisionSpec
25
from bzrlib.tests import TestCase, TestCaseWithTransport
26
from bzrlib.revisionspec import RevisionSpec, RevisionSpec_revno
29
29
def spec_in_history(spec, branch):
38
38
super(TestRevisionSpec, self).setUp()
39
# this sets up a revision graph:
40
44
self.tree = self.make_branch_and_tree('tree')
41
45
self.build_tree(['tree/a'])
90
94
RevisionSpec.from_string, '123a')
98
class TestRevnoFromString(TestCase):
100
def test_from_string_dotted_decimal(self):
101
self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '-1.1')
102
self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '.1')
103
self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1..1')
104
self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1.2..1')
105
self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1.')
106
self.assertIsInstance(RevisionSpec.from_string('1.1'), RevisionSpec_revno)
107
self.assertIsInstance(RevisionSpec.from_string('1.1.3'), RevisionSpec_revno)
93
110
class TestRevisionSpec_revno(TestRevisionSpec):
95
112
def test_positive_int(self):
96
113
self.assertInHistoryIs(0, None, '0')
97
114
self.assertInHistoryIs(1, 'r1', '1')
98
115
self.assertInHistoryIs(2, 'r2', '2')
100
116
self.assertInvalid('3')
118
def test_dotted_decimal(self):
119
self.assertInHistoryIs(None, 'alt_r2', '1.1.1')
102
121
def test_negative_int(self):
103
122
self.assertInHistoryIs(2, 'r2', '-1')
104
123
self.assertInHistoryIs(1, 'r1', '-2')