[PATCH remotenames-ext] display: compute whether the node is obsolete only if needed

Kostia Balytskyi ikostia at fb.com
Fri Jan 27 16:00:19 UTC 2017


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1485532411 28800
#      Fri Jan 27 07:53:31 2017 -0800
# Node ID 494e92ec0cef1e98a5ac0a233d1fc7dcb6ac3fc7
# Parent  ad31e88e4c85ba95642231f73c0915dd6997962f
display: compute whether the node is obsolete only if needed

For unformatted output (e.g. piped somewhere) we don't need
the label information, so we don't need to know whether the node
is obsolete. This is an optimization for repos with many remote
bookmarks.

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -1207,6 +1207,7 @@ def displayremotebookmarks(ui, repo, opt
 
     # it seems overkill to hide displaying hidden remote bookmarks
     repo = repo.unfiltered()
+    useformatted = repo.ui.formatted()
 
     for name in sorted(ns.listnames(repo)):
         node = ns.nodes(repo, name)[0]
@@ -1220,7 +1221,7 @@ def displayremotebookmarks(ui, repo, opt
         fmt = ' ' * padsize + ' %d:%s'
 
         tmplabel = label
-        if ctx.obsolete():
+        if useformatted and ctx.obsolete():
             tmplabel = tmplabel + ' changeset.obsolete'
         fm.write(color, '%s', name, label=label)
         fm.condwrite(not ui.quiet, 'rev node', fmt, ctx.rev(),


More information about the Mercurial-devel mailing list