Add --verbose support to tags command.
authorOsku Salerma <osku@iki.fi>
Sun, 09 Dec 2007 17:14:38 +0900
changeset 5658 ae3089cefaab
parent 5657 47915bf68c44
child 5659 3da652f2039c
Add --verbose support to tags command.
mercurial/commands.py
tests/test-tags
tests/test-tags.out
--- a/mercurial/commands.py	Sun Dec 09 16:32:05 2007 +0900
+++ b/mercurial/commands.py	Sun Dec 09 17:14:38 2007 +0900
@@ -2458,23 +2458,33 @@
 
     List the repository tags.
 
-    This lists both regular and local tags.
+    This lists both regular and local tags. When the -v/--verbose switch
+    is used, a third column "local" is printed for local tags.
     """
 
     l = repo.tagslist()
     l.reverse()
     hexfunc = ui.debugflag and hex or short
+    tagtype = ""
+
     for t, n in l:
+        if ui.quiet:
+            ui.write("%s\n" % t)
+            continue
+
         try:
             hn = hexfunc(n)
-            r = "%5d:%s" % (repo.changelog.rev(n), hexfunc(n))
+            r = "%5d:%s" % (repo.changelog.rev(n), hn)
         except revlog.LookupError:
             r = "    ?:%s" % hn
-        if ui.quiet:
-            ui.write("%s\n" % t)
         else:
             spaces = " " * (30 - util.locallen(t))
-            ui.write("%s%s %s\n" % (t, spaces, r))
+            if ui.verbose:
+                if repo.tagtype(t) == 'local':
+                    tagtype = " local"
+                else:
+                    tagtype = ""
+            ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
 
 def tip(ui, repo, **opts):
     """show the tip revision
--- a/tests/test-tags	Sun Dec 09 16:32:05 2007 +0900
+++ b/tests/test-tags	Sun Dec 09 17:14:38 2007 +0900
@@ -142,4 +142,5 @@
 
 hg tag -r 0 globaltag
 hg tag --remove -l globaltag
+hg tags -v
 exit 0
--- a/tests/test-tags.out	Sun Dec 09 16:32:05 2007 +0900
+++ b/tests/test-tags.out	Sun Dec 09 17:14:38 2007 +0900
@@ -74,3 +74,6 @@
 adding foo
 abort: localtag tag is local
 abort: globaltag tag is global
+tip                                1:a0b6fe111088
+localtag                           0:bbd179dfa0a7 local
+globaltag                          0:bbd179dfa0a7