Mercurial > hg
comparison mercurial/util.py @ 13984:af60153b5e3b
move rcpath from util to scmutil
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 21 Apr 2011 20:14:29 +0200 |
parents | 938fbeacac84 |
children | 26335a817dd0 |
comparison
equal
deleted
inserted
replaced
13983:144d64cf456e | 13984:af60153b5e3b |
---|---|
1081 return text | 1081 return text |
1082 return utext.encode(encoding.encoding) | 1082 return utext.encode(encoding.encoding) |
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() |
1091 path.extend(user_rcpath()) | 1089 path.extend(user_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 | |
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 | 1092 |
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 |
1122 units = ( | 1096 units = ( |