3182
3182
Tags are stored in the branch. Tags are copied from one branch to another
3183
3183
along when you branch, push, pull or merge.
3185
It is an error to give a tag name that already exists unless you pass
3186
--force, in which case the tag is moved to point to the new revision.
3186
3189
takes_args = ['tag_name']
3187
3190
takes_options = [
3189
help='branch in which to place the tag',
3193
3191
Option('delete',
3194
help='Delete this tag rather than placing it',
3192
help='Delete this tag rather than placing it.',
3195
help='Branch in which to place the tag.',
3200
help='Replace existing tags',
3199
def run(self, tag_name, directory='.',
3205
def run(self, tag_name,
3202
3211
branch, relpath = Branch.open_containing(directory)
3204
branch.tags.delete_tag(tag_name)
3205
self.outf.write('deleted tag %s' % tag_name)
3208
if len(revision) != 1:
3209
raise errors.BzrCommandError(
3210
"Tags can only be placed on a single revision, "
3212
revision_id = revision[0].in_history(branch).rev_id
3215
branch.tags.delete_tag(tag_name)
3216
self.outf.write('Deleted tag %s.\n' % tag_name)
3214
revision_id = branch.last_revision()
3215
branch.tags.set_tag(tag_name, revision_id)
3216
self.outf.write('created tag %s' % tag_name)
3219
if len(revision) != 1:
3220
raise errors.BzrCommandError(
3221
"Tags can only be placed on a single revision, "
3223
revision_id = revision[0].in_history(branch).rev_id
3225
revision_id = branch.last_revision()
3226
if (not force) and branch.tags.has_tag(tag_name):
3227
raise errors.TagAlreadyExists(tag_name)
3228
branch.tags.set_tag(tag_name, revision_id)
3229
self.outf.write('Created tag %s.\n' % tag_name)
3219
3234
class cmd_tags(Command):