tests/hghave
changeset 5308 9400d677efc7
parent 5250 d61e98a82cee
parent 5302 961876838de0
child 5409 190c234c8fa0
equal deleted inserted replaced
5300:81575b7b505e 5308:9400d677efc7
     9 import sys
     9 import sys
    10 import tempfile
    10 import tempfile
    11 
    11 
    12 tempprefix = 'hg-hghave-'
    12 tempprefix = 'hg-hghave-'
    13 
    13 
    14 def matchoutput(cmd, regexp):
    14 def matchoutput(cmd, regexp, ignorestatus=False):
    15     """Return True if cmd executes successfully and its output
    15     """Return True if cmd executes successfully and its output
    16     is matched by the supplied regular expression.
    16     is matched by the supplied regular expression.
    17     """
    17     """
    18     r = re.compile(regexp)
    18     r = re.compile(regexp)
    19     fh = os.popen(cmd)
    19     fh = os.popen(cmd)
    20     s = fh.read()
    20     s = fh.read()
    21     ret = fh.close()
    21     ret = fh.close()
    22     return ret is None and r.search(s)
    22     return (ignorestatus or ret is None) and r.search(s)
    23 
    23 
    24 def has_symlink():
    24 def has_symlink():
    25     return hasattr(os, "symlink")
    25     return hasattr(os, "symlink")
    26 
    26 
    27 def has_fifo():
    27 def has_fifo():
    28     return hasattr(os, "mkfifo")
    28     return hasattr(os, "mkfifo")
       
    29 
       
    30 def has_cvs():
       
    31     return matchoutput('cvs --version 2>&1', r'Concurrent Versions System')
       
    32 
       
    33 def has_cvsps():
       
    34     return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
    29 
    35 
    30 def has_executablebit():
    36 def has_executablebit():
    31     fd, path = tempfile.mkstemp(prefix=tempprefix)
    37     fd, path = tempfile.mkstemp(prefix=tempprefix)
    32     os.close(fd)
    38     os.close(fd)
    33     try:
    39     try:
    75         return True
    81         return True
    76     except ImportError:
    82     except ImportError:
    77         return False
    83         return False
    78 
    84 
    79 checks = {
    85 checks = {
       
    86     "cvs": (has_cvs, "cvs client"),
       
    87     "cvsps": (has_cvsps, "cvsps utility"),
    80     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
    88     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
    81     "execbit": (has_executablebit, "executable bit"),
    89     "execbit": (has_executablebit, "executable bit"),
    82     "git": (has_git, "git command line client"),
    90     "git": (has_git, "git command line client"),
    83     "fifo": (has_fifo, "named pipes"),
    91     "fifo": (has_fifo, "named pipes"),
    84     "hotshot": (has_hotshot, "python hotshot module"),
    92     "hotshot": (has_hotshot, "python hotshot module"),