tests/hghave.py
branchstable
changeset 1101 89f984505cbb
parent 1100 59a99457aa65
child 1102 51afb47e2399
equal deleted inserted replaced
1100:59a99457aa65 1101:89f984505cbb
     1 import os, stat
     1 import os, stat, socket
     2 import re
     2 import re
     3 import sys
     3 import sys
     4 import tempfile
     4 import tempfile
     5 
     5 
     6 tempprefix = 'hg-hghave-'
     6 tempprefix = 'hg-hghave-'
    93         os.remove(path)
    93         os.remove(path)
    94 
    94 
    95 def has_inotify():
    95 def has_inotify():
    96     try:
    96     try:
    97         import hgext.inotify.linux.watcher
    97         import hgext.inotify.linux.watcher
    98         return True
    98     except ImportError:
    99     except ImportError:
    99         return False
   100         return False
   100     name = tempfile.mktemp(dir='.', prefix=tempprefix)
       
   101     sock = socket.socket(socket.AF_UNIX)
       
   102     try:
       
   103         sock.bind(name)
       
   104     except socket.error, err:
       
   105         return False
       
   106     sock.close()
       
   107     os.unlink(name)
       
   108     return True
   101 
   109 
   102 def has_fifo():
   110 def has_fifo():
   103     if getattr(os, "mkfifo", None) is None:
   111     if getattr(os, "mkfifo", None) is None:
   104         return False
   112         return False
   105     name = tempfile.mktemp(dir='.', prefix=tempprefix)
   113     name = tempfile.mktemp(dir='.', prefix=tempprefix)