tests/hghave
changeset 1074 6c7d0e38c0c2
parent 1072 bbf056e756cc
child 1089 f26e9129f65b
equal deleted inserted replaced
1066:bd418e7e2d29 1074:6c7d0e38c0c2
    29     return matchoutput('baz --version 2>&1', r'baz Bazaar version')
    29     return matchoutput('baz --version 2>&1', r'baz Bazaar version')
    30 
    30 
    31 def has_bzr():
    31 def has_bzr():
    32     try:
    32     try:
    33         import bzrlib
    33         import bzrlib
    34         return bzrlib.__doc__ != None
    34         return bzrlib.__doc__ is not None
    35     except ImportError:
    35     except ImportError:
    36         return False
    36         return False
    37 
    37 
    38 def has_bzr114():
    38 def has_bzr114():
    39     try:
    39     try:
    40         import bzrlib
    40         import bzrlib
    41         return (bzrlib.__doc__ != None
    41         return (bzrlib.__doc__ is not None
    42                 and bzrlib.version_info[:2] >= (1, 14))
    42                 and bzrlib.version_info[:2] >= (1, 14))
    43     except ImportError:
    43     except ImportError:
    44         return False
    44         return False
    45 
    45 
    46 def has_cvs():
    46 def has_cvs():
    58     try:
    58     try:
    59         fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
    59         fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
    60         os.close(fd)
    60         os.close(fd)
    61         os.remove(path)
    61         os.remove(path)
    62         return True
    62         return True
    63     except:
    63     except (IOError, OSError):
    64         return False
    64         return False
    65 
    65 
    66 def has_executablebit():
    66 def has_executablebit():
    67     try:
    67     try:
    68         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
    68         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
    91         if path == p2:
    91         if path == p2:
    92             p2 = os.path.join(d, b.lower())
    92             p2 = os.path.join(d, b.lower())
    93         try:
    93         try:
    94             s2 = os.stat(p2)
    94             s2 = os.stat(p2)
    95             return s2 == s1
    95             return s2 == s1
    96         except:
    96         except OSError:
    97             return False
    97             return False
    98     finally:
    98     finally:
    99         os.remove(path)
    99         os.remove(path)
   100 
   100 
   101 def has_inotify():
   101 def has_inotify():
   104         return True
   104         return True
   105     except ImportError:
   105     except ImportError:
   106         return False
   106         return False
   107 
   107 
   108 def has_fifo():
   108 def has_fifo():
   109     return hasattr(os, "mkfifo")
   109     return getattr(os, "mkfifo", None) is not None
   110 
   110 
   111 def has_cacheable_fs():
   111 def has_cacheable_fs():
   112     from mercurial import util
   112     from mercurial import util
   113 
   113 
   114     fd, path = tempfile.mkstemp(prefix=tempprefix)
   114     fd, path = tempfile.mkstemp(prefix=tempprefix)
   163         return True
   163         return True
   164     except ImportError:
   164     except ImportError:
   165         return False
   165         return False
   166 
   166 
   167 def has_p4():
   167 def has_p4():
   168     return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/')
   168     return (matchoutput('p4 -V', r'Rev\. P4/') and
       
   169             matchoutput('p4d -V', r'Rev\. P4D/'))
   169 
   170 
   170 def has_symlink():
   171 def has_symlink():
   171     if not hasattr(os, "symlink"):
   172     if getattr(os, "symlink", None) is None:
   172         return False
   173         return False
   173     name = tempfile.mktemp(dir=".", prefix='hg-checklink-')
   174     name = tempfile.mktemp(dir=".", prefix='hg-checklink-')
   174     try:
   175     try:
   175         os.symlink(".", name)
   176         os.symlink(".", name)
   176         os.unlink(name)
   177         os.unlink(name)