##// END OF EJS Templates
posix, windows: introduce cachestat...
Idan Kamara -
r14927:2aa3e07b default
parent child Browse files
Show More
@@ -349,5 +349,21 b' def hidewindow():'
349 """
349 """
350 pass
350 pass
351
351
352 class cachestat(object):
353 def __init__(self, path):
354 self.stat = os.stat(path)
355
356 def cacheable(self):
357 return bool(self.stat.st_ino)
358
359 def __eq__(self, other):
360 try:
361 return self.stat == other.stat
362 except AttributeError:
363 return False
364
365 def __ne__(self, other):
366 return not self == other
367
352 def executablepath():
368 def executablepath():
353 return None # available on Windows only
369 return None # available on Windows only
@@ -24,6 +24,7 b" if os.name == 'nt':"
24 else:
24 else:
25 import posix as platform
25 import posix as platform
26
26
27 cachestat = platform.cachestat
27 checkexec = platform.checkexec
28 checkexec = platform.checkexec
28 checklink = platform.checklink
29 checklink = platform.checklink
29 executablepath = platform.executablepath
30 executablepath = platform.executablepath
@@ -286,4 +286,11 b' def isexec(f):'
286
286
287 from win32 import *
287 from win32 import *
288
288
289 class cachestat(object):
290 def __init__(self, path):
291 pass
292
293 def cacheable(self):
294 return False
295
289 expandglobs = True
296 expandglobs = True
@@ -101,6 +101,16 b' def has_inotify():'
101 def has_fifo():
101 def has_fifo():
102 return hasattr(os, "mkfifo")
102 return hasattr(os, "mkfifo")
103
103
104 def has_cacheable_fs():
105 from mercurial import util
106
107 fd, path = tempfile.mkstemp(prefix=tempprefix)
108 os.close(fd)
109 try:
110 return util.cachestat(path).cacheable()
111 finally:
112 os.remove(path)
113
104 def has_lsprof():
114 def has_lsprof():
105 try:
115 try:
106 import _lsprof
116 import _lsprof
@@ -200,6 +210,7 b' checks = {'
200 "baz": (has_baz, "GNU Arch baz client"),
210 "baz": (has_baz, "GNU Arch baz client"),
201 "bzr": (has_bzr, "Canonical's Bazaar client"),
211 "bzr": (has_bzr, "Canonical's Bazaar client"),
202 "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
212 "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
213 "cacheable": (has_cacheable_fs, "cacheable filesystem"),
203 "cvs": (has_cvs, "cvs client/server"),
214 "cvs": (has_cvs, "cvs client/server"),
204 "darcs": (has_darcs, "darcs client"),
215 "darcs": (has_darcs, "darcs client"),
205 "docutils": (has_docutils, "Docutils text processing library"),
216 "docutils": (has_docutils, "Docutils text processing library"),
General Comments 0
You need to be logged in to leave comments. Login now