~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionspec.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
146
146
    def test_object(self):
147
147
        self.assertRaises(TypeError, RevisionSpec.from_string, object())
148
148
 
149
 
    def test_unregistered_spec(self):
150
 
        self.assertRaises(errors.NoSuchRevisionSpec,
151
 
                          RevisionSpec.from_string, 'foo')
152
 
        self.assertRaises(errors.NoSuchRevisionSpec,
153
 
                          RevisionSpec.from_string, '123a')
154
 
 
155
 
 
156
 
 
157
 
class TestRevnoFromString(TestCase):
158
 
 
159
 
    def test_from_string_dotted_decimal(self):
160
 
        self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '-1.1')
161
 
        self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '.1')
162
 
        self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1..1')
163
 
        self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1.2..1')
164
 
        self.assertRaises(errors.NoSuchRevisionSpec, RevisionSpec.from_string, '1.')
165
 
        self.assertIsInstance(RevisionSpec.from_string('1.1'), RevisionSpec_revno)
166
 
        self.assertIsInstance(RevisionSpec.from_string('1.1.3'), RevisionSpec_revno)
 
149
 
 
150
class TestRevisionSpec_dwim(TestRevisionSpec):
 
151
 
 
152
    # Don't need to test revno's explicitly since TRS_revno already
 
153
    # covers that well for us
 
154
    def test_dwim_spec_revno(self):
 
155
        self.assertInHistoryIs(2, 'r2', '2')
 
156
        self.assertAsRevisionId('alt_r2', '1.1.1')
 
157
 
 
158
    def test_dwim_spec_revid(self):
 
159
        self.assertInHistoryIs(2, 'r2', 'r2')
 
160
 
 
161
    def test_dwim_spec_tag(self):
 
162
        self.tree.branch.tags.set_tag('footag', 'r1')
 
163
        self.assertAsRevisionId('r1', 'footag')
 
164
        self.tree.branch.tags.delete_tag('footag')
 
165
        self.assertRaises(errors.InvalidRevisionSpec,
 
166
                          self.get_in_history, 'footag')
 
167
 
 
168
    def test_dwim_spec_tag_that_looks_like_revno(self):
 
169
        # Test that we slip past revno with things that look like revnos,
 
170
        # but aren't.  Tags are convenient for testing this since we can
 
171
        # make them look however we want.
 
172
        self.tree.branch.tags.set_tag('3', 'r2')
 
173
        self.assertAsRevisionId('r2', '3')
 
174
        self.build_tree(['tree/b'])
 
175
        self.tree.add(['b'])
 
176
        self.tree.commit('b', rev_id='r3')
 
177
        self.assertAsRevisionId('r3', '3')
 
178
 
 
179
    def test_dwim_spec_date(self):
 
180
        self.assertAsRevisionId('r1', 'today')
 
181
 
 
182
    def test_dwim_spec_branch(self):
 
183
        self.assertInHistoryIs(None, 'alt_r2', 'tree2')
 
184
 
 
185
    def test_dwim_spec_nonexistent(self):
 
186
        self.assertInvalid('somethingrandom', invalid_as_revision_id=False)
 
187
        self.assertInvalid('-1.1', invalid_as_revision_id=False)
 
188
        self.assertInvalid('.1', invalid_as_revision_id=False)
 
189
        self.assertInvalid('1..1', invalid_as_revision_id=False)
 
190
        self.assertInvalid('1.2..1', invalid_as_revision_id=False)
 
191
        self.assertInvalid('1.', invalid_as_revision_id=False)
167
192
 
168
193
 
169
194
class TestRevisionSpec_revno(TestRevisionSpec):