[PATCH 1 of 2] identify: build the tag list directly instead of using wctx.tags()

Matt Harbison mharbison72 at gmail.com
Sun Jun 28 14:34:41 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435512137 14400
#      Sun Jun 28 13:22:17 2015 -0400
# Node ID 87c10f86c7517d0f8c42a080821c4b399d6f9755
# Parent  6368c51cfad6dc5f9c46369ed5e17cf8bd09efae
identify: build the tag list directly instead of using wctx.tags()

The current implementation of workingctx.tags() returns the tags of the parents.
This causes the calculation of {lastesttagdistance} from wdir() to be wrong.
The value when updated to a tag is 0, but updated to the tag's child is 2, the
child of that 3, and so on.  This prepares for workingctx.tags() to not report
the parent tags.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4067,6 +4067,10 @@
         if not rev:
             ctx = repo[None]
             parents = ctx.parents()
+            taglist = []
+            for p in parents:
+                taglist.extend(p.tags())
+
             changed = ""
             if default or id or num:
                 if (any(repo.status())
@@ -4084,6 +4088,7 @@
                 output = [hexfunc(ctx.node())]
             if num:
                 output.append(str(ctx.rev()))
+            taglist = ctx.tags()
 
         if default and not ui.quiet:
             b = ctx.branch()
@@ -4091,7 +4096,7 @@
                 output.append("(%s)" % b)
 
             # multiple tags for a single parent separated by '/'
-            t = '/'.join(ctx.tags())
+            t = '/'.join(taglist)
             if t:
                 output.append(t)
 
@@ -4104,7 +4109,7 @@
                 output.append(ctx.branch())
 
             if tags:
-                output.extend(ctx.tags())
+                output.extend(taglist)
 
             if bookmarks:
                 output.extend(ctx.bookmarks())


More information about the Mercurial-devel mailing list