~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: 2008-09-09 15:09:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3699.
  • Revision ID: john@arbash-meinel.com-20080909150912-wyttm8he1zsls2ck
Use the right timing function on win32

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import datetime
18
18
import os
23
23
    bzrdir,
24
24
    errors,
25
25
    repository,
26
 
    revision as _mod_revision,
27
26
    )
28
27
from bzrlib.tests import TestCase, TestCaseWithTransport
29
28
from bzrlib.revisionspec import (
101
100
        self.assertEqual(revision_id,
102
101
                         spec.as_revision_id(self.tree.branch))
103
102
 
104
 
    def get_as_tree(self, revision_spec, tree=None):
105
 
        if tree is None:
106
 
            tree = self.tree
107
 
        spec = RevisionSpec.from_string(revision_spec)
108
 
        return spec.as_tree(tree.branch)
109
 
 
110
103
 
111
104
class RevisionSpecMatchOnTrap(RevisionSpec):
112
105
 
176
169
 
177
170
    def test_dotted_decimal(self):
178
171
        self.assertInHistoryIs(None, 'alt_r2', '1.1.1')
179
 
        self.assertInvalid('1.1.123')
180
172
 
181
173
    def test_negative_int(self):
182
174
        self.assertInHistoryIs(2, 'r2', '-1')
276
268
        """Old revno:N:path tests"""
277
269
        wta = self.make_branch_and_tree('a')
278
270
        ba = wta.branch
279
 
 
 
271
        
280
272
        wta.commit('Commit one', rev_id='a@r-0-1')
281
273
        wta.commit('Commit two', rev_id='a@r-0-2')
282
274
        wta.commit('Commit three', rev_id='a@r-0-3')
308
300
        self.assertAsRevisionId('r2', '-1')
309
301
        self.assertAsRevisionId('alt_r2', '1.1.1')
310
302
 
311
 
    def test_as_tree(self):
312
 
        tree = self.get_as_tree('0')
313
 
        self.assertEquals(_mod_revision.NULL_REVISION, tree.get_revision_id())
314
 
        tree = self.get_as_tree('1')
315
 
        self.assertEquals('r1', tree.get_revision_id())
316
 
        tree = self.get_as_tree('2')
317
 
        self.assertEquals('r2', tree.get_revision_id())
318
 
        tree = self.get_as_tree('-2')
319
 
        self.assertEquals('r1', tree.get_revision_id())
320
 
        tree = self.get_as_tree('-1')
321
 
        self.assertEquals('r2', tree.get_revision_id())
322
 
        tree = self.get_as_tree('1.1.1')
323
 
        self.assertEquals('alt_r2', tree.get_revision_id())
324
 
 
325
303
 
326
304
class TestRevisionSpec_revid(TestRevisionSpec):
327
 
 
 
305
    
328
306
    def test_in_history(self):
329
307
        # We should be able to access revisions that are directly
330
308
        # in the history.
331
309
        self.assertInHistoryIs(1, 'r1', 'revid:r1')
332
310
        self.assertInHistoryIs(2, 'r2', 'revid:r2')
333
 
 
 
311
        
334
312
    def test_missing(self):
335
313
        self.assertInvalid('revid:r3', invalid_as_revision_id=False)
336
314
 
437
415
 
438
416
 
439
417
class TestRevisionSpec_tag(TestRevisionSpec):
440
 
 
 
418
    
441
419
    def make_branch_and_tree(self, relpath):
442
420
        # override format as the default one may not support tags
443
421
        return TestRevisionSpec.make_branch_and_tree(
509
487
 
510
488
 
511
489
class TestRevisionSpec_ancestor(TestRevisionSpec):
512
 
 
 
490
    
513
491
    def test_non_exact_branch(self):
514
492
        # It seems better to require an exact path to the branch
515
493
        # Branch.open() rather than using Branch.open_containing()
545
523
        self.assertRaises(errors.NoCommits,
546
524
                          spec_in_history, 'ancestor:new_tree',
547
525
                                           self.tree.branch)
548
 
 
 
526
                        
549
527
        self.assertRaises(errors.NoCommits,
550
528
                          spec_in_history, 'ancestor:tree',
551
529
                                           new_tree.branch)
553
531
    def test_as_revision_id(self):
554
532
        self.assertAsRevisionId('alt_r2', 'ancestor:tree2')
555
533
 
556
 
    def test_default(self):
557
 
        # We don't have a parent to default to
558
 
        self.assertRaises(errors.NotBranchError, self.get_in_history,
559
 
                          'ancestor:')
560
 
 
561
 
        # Create a branch with a parent to default to
562
 
        tree3 = self.tree.bzrdir.sprout('tree3').open_workingtree()
563
 
        tree3.commit('foo', rev_id='r3')
564
 
        self.tree = tree3
565
 
        self.assertInHistoryIs(2, 'r2', 'ancestor:')
566
 
 
567
534
 
568
535
class TestRevisionSpec_branch(TestRevisionSpec):
569
 
 
 
536
    
570
537
    def test_non_exact_branch(self):
571
538
        # It seems better to require an exact path to the branch
572
539
        # Branch.open() rather than using Branch.open_containing()
597
564
        new_tree = self.make_branch_and_tree('new_tree')
598
565
        self.assertRaises(errors.NoCommits,
599
566
                          self.get_in_history, 'branch:new_tree')
600
 
        self.assertRaises(errors.NoCommits,
601
 
                          self.get_as_tree, 'branch:new_tree')
602
567
 
603
568
    def test_as_revision_id(self):
604
569
        self.assertAsRevisionId('alt_r2', 'branch:tree2')
605
570
 
606
 
    def test_as_tree(self):
607
 
        tree = self.get_as_tree('branch:tree', self.tree2)
608
 
        self.assertEquals('r2', tree.get_revision_id())
609
 
        self.assertFalse(self.tree2.branch.repository.has_revision('r2'))
610
 
 
611
571
 
612
572
class TestRevisionSpec_submit(TestRevisionSpec):
613
573