/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionspec.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import datetime
18
18
import os
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):
276
301
        """Old revno:N:path tests"""
277
302
        wta = self.make_branch_and_tree('a')
278
303
        ba = wta.branch
279
 
        
 
304
 
280
305
        wta.commit('Commit one', rev_id='a@r-0-1')
281
306
        wta.commit('Commit two', rev_id='a@r-0-2')
282
307
        wta.commit('Commit three', rev_id='a@r-0-3')
324
349
 
325
350
 
326
351
class TestRevisionSpec_revid(TestRevisionSpec):
327
 
    
 
352
 
328
353
    def test_in_history(self):
329
354
        # We should be able to access revisions that are directly
330
355
        # in the history.
331
356
        self.assertInHistoryIs(1, 'r1', 'revid:r1')
332
357
        self.assertInHistoryIs(2, 'r2', 'revid:r2')
333
 
        
 
358
 
334
359
    def test_missing(self):
335
360
        self.assertInvalid('revid:r3', invalid_as_revision_id=False)
336
361
 
437
462
 
438
463
 
439
464
class TestRevisionSpec_tag(TestRevisionSpec):
440
 
    
 
465
 
441
466
    def make_branch_and_tree(self, relpath):
442
467
        # override format as the default one may not support tags
443
468
        return TestRevisionSpec.make_branch_and_tree(
509
534
 
510
535
 
511
536
class TestRevisionSpec_ancestor(TestRevisionSpec):
512
 
    
 
537
 
513
538
    def test_non_exact_branch(self):
514
539
        # It seems better to require an exact path to the branch
515
540
        # Branch.open() rather than using Branch.open_containing()
545
570
        self.assertRaises(errors.NoCommits,
546
571
                          spec_in_history, 'ancestor:new_tree',
547
572
                                           self.tree.branch)
548
 
                        
 
573
 
549
574
        self.assertRaises(errors.NoCommits,
550
575
                          spec_in_history, 'ancestor:tree',
551
576
                                           new_tree.branch)
566
591
 
567
592
 
568
593
class TestRevisionSpec_branch(TestRevisionSpec):
569
 
    
 
594
 
570
595
    def test_non_exact_branch(self):
571
596
        # It seems better to require an exact path to the branch
572
597
        # Branch.open() rather than using Branch.open_containing()