# HG changeset patch # User Pierre-Yves David # Date 1434737985 25200 # Node ID 52e5f68d8363d634e89325cf5c21506c0b031159 # Parent 9c647f427aef11a0a2be2c8f07bfe0d34c15c779 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. diff -r 9c647f427aef -r 52e5f68d8363 mercurial/localrepo.py --- 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(): diff -r 9c647f427aef -r 52e5f68d8363 mercurial/scmutil.py --- 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. diff -r 9c647f427aef -r 52e5f68d8363 mercurial/ui.py --- 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.