diff mercurial/dirstate.py @ 6743:86e8187b721a

simplify flag handling add _checklink var to dirstate introduce dirstate.flagfunc switch users of util.execfunc/linkfunc to flagfunc change manifestdict.set to take a flags string change ctx.fileflags to ctx.flags change gitmode func to a dict remove util.execfunc/linkfunc
author Matt Mackall <mpm@selenic.com>
date Thu, 26 Jun 2008 13:46:34 -0500
parents 76021ec849c8
children ed01fa8ceaa6
line wrap: on
line diff
--- a/mercurial/dirstate.py	Thu Jun 26 13:46:33 2008 -0500
+++ b/mercurial/dirstate.py	Thu Jun 26 13:46:34 2008 -0500
@@ -70,6 +70,9 @@
         elif name == '_slash':
             self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/'
             return self._slash
+        elif name == '_checklink':
+            self._checklink = util.checklink(self._root)
+            return self._checklink
         elif name == '_checkexec':
             self._checkexec = util.checkexec(self._root)
             return self._checkexec
@@ -91,6 +94,34 @@
     def folding(self):
         return self._folding
 
+    def flagfunc(self, fallback):
+        if self._checklink:
+            if self._checkexec:
+                def f(x):
+                    p = os.path.join(self._root, x)
+                    if os.path.islink(p):
+                        return 'l'
+                    if util.is_exec(p):
+                        return 'x'
+                    return ''
+                return f
+            def f(x):
+                if os.path.islink(os.path.join(self._root, x)):
+                    return 'l'
+                if 'x' in fallback(x):
+                    return 'x'
+                return ''
+            return f
+        if self._checkexec:
+            def f(x):
+                if 'l' in fallback(x):
+                    return 'l'
+                if util.is_exec(os.path.join(self._root, x)):
+                    return 'x'
+                return ''
+            return f
+        return fallback
+
     def getcwd(self):
         cwd = os.getcwd()
         if cwd == self._root: return ''