Show More
@@ -146,6 +146,16 b' HGMERGE::' | |||
|
146 | 146 | |
|
147 | 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 | 159 | HGUSER:: |
|
150 | 160 | This is the string used for the author of a commit. |
|
151 | 161 |
@@ -18,7 +18,7 b' class ui(object):' | |||
|
18 | 18 | # this is the parent of all ui children |
|
19 | 19 | self.parentui = None |
|
20 | 20 | self.cdata = ConfigParser.SafeConfigParser() |
|
21 | self.readconfig(util.rcpath) | |
|
21 | self.readconfig(util.rcpath()) | |
|
22 | 22 | |
|
23 | 23 | self.quiet = self.configbool("ui", "quiet") |
|
24 | 24 | self.verbose = self.configbool("ui", "verbose") |
@@ -506,17 +506,18 b" if os.name == 'nt':" | |||
|
506 | 506 | |
|
507 | 507 | sys.stdout = winstdout(sys.stdout) |
|
508 | 508 | |
|
509 | try: | |
|
510 | import win32api, win32process | |
|
511 | filename = win32process.GetModuleFileNameEx(win32api.GetCurrentProcess(), 0) | |
|
512 | systemrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') | |
|
509 | def os_rcpath(): | |
|
510 | '''return default os-specific hgrc search path''' | |
|
511 | try: | |
|
512 | import win32api, win32process | |
|
513 | proc = win32api.GetCurrentProcess() | |
|
514 | filename = win32process.GetModuleFileNameEx(proc, 0) | |
|
515 | systemrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') | |
|
516 | except ImportError: | |
|
517 | systemrc = r'c:\mercurial\mercurial.ini' | |
|
513 | 518 | |
|
514 | except ImportError: | |
|
515 | systemrc = r'c:\mercurial\mercurial.ini' | |
|
516 | pass | |
|
517 | ||
|
518 | rcpath = (systemrc, | |
|
519 | os.path.join(os.path.expanduser('~'), 'mercurial.ini')) | |
|
519 | return [systemrc, | |
|
520 | os.path.join(os.path.expanduser('~'), 'mercurial.ini')] | |
|
520 | 521 | |
|
521 | 522 | def parse_patch_output(output_line): |
|
522 | 523 | """parses the output produced by patch and returns the file name""" |
@@ -591,12 +592,17 b' else:' | |||
|
591 | 592 | if f.endswith(".rc")]) |
|
592 | 593 | except OSError, inst: pass |
|
593 | 594 | return rcs |
|
594 | rcpath = [] | |
|
595 | if len(sys.argv) > 0: | |
|
596 | rcpath.extend(rcfiles(os.path.dirname(sys.argv[0]) + '/../etc/mercurial')) | |
|
597 | rcpath.extend(rcfiles('/etc/mercurial')) | |
|
598 | rcpath.append(os.path.expanduser('~/.hgrc')) | |
|
599 | rcpath = [os.path.normpath(f) for f in rcpath] | |
|
595 | ||
|
596 | def os_rcpath(): | |
|
597 | '''return default os-specific hgrc search path''' | |
|
598 | path = [] | |
|
599 | if len(sys.argv) > 0: | |
|
600 | path.extend(rcfiles(os.path.dirname(sys.argv[0]) + | |
|
601 | '/../etc/mercurial')) | |
|
602 | path.extend(rcfiles('/etc/mercurial')) | |
|
603 | path.append(os.path.expanduser('~/.hgrc')) | |
|
604 | path = [os.path.normpath(f) for f in path] | |
|
605 | return path | |
|
600 | 606 | |
|
601 | 607 | def parse_patch_output(output_line): |
|
602 | 608 | """parses the output produced by patch and returns the file name""" |
@@ -768,3 +774,29 b' def walkrepos(path):' | |||
|
768 | 774 | yield root |
|
769 | 775 | dirs[:] = [] |
|
770 | 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 |
General Comments 0
You need to be logged in to leave comments.
Login now