[PATCH 2 of 3] util: strip trailing newline from debugstacktrace message

Mads Kiilerich mads at kiilerich.com
Sat Mar 11 17:31:12 EST 2017


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1421378800 -3600
#      Fri Jan 16 04:26:40 2015 +0100
# Node ID dbf53b1ab67f06fcf13736c1bd91f8472a851be5
# Parent  56ee8fd0a885a7ba4f4da5dbe85d8844bb45df5b
util: strip trailing newline from debugstacktrace message

This makes the function more convenient to use as drop-in replacement for
ui.write & co.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2871,7 +2871,7 @@ def debugstacktrace(msg='stacktrace', sk
     '''
     if otherf:
         otherf.flush()
-    f.write('%s at:\n' % msg)
+    f.write('%s at:\n' % msg.rstrip())
     for line in getstackframes(skip + 1):
         f.write(line)
     f.flush()
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -129,8 +129,7 @@ Test internal debugstacktrace command
   stacktrace at:
    debugstacktrace.py:10 in * (glob)
    debugstacktrace.py:3  in f
-  hello from g
-   at:
+  hello from g at:
    debugstacktrace.py:10 in * (glob)
    debugstacktrace.py:4  in f
   hi ...


More information about the Mercurial-devel mailing list