[PATCH 1 of 3] move rcpath from util to scmutil

Adrian Buehlmann adrian at cadifra.com
Thu Apr 21 14:46:29 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1303409669 -7200
# Node ID 2c685a3fbae5ded461c9cd5516c4ceb74b871b1a
# Parent  938fbeacac8482b33794488e0e0e2d08b58ff423
move rcpath from util to scmutil

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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:
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -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
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -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):
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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'''
 


More information about the Mercurial-devel mailing list