--- a/mercurial/commands.py Thu Apr 21 15:11:28 2011 -0500
+++ b/mercurial/commands.py Thu Apr 21 20:14:29 2011 +0200
@@ -1199,7 +1199,7 @@
Returns 0 on success.
"""
- for f in util.rcpath():
+ for f in scmutil.rcpath():
ui.debug(_('read config from: %s\n') % f)
untrusted = bool(opts.get('untrusted'))
if values:
--- a/mercurial/scmutil.py Thu Apr 21 15:11:28 2011 -0500
+++ b/mercurial/scmutil.py Thu Apr 21 20:14:29 2011 +0200
@@ -6,7 +6,7 @@
# GNU General Public License version 2 or any later version.
from i18n import _
-import util, error
+import util, error, osutil
import os, errno, stat
def checkfilename(f):
@@ -295,3 +295,29 @@
else:
newdirs.append(d)
dirs[:] = newdirs
+
+_rcpath = None
+
+def rcpath():
+ '''return hgrc search path. if env var HGRCPATH is set, use it.
+ for each item in path, if directory, use files ending in .rc,
+ else use item.
+ make HGRCPATH empty to only look in .hg/hgrc of current repo.
+ if no HGRCPATH, use default os-specific path.'''
+ global _rcpath
+ if _rcpath is None:
+ if 'HGRCPATH' in os.environ:
+ _rcpath = []
+ for p in os.environ['HGRCPATH'].split(os.pathsep):
+ if not p:
+ continue
+ p = util.expandpath(p)
+ if os.path.isdir(p):
+ for f, kind in osutil.listdir(p):
+ if f.endswith('.rc'):
+ _rcpath.append(os.path.join(p, f))
+ else:
+ _rcpath.append(p)
+ else:
+ _rcpath = util.os_rcpath()
+ return _rcpath
--- a/mercurial/ui.py Thu Apr 21 15:11:28 2011 -0500
+++ b/mercurial/ui.py Thu Apr 21 20:14:29 2011 +0200
@@ -7,7 +7,7 @@
from i18n import _
import errno, getpass, os, socket, sys, tempfile, traceback
-import config, util, error, url
+import config, scmutil, util, error, url
class ui(object):
def __init__(self, src=None):
@@ -32,7 +32,7 @@
# shared read-only environment
self.environ = os.environ
# we always trust global config files
- for f in util.rcpath():
+ for f in scmutil.rcpath():
self.readconfig(f, trust=True)
def copy(self):
--- a/mercurial/util.py Thu Apr 21 15:11:28 2011 -0500
+++ b/mercurial/util.py Thu Apr 21 20:14:29 2011 +0200
@@ -1083,8 +1083,6 @@
except (UnicodeDecodeError, UnicodeEncodeError):
return _ellipsis(text, maxlength)[0]
-_rcpath = None
-
def os_rcpath():
'''return default os-specific hgrc search path'''
path = system_rcpath()
@@ -1092,30 +1090,6 @@
path = [os.path.normpath(f) for f in path]
return path
-def rcpath():
- '''return hgrc search path. if env var HGRCPATH is set, use it.
- for each item in path, if directory, use files ending in .rc,
- else use item.
- make HGRCPATH empty to only look in .hg/hgrc of current repo.
- if no HGRCPATH, use default os-specific path.'''
- global _rcpath
- if _rcpath is None:
- if 'HGRCPATH' in os.environ:
- _rcpath = []
- for p in os.environ['HGRCPATH'].split(os.pathsep):
- if not p:
- continue
- p = expandpath(p)
- if os.path.isdir(p):
- for f, kind in osutil.listdir(p):
- if f.endswith('.rc'):
- _rcpath.append(os.path.join(p, f))
- else:
- _rcpath.append(p)
- else:
- _rcpath = os_rcpath()
- return _rcpath
-
def bytecount(nbytes):
'''return byte count formatted as readable string, with units'''