identify: use contexts
authorMatt Mackall <mpm@selenic.com>
Thu, 21 Jun 2007 11:42:39 -0500
changeset 4664 dedb8abfd0e1
parent 4663 6b2e8cb39583
child 4665 091c9e54d306
identify: use contexts
mercurial/commands.py
--- a/mercurial/commands.py	Thu Jun 21 11:42:39 2007 -0500
+++ b/mercurial/commands.py	Thu Jun 21 11:42:39 2007 -0500
@@ -1442,28 +1442,24 @@
     in the working directory, followed by a list of tags for this revision.
     """
 
-    parents = [p for p in repo.dirstate.parents() if p != nullid]
-    if not parents:
-        parents = [nullid]
-
     hexfunc = ui.debugflag and hex or short
-    modified, added, removed, deleted = repo.status()[:4]
-    output = ["%s%s" %
-              ('+'.join([hexfunc(parent) for parent in parents]),
-              (modified or added or removed or deleted) and "+" or "")]
+
+    wctx = repo.workingctx()
+    parents = wctx.parents()
+    changed = wctx.files() + wctx.deleted()
+
+    output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
+                        (changed) and "+" or "")]
 
     if not ui.quiet:
-
-        branch = util.tolocal(repo.workingctx().branch())
+        branch = util.tolocal(wctx.branch())
         if branch != 'default':
             output.append("(%s)" % branch)
 
         # multiple tags for a single parent separated by '/'
-        parenttags = ['/'.join(tags)
-                      for tags in map(repo.nodetags, parents) if tags]
-        # tags for multiple parents separated by ' + '
-        if parenttags:
-            output.append(' + '.join(parenttags))
+        tags = "/".join(wctx.tags())
+        if tags:
+            output.append(tags)
 
     ui.write("%s\n" % ' '.join(output))