~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionnamespaces.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-31 21:29:02 UTC
  • mfrom: (2104 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2110.
  • Revision ID: john@arbash-meinel.com-20061031212902-4b33920b90e9ce92
[merge] bzr.dev 2104

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
2
2
#
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
22
22
    errors,
23
23
    )
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
27
27
 
28
28
 
29
29
def spec_in_history(spec, branch):
36
36
 
37
37
    def setUp(self):
38
38
        super(TestRevisionSpec, self).setUp()
 
39
        # this sets up a revision graph:
 
40
        # r1: []             1
 
41
        # alt_r2: [r1]       1.1.1
 
42
        # r2: [r1, alt_r2]   2
39
43
 
40
44
        self.tree = self.make_branch_and_tree('tree')
41
45
        self.build_tree(['tree/a'])
90
94
                          RevisionSpec.from_string, '123a')
91
95
 
92
96
 
 
97
 
 
98
class TestRevnoFromString(TestCase):
 
99
 
 
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)
 
108
 
 
109
 
93
110
class TestRevisionSpec_revno(TestRevisionSpec):
94
111
 
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')
99
 
 
100
116
        self.assertInvalid('3')
101
117
 
 
118
    def test_dotted_decimal(self):
 
119
        self.assertInHistoryIs(None, 'alt_r2', '1.1.1')
 
120
 
102
121
    def test_negative_int(self):
103
122
        self.assertInHistoryIs(2, 'r2', '-1')
104
123
        self.assertInHistoryIs(1, 'r1', '-2')