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

login
register
mail settings
Submitter Kostia Balytskyi
Date Jan. 27, 2017, 4 p.m.
Message ID <494e92ec0cef1e98a5ac.1485532819@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18274/
State Accepted
Headers show

Comments

Kostia Balytskyi - Jan. 27, 2017, 4 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@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.
Sean Farley - Feb. 3, 2017, 10:25 p.m.
Kostia Balytskyi <ikostia@fb.com> writes:

> # HG changeset patch
> # User Kostia Balytskyi <ikostia@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.

Makes sense; queued!

Patch

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(),