Rev 2226: Add tag -r option in file:///home/mbp/bzr/Work/tags/
Martin Pool
mbp at sourcefrog.net
Fri Jan 19 08:47:52 GMT 2007
------------------------------------------------------------
revno: 2226
revision-id: mbp at sourcefrog.net-20070119084751-zcoq7c4t7yockec1
parent: mbp at sourcefrog.net-20070119083251-tr6zsf024kckx3lb
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: tags
timestamp: Fri 2007-01-19 19:47:51 +1100
message:
Add tag -r option
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_tags.py test_tags.py-20070116132048-5h4qak2cm22jlb9e-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-01-19 02:46:50 +0000
+++ b/bzrlib/builtins.py 2007-01-19 08:47:51 +0000
@@ -3004,17 +3004,23 @@
short_name='d',
type=unicode,
),
+ 'revision',
]
- def run(self, tag_name, directory='.'):
+ def run(self, tag_name, directory='.', revision=None):
branch, relpath = Branch.open_containing(directory)
- revision_id = branch.last_revision()
+ if revision:
+ if len(revision) != 1:
+ raise errors.BzrCommandError(
+ "Tags can only be placed on a single revision, "
+ "not on a range")
+ revision_id = revision[0].in_history(branch).rev_id
+ else:
+ revision_id = branch.last_revision()
branch.repository.set_tag(tag_name, revision_id)
self.outf.write('created tag %s' % tag_name)
-
-
# command-line interpretation helper for merge-related commands
def _merge_helper(other_revision, base_revision,
check_clean=True, ignore_zero=False,
=== modified file 'bzrlib/tests/blackbox/test_tags.py'
--- a/bzrlib/tests/blackbox/test_tags.py 2007-01-16 13:21:38 +0000
+++ b/bzrlib/tests/blackbox/test_tags.py 2007-01-19 08:47:51 +0000
@@ -37,9 +37,12 @@
out, err = self.run_bzr_captured(['help', 'tag'])
self.assertContainsRe(out, 'Create a tag')
+ def test_cannot_tag_range(self):
+ out, err = self.run_bzr('tag', '-r1..10', 'name', retcode=3)
+ self.assertContainsRe(err,
+ "Tags can only be placed on a single revision")
+
def test_tag_current_rev(self):
- ## b = self.make_branch('branch')
- ## b.repository.tag
t = self.make_branch_and_tree('branch')
t.commit(allow_pointless=True, message='initial commit',
rev_id='first-revid')
@@ -49,3 +52,6 @@
# tag should be observable through the api
repo = t.branch.repository
self.assertEquals(repo.get_tag_dict(), dict(NEWTAG='first-revid'))
+ # can also create tags using -r
+ self.run_bzr('tag', '-d', 'branch', 'tag2', '-r1')
+ self.assertEquals(repo.lookup_tag('tag2'), 'first-revid')
More information about the bazaar-commits
mailing list