##// END OF EJS Templates
add HGRCPATH env var, list of places to look for hgrc files....
Vadim Gelfer -
r1951:696230e5 default
parent child Browse files
Show More
@@ -146,6 +146,16 b' HGMERGE::'
146
146
147 (deprecated, use .hgrc)
147 (deprecated, use .hgrc)
148
148
149 HGRCPATH::
150 A list of files or directories to search for hgrc files. Item
151 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
152 platform default search path is used. If empty, only .hg/hgrc of
153 current repository is read.
154
155 For each element in path, if a directory, all entries in directory
156 ending with ".rc" are added to path. Else, element itself is
157 added to path.
158
149 HGUSER::
159 HGUSER::
150 This is the string used for the author of a commit.
160 This is the string used for the author of a commit.
151
161
@@ -18,7 +18,7 b' class ui(object):'
18 # this is the parent of all ui children
18 # this is the parent of all ui children
19 self.parentui = None
19 self.parentui = None
20 self.cdata = ConfigParser.SafeConfigParser()
20 self.cdata = ConfigParser.SafeConfigParser()
21 self.readconfig(util.rcpath)
21 self.readconfig(util.rcpath())
22
22
23 self.quiet = self.configbool("ui", "quiet")
23 self.quiet = self.configbool("ui", "quiet")
24 self.verbose = self.configbool("ui", "verbose")
24 self.verbose = self.configbool("ui", "verbose")
@@ -506,17 +506,18 b" if os.name == 'nt':"
506
506
507 sys.stdout = winstdout(sys.stdout)
507 sys.stdout = winstdout(sys.stdout)
508
508
509 def os_rcpath():
510 '''return default os-specific hgrc search path'''
509 try:
511 try:
510 import win32api, win32process
512 import win32api, win32process
511 filename = win32process.GetModuleFileNameEx(win32api.GetCurrentProcess(), 0)
513 proc = win32api.GetCurrentProcess()
514 filename = win32process.GetModuleFileNameEx(proc, 0)
512 systemrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
515 systemrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
513
514 except ImportError:
516 except ImportError:
515 systemrc = r'c:\mercurial\mercurial.ini'
517 systemrc = r'c:\mercurial\mercurial.ini'
516 pass
517
518
518 rcpath = (systemrc,
519 return [systemrc,
519 os.path.join(os.path.expanduser('~'), 'mercurial.ini'))
520 os.path.join(os.path.expanduser('~'), 'mercurial.ini')]
520
521
521 def parse_patch_output(output_line):
522 def parse_patch_output(output_line):
522 """parses the output produced by patch and returns the file name"""
523 """parses the output produced by patch and returns the file name"""
@@ -591,12 +592,17 b' else:'
591 if f.endswith(".rc")])
592 if f.endswith(".rc")])
592 except OSError, inst: pass
593 except OSError, inst: pass
593 return rcs
594 return rcs
594 rcpath = []
595
596 def os_rcpath():
597 '''return default os-specific hgrc search path'''
598 path = []
595 if len(sys.argv) > 0:
599 if len(sys.argv) > 0:
596 rcpath.extend(rcfiles(os.path.dirname(sys.argv[0]) + '/../etc/mercurial'))
600 path.extend(rcfiles(os.path.dirname(sys.argv[0]) +
597 rcpath.extend(rcfiles('/etc/mercurial'))
601 '/../etc/mercurial'))
598 rcpath.append(os.path.expanduser('~/.hgrc'))
602 path.extend(rcfiles('/etc/mercurial'))
599 rcpath = [os.path.normpath(f) for f in rcpath]
603 path.append(os.path.expanduser('~/.hgrc'))
604 path = [os.path.normpath(f) for f in path]
605 return path
600
606
601 def parse_patch_output(output_line):
607 def parse_patch_output(output_line):
602 """parses the output produced by patch and returns the file name"""
608 """parses the output produced by patch and returns the file name"""
@@ -768,3 +774,29 b' def walkrepos(path):'
768 yield root
774 yield root
769 dirs[:] = []
775 dirs[:] = []
770 break
776 break
777
778 _rcpath = None
779
780 def rcpath():
781 '''return hgrc search path. if env var HGRCPATH is set, use it.
782 for each item in path, if directory, use files ending in .rc,
783 else use item.
784 make HGRCPATH empty to only look in .hg/hgrc of current repo.
785 if no HGRCPATH, use default os-specific path.'''
786 global _rcpath
787 if _rcpath is None:
788 if 'HGRCPATH' in os.environ:
789 _rcpath = []
790 for p in os.environ['HGRCPATH'].split(os.pathsep):
791 if not p: continue
792 try:
793 for f in os.listdir(p):
794 if f.endswith('.rc'):
795 _rcpath.append(os.path.join(p, f))
796 continue
797 except:
798 pass
799 _rcpath.append(p)
800 else:
801 _rcpath = os_rcpath()
802 return _rcpath
@@ -18,6 +18,7 b' TZ=GMT; export TZ'
18 HGEDITOR=true; export HGEDITOR
18 HGEDITOR=true; export HGEDITOR
19 HGMERGE=true; export HGMERGE
19 HGMERGE=true; export HGMERGE
20 HGUSER="test"; export HGUSER
20 HGUSER="test"; export HGUSER
21 HGRCPATH=""; export HGRCPATH
21
22
22 ECHO_N="echo -n"
23 ECHO_N="echo -n"
23 [ -x /usr/ucb/echo ] && ECHO_N="/usr/ucb/echo -n"
24 [ -x /usr/ucb/echo ] && ECHO_N="/usr/ucb/echo -n"
General Comments 0
You need to be logged in to leave comments. Login now