~parthm/bzr/no-chown-if-bzrlog-exists

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_tags.py

(Jelmer) Add 'automatic_tag_name' hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for commands related to tags"""
18
18
 
19
 
from bzrlib import bzrdir
 
19
from bzrlib import (
 
20
    bzrdir,
 
21
    tag,
 
22
    )
20
23
from bzrlib.branch import (
21
24
    Branch,
22
25
    )
47
50
        self.assertContainsRe(err,
48
51
            "Tags can only be placed on a single revision")
49
52
 
 
53
    def test_no_tag_name(self):
 
54
        out, err = self.run_bzr('tag -d branch', retcode=3)
 
55
        self.assertContainsRe(err, 'Please specify a tag name.')
 
56
 
 
57
    def test_automatic_tag_name(self):
 
58
        def get_tag_name(branch, revid):
 
59
            return "mytag"
 
60
        Branch.hooks.install_named_hook('automatic_tag_name',
 
61
            get_tag_name, 'get tag name')
 
62
        out, err = self.run_bzr('tag -d branch')
 
63
        self.assertContainsRe(out, 'Created tag mytag.')
 
64
 
50
65
    def test_tag_current_rev(self):
51
66
        t = self.make_branch_and_tree('branch')
52
67
        t.commit(allow_pointless=True, message='initial commit',
73
88
        # ... but can if you use --force
74
89
        out, err = self.run_bzr('tag -d branch NEWTAG --force')
75
90
 
 
91
    def test_tag_delete_requires_name(self):
 
92
        out, err = self.run_bzr('tag -d branch', retcode=3)
 
93
        self.assertContainsRe(err, 'Please specify a tag name\\.')
 
94
 
76
95
    def test_branch_push_pull_merge_copies_tags(self):
77
96
        t = self.make_branch_and_tree('branch1')
78
97
        t.commit(allow_pointless=True, message='initial commit',