Rev 2244: Add tags command in http://sourcefrog.net/bzr/tags

Martin Pool mbp at sourcefrog.net
Wed Feb 21 05:08:28 GMT 2007


At http://sourcefrog.net/bzr/tags

------------------------------------------------------------
revno: 2244
revision-id: mbp at sourcefrog.net-20070221050828-yqvr0i3if980i8sy
parent: mbp at sourcefrog.net-20070221050651-2if33edbetuiv2vf
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: tags
timestamp: Wed 2007-02-21 16:08:28 +1100
message:
  Add tags command
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-02-21 04:08:27 +0000
+++ b/bzrlib/builtins.py	2007-02-21 05:08:28 +0000
@@ -3203,6 +3203,29 @@
             self.outf.write('created tag %s' % tag_name)
 
 
+class cmd_tags(Command):
+    """List tags.
+
+    This tag shows a table of tag names and the revisions they reference.
+    """
+
+    takes_options = [
+        Option('directory',
+            help='Branch whose tags should be displayed',
+            short_name='d',
+            type=unicode,
+            ),
+    ]
+
+    @display_command
+    def run(self,
+            directory='.',
+            ):
+        branch, relpath = Branch.open_containing(directory)
+        for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
+            self.outf.write('%-40s %s' % (tag_name, target))
+
+
 # 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-02-21 04:08:27 +0000
+++ b/bzrlib/tests/blackbox/test_tags.py	2007-02-21 05:08:28 +0000
@@ -93,3 +93,12 @@
         b1.tags.set_tag('tag4', 'second-revid')
         self.run_bzr('merge', '-d', 'branch2', 'branch1')
         self.assertEquals(b2.tags.lookup_tag('tag4'), 'second-revid')
+
+    def test_list_tags(self):
+        t = self.make_branch_and_tree('branch1')
+        b1 = t.branch
+        tagname = u'\u30d0zaar'
+        b1.tags.set_tag(tagname, 'revid-1')
+        out, err = self.run_bzr('tags', '-d', 'branch1')
+        self.assertEquals(err, '')
+




More information about the bazaar-commits mailing list