diff mercurial/commands.py @ 343:d7df759d0e97

rework all code using tags -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 rework all code using tags Add three utility functions: tags(): get (and possibly load) the tags mapping tagslist(): sort tag,node by revision (aka topologically) nodetags(): return a list of tags associated with a node (also cached) Update all the code using tags to use these. Simplify identify code make unknown always visible if printed don't ignore tip pseudo-tag manifest hash: e6deb4d545ad465be7735f9ec43227bcb5e238c7 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCr+HjywK+sNU5EO8RAh4/AJ90cI0WxmvQAj6Lq2ZiG8LmqZan/QCfR8B5 ltu8tOIEHDa8LhfS9wtBu0k= =pv3t -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 15 Jun 2005 00:08:03 -0800
parents 97a897d32dfc
children b4e0e20646bb
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 15 00:03:25 2005 -0800
+++ b/mercurial/commands.py	Wed Jun 15 00:08:03 2005 -0800
@@ -126,18 +126,6 @@
             ui.status("summary:     %s\n" % description[0])
     ui.status("\n")
 
-def tags_load(repo):
-    repo.lookup(0) # prime the cache
-    i = repo.tags.items()
-    n = []
-    for e in i:
-        try:
-            l = repo.changelog.rev(e[1])
-        except KeyError:
-            l = -2
-        n.append((l, e))
-    return n
-
 def help(ui, cmd=None):
     '''show help for a given command or all commands'''
     if cmd:
@@ -328,17 +316,15 @@
     """print information about the working copy"""
     (c, a, d, u) = repo.diffdir(repo.root)
     mflag = (c or a or d or u) and "+" or ""
-    parents = [parent for parent in repo.dirstate.parents()
-                      if parent != hg.nullid]
+    parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
     if not parents:
-        ui.note("unknown\n")
+        ui.write("unknown\n")
         return
 
     tstring = ''
     if not ui.quiet:
-        taglist = [e[1] for e in tags_load(repo)]
-        tstring = " %s" % ' + '.join([e[0] for e in taglist
-                                      if e[0] != 'tip' and e[1] in parents])
+        tags = sum(map(repo.nodetags, parents), [])
+        tstring = " " + ' + '.join(tags)
 
     hexfunc = ui.verbose and hg.hex or hg.short
     pstring = '+'.join([hexfunc(parent) for parent in parents])
@@ -544,17 +530,15 @@
 
 def tags(ui, repo):
     """list repository tags"""
-    n = tags_load(repo)
-
-    n.sort()
-    n.reverse()
-    i = [ e[1] for e in n ]
-    for k, n in i:
+    
+    l = repo.tagslist()
+    l.reverse()
+    for t,n in l:
         try:
             r = repo.changelog.rev(n)
         except KeyError:
             r = "?"
-        print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n))
+        print "%-30s %5d:%s" % (t, repo.changelog.rev(n), hg.hex(n))
 
 def tip(ui, repo):
     """show the tip revision"""