Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 4097:403c4ddd74bb
Combined the two os_rcpath methods into a single one near rcpath in mercurial/util.py
The os_rcpath method delegates to system_rcpath and user_rcpath from the
different platform implementations.
author | Shane Holloway <shane.holloway@ieee.org> |
---|---|
date | Thu, 15 Feb 2007 09:51:57 -0700 |
parents | 49237d6ae97d |
children | c08b6af023bc |
comparison
equal
deleted
inserted
replaced
4096:49237d6ae97d | 4097:403c4ddd74bb |
---|---|
797 try: | 797 try: |
798 return system_rcpath_win32() | 798 return system_rcpath_win32() |
799 except: | 799 except: |
800 return [r'c:\mercurial\mercurial.ini'] | 800 return [r'c:\mercurial\mercurial.ini'] |
801 | 801 |
802 def os_rcpath(): | |
803 '''return default os-specific hgrc search path''' | |
804 path = system_rcpath() | |
805 path.extend(user_rcpath()) | |
806 path = [os.path.normpath(f) for f in path] | |
807 return path | |
808 | |
809 def user_rcpath(): | 802 def user_rcpath(): |
810 '''return os-specific hgrc search path to the user dir''' | 803 '''return os-specific hgrc search path to the user dir''' |
811 path = [os.path.join(os.path.expanduser('~'), 'mercurial.ini')] | 804 path = [os.path.join(os.path.expanduser('~'), 'mercurial.ini')] |
812 userprofile = os.environ.get('USERPROFILE') | 805 userprofile = os.environ.get('USERPROFILE') |
813 if userprofile: | 806 if userprofile: |
895 rcs.extend([os.path.join(rcdir, f) for f in os.listdir(rcdir) | 888 rcs.extend([os.path.join(rcdir, f) for f in os.listdir(rcdir) |
896 if f.endswith(".rc")]) | 889 if f.endswith(".rc")]) |
897 except OSError: | 890 except OSError: |
898 pass | 891 pass |
899 return rcs | 892 return rcs |
900 | |
901 def os_rcpath(): | |
902 '''return default os-specific hgrc search path''' | |
903 path = system_rcpath() | |
904 path.extend(user_rcpath()) | |
905 path = [os.path.normpath(f) for f in path] | |
906 return path | |
907 | 893 |
908 def system_rcpath(): | 894 def system_rcpath(): |
909 path = [] | 895 path = [] |
910 # old mod_python does not set sys.argv | 896 # old mod_python does not set sys.argv |
911 if len(getattr(sys, 'argv', [])) > 0: | 897 if len(getattr(sys, 'argv', [])) > 0: |
1389 dirs[:] = [] | 1375 dirs[:] = [] |
1390 break | 1376 break |
1391 | 1377 |
1392 _rcpath = None | 1378 _rcpath = None |
1393 | 1379 |
1380 def os_rcpath(): | |
1381 '''return default os-specific hgrc search path''' | |
1382 path = system_rcpath() | |
1383 path.extend(user_rcpath()) | |
1384 path = [os.path.normpath(f) for f in path] | |
1385 return path | |
1386 | |
1394 def rcpath(): | 1387 def rcpath(): |
1395 '''return hgrc search path. if env var HGRCPATH is set, use it. | 1388 '''return hgrc search path. if env var HGRCPATH is set, use it. |
1396 for each item in path, if directory, use files ending in .rc, | 1389 for each item in path, if directory, use files ending in .rc, |
1397 else use item. | 1390 else use item. |
1398 make HGRCPATH empty to only look in .hg/hgrc of current repo. | 1391 make HGRCPATH empty to only look in .hg/hgrc of current repo. |