mercurial/util.py
changeset 1583 32a4e6802864
parent 1482 4d38b85e60aa
child 1584 b3e94785ab69
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