/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_revisionnamespaces.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-28 16:19:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1979.
  • Revision ID: john@arbash-meinel.com-20060828161947-5986ffb6cf082f59
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    )
24
24
from bzrlib.builtins import merge
25
25
from bzrlib.tests import TestCaseWithTransport
26
 
from bzrlib.revisionspec import get_revision_spec
 
26
from bzrlib.revisionspec import RevisionSpec
 
27
 
 
28
 
 
29
def spec_in_history(spec, branch):
 
30
    """A simple helper to change a revision spec into a branch search"""
 
31
    return RevisionSpec.from_string(spec).in_history(branch)
27
32
 
28
33
 
29
34
# Basic class, which just creates a really basic set of revisions
46
51
        self.tree.commit('second', rev_id='r2')
47
52
 
48
53
    def get_in_history(self, revision_spec):
49
 
        return get_revision_spec(revision_spec).in_history(self.tree.branch)
 
54
        return spec_in_history(revision_spec, self.tree.branch)
50
55
 
51
56
    def assertInHistoryIs(self, exp_revno, exp_revision_id, revision_spec):
52
57
        rev_info = self.get_in_history(revision_spec)
76
81
        self.assertInHistoryIs(0, None, None)
77
82
 
78
83
    def test_object(self):
79
 
        self.assertRaises(TypeError, get_revision_spec, object())
 
84
        self.assertRaises(TypeError, RevisionSpec.from_string, object())
80
85
 
81
86
    def test_unregistered_spec(self):
82
 
        self.assertRaises(errors.NoSuchRevisionSpec, get_revision_spec, 'foo')
83
 
        self.assertRaises(errors.NoSuchRevisionSpec, get_revision_spec, '123a')
 
87
        self.assertRaises(errors.NoSuchRevisionSpec,
 
88
                          RevisionSpec.from_string, 'foo')
 
89
        self.assertRaises(errors.NoSuchRevisionSpec,
 
90
                          RevisionSpec.from_string, '123a')
84
91
 
85
92
 
86
93
class TestRevisionSpec_revno(TestRevisionSpec):
136
143
    def test_non_exact_branch(self):
137
144
        # It seems better to require an exact path to the branch
138
145
        # Branch.open() rather than using Branch.open_containing()
 
146
        spec = RevisionSpec.from_string('revno:2:tree2/a')
139
147
        self.assertRaises(errors.NotBranchError,
140
 
                          get_revision_spec('revno:2:tree2/a').in_history,
141
 
                          self.tree.branch)
 
148
                          spec.in_history, self.tree.branch)
142
149
 
143
150
    def test_with_branch(self):
144
151
        # Passing a URL overrides the supplied branch path
202
209
        wtb.commit('Commit two', rev_id='b@r-0-2')
203
210
        wtb.commit('Commit three', rev_id='b@r-0-3')
204
211
 
205
 
        self.assertEqual(get_revision_spec('revno:1:a/').in_history(ba),
206
 
                         (1, 'a@r-0-1'))
 
212
 
 
213
        self.assertEqual((1, 'a@r-0-1'),
 
214
                         spec_in_history('revno:1:a/', ba))
207
215
        # The argument of in_history should be ignored since it is
208
216
        # redundant with the path in the spec.
209
 
        self.assertEqual(get_revision_spec('revno:1:a/').in_history(None),
210
 
                         (1, 'a@r-0-1'))
211
 
        self.assertEqual(get_revision_spec('revno:1:a/').in_history(bb),
212
 
                         (1, 'a@r-0-1'))
213
 
        self.assertEqual(get_revision_spec('revno:2:b/').in_history(None),
214
 
                         (2, 'b@r-0-2'))
 
217
        self.assertEqual((1, 'a@r-0-1'),
 
218
                         spec_in_history('revno:1:a/', None))
 
219
        self.assertEqual((1, 'a@r-0-1'),
 
220
                         spec_in_history('revno:1:a/', bb))
 
221
        self.assertEqual((2, 'b@r-0-2'),
 
222
                         spec_in_history('revno:2:b/', None))
215
223
 
216
224
 
217
225
 
265
273
        tree = self.make_branch_and_tree('tree3')
266
274
 
267
275
        self.assertRaises(errors.NoCommits,
268
 
                          get_revision_spec('last:').in_history, tree.branch)
 
276
                          spec_in_history, 'last:', tree.branch)
269
277
 
270
278
    def test_not_a_number(self):
271
279
        try:
355
363
        # It seems better to require an exact path to the branch
356
364
        # Branch.open() rather than using Branch.open_containing()
357
365
        self.assertRaises(errors.NotBranchError,
358
 
                          get_revision_spec('ancestor:tree2/a').in_history,
359
 
                          self.tree.branch)
 
366
                          self.get_in_history, 'ancestor:tree2/a')
360
367
 
361
368
    def test_simple(self):
362
369
        # Common ancestor of trees is 'alt_r2'
380
387
 
381
388
        # With no common ancestor, we should raise another user error
382
389
        self.assertRaises(errors.NoCommonAncestor,
383
 
                          get_revision_spec('ancestor:new_tree').in_history,
384
 
                          self.tree.branch)
 
390
                          self.get_in_history, 'ancestor:new_tree')
385
391
 
386
392
    def test_no_commits(self):
387
393
        new_tree = self.make_branch_and_tree('new_tree')
388
394
        self.assertRaises(errors.NoCommits,
389
 
                          get_revision_spec('ancestor:new_tree').in_history,
390
 
                          self.tree.branch)
 
395
                          spec_in_history, 'ancestor:new_tree',
 
396
                                           self.tree.branch)
391
397
                        
392
398
        self.assertRaises(errors.NoCommits,
393
 
                          get_revision_spec('ancestor:tree').in_history,
394
 
                          new_tree.branch)
 
399
                          spec_in_history, 'ancestor:tree',
 
400
                                           new_tree.branch)
395
401
 
396
402
 
397
403
class TestRevisionSpec_branch(TestRevisionSpec):
400
406
        # It seems better to require an exact path to the branch
401
407
        # Branch.open() rather than using Branch.open_containing()
402
408
        self.assertRaises(errors.NotBranchError,
403
 
                          get_revision_spec('branch:tree2/a').in_history,
404
 
                          self.tree.branch)
 
409
                          self.get_in_history, 'branch:tree2/a')
405
410
 
406
411
    def test_simple(self):
407
412
        self.assertInHistoryIs(None, 'alt_r2', 'branch:tree2')
426
431
    def test_no_commits(self):
427
432
        new_tree = self.make_branch_and_tree('new_tree')
428
433
        self.assertRaises(errors.NoCommits,
429
 
                          get_revision_spec('branch:new_tree').in_history,
430
 
                          self.tree.branch)
 
434
                          self.get_in_history, 'branch:new_tree')