Patchwork [07,of,10] ui: allow develwarn without a stack

login
register
mail settings
Submitter Jun Wu
Date June 30, 2016, 4:59 p.m.
Message ID <6b6fdfbf77d35a290519.1467305942@x1c>
Download mbox | patch
Permalink /patch/15666/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - June 30, 2016, 4:59 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1467284364 -3600
#      Thu Jun 30 11:59:24 2016 +0100
# Node ID 6b6fdfbf77d35a290519b6620b5fd999e10ac723
# Parent  ae943c113c1b9f68313f0dfd7304e07dad53be75
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 6b6fdfbf77d3
ui: allow develwarn without a stack

Sometimes we can only do aftermath check and do not have clues about the exact
problematic location. This patch allows develwarn to be without a stack by
setting stacklevel to None.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1157,12 +1157,15 @@  class ui(object):
         """issue a developer warning message
 
         Use 'stacklevel' to report the offender some layers further up in the
-        stack.
+        stack. If 'stacklevel' is None, no stack will be printed.
         """
         if not self.configbool('devel', 'all-warnings'):
             if config is not None and not self.configbool('devel', config):
                 return
         msg = 'devel-warn: ' + msg
+        if stacklevel is None:
+            self.log('develwarn', msg)
+            return
         stacklevel += 1 # get in develwarn
         if self.tracebackflag:
             util.debugstacktrace(msg, stacklevel, self.ferr, self.fout)