Mercurial > hg
comparison mercurial/util.py @ 1583:32a4e6802864
make mercurial look in more places for config files.
now it searches <install dir>/etc/mercurial, /etc/mercurial, and user
hgrc.
this allows site-wide configuration to be shared over automounted nfs
partition, instead of chenging on every system. option of having local
configuration on every system remains.
old code for searching /etc/mercurial/hgrc.d never worked, this code
is tested and works.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 04 Nov 2005 11:51:01 -0800 |
parents | 4d38b85e60aa |
children | b3e94785ab69 |
comparison
equal
deleted
inserted
replaced
1507:cd8fadd8c689 | 1583:32a4e6802864 |
---|---|
11 """ | 11 """ |
12 | 12 |
13 import os, errno | 13 import os, errno |
14 from i18n import gettext as _ | 14 from i18n import gettext as _ |
15 from demandload import * | 15 from demandload import * |
16 demandload(globals(), "re cStringIO shutil popen2 tempfile threading time") | 16 demandload(globals(), "re cStringIO shutil popen2 sys tempfile threading time") |
17 | 17 |
18 def pipefilter(s, cmd): | 18 def pipefilter(s, cmd): |
19 '''filter string S through command CMD, returning its output''' | 19 '''filter string S through command CMD, returning its output''' |
20 (pout, pin) = popen2.popen2(cmd, -1, 'b') | 20 (pout, pin) = popen2.popen2(cmd, -1, 'b') |
21 def writer(): | 21 def writer(): |
481 return _("exited with status %d") % code, code | 481 return _("exited with status %d") % code, code |
482 | 482 |
483 else: | 483 else: |
484 nulldev = '/dev/null' | 484 nulldev = '/dev/null' |
485 | 485 |
486 hgrcd = '/etc/mercurial/hgrc.d' | 486 def rcfiles(path): |
487 hgrcs = [] | 487 rcs = [os.path.join(path, 'hgrc')] |
488 if os.path.isdir(hgrcd): | 488 rcdir = os.path.join(path, 'hgrc.d') |
489 hgrcs = [f for f in os.listdir(hgrcd) if f.endswith(".rc")] | 489 try: |
490 rcpath = map(os.path.normpath, hgrcs + | 490 rcs.extend([os.path.join(rcdir, f) for f in os.listdir(rcdir) |
491 ['/etc/mercurial/hgrc', os.path.expanduser('~/.hgrc')]) | 491 if f.endswith(".rc")]) |
492 except OSError, inst: pass | |
493 return rcs | |
494 rcpath = rcfiles(os.path.dirname(sys.argv[0]) + '/../etc/mercurial') | |
495 rcpath.extend(rcfiles('/etc/mercurial')) | |
496 rcpath.append(os.path.expanduser('~/.hgrc')) | |
497 rcpath = [os.path.normpath(f) for f in rcpath] | |
492 | 498 |
493 def parse_patch_output(output_line): | 499 def parse_patch_output(output_line): |
494 """parses the output produced by patch and returns the file name""" | 500 """parses the output produced by patch and returns the file name""" |
495 return output_line[14:] | 501 return output_line[14:] |
496 | 502 |