changeset 25629:52e5f68d8363

devel-warn: move the develwarn function as a method of the ui object We are going to use this feature in more and more place. Having to import scmutil makes it an import cycle hell.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 19 Jun 2015 11:19:45 -0700
parents 9c647f427aef
children c88082baf693
files mercurial/localrepo.py mercurial/scmutil.py mercurial/ui.py
diffstat 3 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Jun 18 23:08:27 2015 +0900
+++ b/mercurial/localrepo.py	Fri Jun 19 11:19:45 2015 -0700
@@ -953,7 +953,7 @@
                 or self.ui.configbool('devel', 'check-locks')):
             l = self._lockref and self._lockref()
             if l is None or not l.held:
-                scmutil.develwarn(self.ui, 'transaction with no lock')
+                self.ui.develwarn('transaction with no lock')
         tr = self.currenttransaction()
         if tr is not None:
             return tr.nest()
@@ -1258,7 +1258,7 @@
                      or self.ui.configbool('devel', 'check-locks')):
             l = self._lockref and self._lockref()
             if l is not None and l.held:
-                scmutil.develwarn(self.ui, '"wlock" acquired after "lock"')
+                self.ui.develwarn('"wlock" acquired after "lock"')
 
         def unlock():
             if self.dirstate.pendingparentchange():
--- a/mercurial/scmutil.py	Thu Jun 18 23:08:27 2015 +0900
+++ b/mercurial/scmutil.py	Fri Jun 19 11:19:45 2015 -0700
@@ -10,7 +10,7 @@
 import util, error, osutil, revset, similar, encoding, phases
 import pathutil
 import match as matchmod
-import os, errno, re, glob, tempfile, shutil, stat, inspect
+import os, errno, re, glob, tempfile, shutil, stat
 
 if os.name == 'nt':
     import scmwindows as scmplatform
@@ -187,16 +187,6 @@
         self._loweredfiles.add(fl)
         self._newfiles.add(f)
 
-def develwarn(tui, msg):
-    """issue a developer warning message"""
-    msg = 'devel-warn: ' + msg
-    if tui.tracebackflag:
-        util.debugstacktrace(msg, 2)
-    else:
-        curframe = inspect.currentframe()
-        calframe = inspect.getouterframes(curframe, 2)
-        tui.write_err('%s at: %s:%s (%s)\n' % ((msg,) + calframe[2][1:4]))
-
 def filteredhash(repo, maxrev):
     """build hash of filtered revisions in the current repoview.
 
--- a/mercurial/ui.py	Thu Jun 18 23:08:27 2015 +0900
+++ b/mercurial/ui.py	Fri Jun 19 11:19:45 2015 -0700
@@ -5,6 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import inspect
 from i18n import _
 import errno, getpass, os, socket, sys, tempfile, traceback
 import config, scmutil, util, error, formatter, progress
@@ -958,6 +959,16 @@
         '''
         return msg
 
+    def develwarn(self, msg):
+        """issue a developer warning message"""
+        msg = 'devel-warn: ' + msg
+        if self.tracebackflag:
+            util.debugstacktrace(msg, 2)
+        else:
+            curframe = inspect.currentframe()
+            calframe = inspect.getouterframes(curframe, 2)
+            self.write_err('%s at: %s:%s (%s)\n' % ((msg,) + calframe[2][1:4]))
+
 class paths(dict):
     """Represents a collection of paths and their configs.