##// END OF EJS Templates
move rcpath from util to scmutil
Adrian Buehlmann -
r13984:af60153b default
parent child Browse files
Show More
@@ -1199,7 +1199,7 b' def showconfig(ui, repo, *values, **opts'
1199 Returns 0 on success.
1199 Returns 0 on success.
1200 """
1200 """
1201
1201
1202 for f in util.rcpath():
1202 for f in scmutil.rcpath():
1203 ui.debug(_('read config from: %s\n') % f)
1203 ui.debug(_('read config from: %s\n') % f)
1204 untrusted = bool(opts.get('untrusted'))
1204 untrusted = bool(opts.get('untrusted'))
1205 if values:
1205 if values:
@@ -6,7 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import util, error
9 import util, error, osutil
10 import os, errno, stat
10 import os, errno, stat
11
11
12 def checkfilename(f):
12 def checkfilename(f):
@@ -295,3 +295,29 b' def walkrepos(path, followsym=False, see'
295 else:
295 else:
296 newdirs.append(d)
296 newdirs.append(d)
297 dirs[:] = newdirs
297 dirs[:] = newdirs
298
299 _rcpath = None
300
301 def rcpath():
302 '''return hgrc search path. if env var HGRCPATH is set, use it.
303 for each item in path, if directory, use files ending in .rc,
304 else use item.
305 make HGRCPATH empty to only look in .hg/hgrc of current repo.
306 if no HGRCPATH, use default os-specific path.'''
307 global _rcpath
308 if _rcpath is None:
309 if 'HGRCPATH' in os.environ:
310 _rcpath = []
311 for p in os.environ['HGRCPATH'].split(os.pathsep):
312 if not p:
313 continue
314 p = util.expandpath(p)
315 if os.path.isdir(p):
316 for f, kind in osutil.listdir(p):
317 if f.endswith('.rc'):
318 _rcpath.append(os.path.join(p, f))
319 else:
320 _rcpath.append(p)
321 else:
322 _rcpath = util.os_rcpath()
323 return _rcpath
@@ -7,7 +7,7 b''
7
7
8 from i18n import _
8 from i18n import _
9 import errno, getpass, os, socket, sys, tempfile, traceback
9 import errno, getpass, os, socket, sys, tempfile, traceback
10 import config, util, error, url
10 import config, scmutil, util, error, url
11
11
12 class ui(object):
12 class ui(object):
13 def __init__(self, src=None):
13 def __init__(self, src=None):
@@ -32,7 +32,7 b' class ui(object):'
32 # shared read-only environment
32 # shared read-only environment
33 self.environ = os.environ
33 self.environ = os.environ
34 # we always trust global config files
34 # we always trust global config files
35 for f in util.rcpath():
35 for f in scmutil.rcpath():
36 self.readconfig(f, trust=True)
36 self.readconfig(f, trust=True)
37
37
38 def copy(self):
38 def copy(self):
@@ -1083,8 +1083,6 b' def ellipsis(text, maxlength=400):'
1083 except (UnicodeDecodeError, UnicodeEncodeError):
1083 except (UnicodeDecodeError, UnicodeEncodeError):
1084 return _ellipsis(text, maxlength)[0]
1084 return _ellipsis(text, maxlength)[0]
1085
1085
1086 _rcpath = None
1087
1088 def os_rcpath():
1086 def os_rcpath():
1089 '''return default os-specific hgrc search path'''
1087 '''return default os-specific hgrc search path'''
1090 path = system_rcpath()
1088 path = system_rcpath()
@@ -1092,30 +1090,6 b' def os_rcpath():'
1092 path = [os.path.normpath(f) for f in path]
1090 path = [os.path.normpath(f) for f in path]
1093 return path
1091 return path
1094
1092
1095 def rcpath():
1096 '''return hgrc search path. if env var HGRCPATH is set, use it.
1097 for each item in path, if directory, use files ending in .rc,
1098 else use item.
1099 make HGRCPATH empty to only look in .hg/hgrc of current repo.
1100 if no HGRCPATH, use default os-specific path.'''
1101 global _rcpath
1102 if _rcpath is None:
1103 if 'HGRCPATH' in os.environ:
1104 _rcpath = []
1105 for p in os.environ['HGRCPATH'].split(os.pathsep):
1106 if not p:
1107 continue
1108 p = expandpath(p)
1109 if os.path.isdir(p):
1110 for f, kind in osutil.listdir(p):
1111 if f.endswith('.rc'):
1112 _rcpath.append(os.path.join(p, f))
1113 else:
1114 _rcpath.append(p)
1115 else:
1116 _rcpath = os_rcpath()
1117 return _rcpath
1118
1119 def bytecount(nbytes):
1093 def bytecount(nbytes):
1120 '''return byte count formatted as readable string, with units'''
1094 '''return byte count formatted as readable string, with units'''
1121
1095
General Comments 0
You need to be logged in to leave comments. Login now