1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
1
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
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
21
21
from bzrlib import (
24
27
from bzrlib.builtins import merge
25
28
from bzrlib.tests import TestCase, TestCaseWithTransport
26
from bzrlib.revisionspec import RevisionSpec, RevisionSpec_revno
29
from bzrlib.revisionspec import (
29
36
def spec_in_history(spec, branch):
336
343
class TestRevisionSpec_tag(TestRevisionSpec):
338
def test_invalid(self):
339
self.assertInvalid('tag:foo', extra='\ntag: namespace registered,'
340
' but not implemented')
345
def make_branch_and_tree(self, relpath):
346
# override format as the default one may not support tags
347
control = bzrdir.BzrDir.create(relpath)
348
control.create_repository()
349
branch.BzrBranchExperimental.initialize(control)
350
return control.create_workingtree()
352
def test_from_string_tag(self):
353
spec = RevisionSpec.from_string('tag:bzr-0.14')
354
self.assertIsInstance(spec, RevisionSpec_tag)
355
self.assertEqual(spec.spec, 'bzr-0.14')
357
def test_lookup_tag(self):
358
self.tree.branch.tags.set_tag('bzr-0.14', 'r1')
359
self.assertInHistoryIs(1, 'r1', 'tag:bzr-0.14')
361
def test_failed_lookup(self):
362
# tags that don't exist give a specific message: arguably we should
363
# just give InvalidRevisionSpec but I think this is more helpful
364
self.assertRaises(errors.NoSuchTag,
366
'tag:some-random-tag')
343
369
class TestRevisionSpec_date(TestRevisionSpec):