symlinks: add a linkfunc
authorMatt Mackall <mpm@selenic.com>
Fri, 29 Dec 2006 20:04:31 -0600
changeset 4000 3297aa945cf2
parent 3999 0b740dcf0cf1
child 4001 dda03b2d9ef1
symlinks: add a linkfunc
mercurial/util.py
--- a/mercurial/util.py	Fri Dec 29 20:04:31 2006 -0600
+++ b/mercurial/util.py	Fri Dec 29 20:04:31 2006 -0600
@@ -725,6 +725,12 @@
     except OSError:
         return False
 
+def linkfunc(path, fallback):
+    '''return an is_link() function with default to fallback'''
+    if checklink(path):
+        return lambda x: is_link(os.path.join(path, x))
+    return fallback
+
 # Platform specific variants
 if os.name == 'nt':
     import msvcrt