Patchwork [6,of,8] py3: use bytes.endswith('\n') to strip off '\n' from debug color output

login
register
mail settings
Submitter Yuya Nishihara
Date March 1, 2018, 2:17 p.m.
Message ID <5644cfd9717dd1417505.1519913833@mimosa>
Download mbox | patch
Permalink /patch/28553/
State Accepted
Headers show

Comments

Yuya Nishihara - March 1, 2018, 2:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519911519 18000
#      Thu Mar 01 08:38:39 2018 -0500
# Node ID 5644cfd9717dd1417505a3ee0e0ae492f0da799f
# Parent  89d47c8b3dc9a4dcc207319b8177440fd5d99d2b
py3: use bytes.endswith('\n') to strip off '\n' from debug color output

Patch

diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -371,7 +371,7 @@  def colorlabel(ui, msg, label):
     """add color control code according to the mode"""
     if ui._colormode == 'debug':
         if label and msg:
-            if msg[-1] == '\n':
+            if msg.endswith('\n'):
                 msg = "[%s|%s]\n" % (label, msg[:-1])
             else:
                 msg = "[%s|%s]" % (label, msg)