[PATCH 1 of 2] devel-warn: move the develwarn function as a method of the ui object
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Jun 19 18:41:09 UTC 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1434737985 25200
# Fri Jun 19 11:19:45 2015 -0700
# Node ID a51f19e7f84edf50d1d751d8f55466bb10f4ba05
# Parent 85294076adceb3263056e366023cba2e88ace6ca
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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -946,11 +946,11 @@ class localrepository(object):
def transaction(self, desc, report=None):
if (self.ui.configbool('devel', 'all-warnings')
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()
# abort here if the journal already exists
@@ -1251,11 +1251,11 @@ class localrepository(object):
# acquisition would not cause dead-lock as they would just fail.
if wait and (self.ui.configbool('devel', 'all-warnings')
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():
self.dirstate.invalidate()
else:
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -8,11 +8,11 @@
from i18n import _
from mercurial.node import nullrev
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
else:
import scmposix as scmplatform
@@ -185,20 +185,10 @@ class casecollisionauditor(object):
raise util.Abort(msg)
self._ui.warn(_("warning: %s\n") % msg)
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.
Multiple caches perform up-to-date validation by checking that the
tiprev and tipnode stored in the cache file match the current repository.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -3,10 +3,11 @@
# Copyright 2005-2007 Matt Mackall <mpm at selenic.com>
#
# 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
from node import hex
@@ -956,10 +957,20 @@ class ui(object):
ui.write(s, 'label') is equivalent to
ui.write(ui.label(s, 'label')).
'''
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.
Data is initially derived from ui instances and the config files they have
loaded.
More information about the Mercurial-devel
mailing list