dirstate: lazify and lambdafy _slash
authorMatt Mackall <mpm@selenic.com>
Mon, 18 Jun 2007 13:24:34 -0500
changeset 4611 86e5500a517e
parent 4610 274c99fc629f
child 4612 17ee7407097f
dirstate: lazify and lambdafy _slash
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Jun 18 13:24:34 2007 -0500
+++ b/mercurial/dirstate.py	Mon Jun 18 13:24:34 2007 -0500
@@ -22,7 +22,6 @@
         self.root = root
         self.dirty = 0
         self.ui = ui
-        self._slash = None
 
     def __getattr__(self, name):
         if name == 'map':
@@ -56,6 +55,9 @@
             files = [self.wjoin('.hgignore')] + self.ui.hgignorefiles()
             self._ignore = ignore.ignore(self.root, files, self.ui.warn)
             return self._ignore
+        elif name == '_slash':
+            self._slash = self.ui.configbool('ui', 'slash') and os.sep != '/'
+            return self._slash
         else:
             raise AttributeError, name
 
@@ -79,10 +81,8 @@
         if cwd is None:
             cwd = self.getcwd()
         path = util.pathto(self.root, cwd, f)
-        if self._slash is None:
-            self._slash = self.ui.configbool('ui', 'slash') and os.sep != '/'
         if self._slash:
-            path = path.replace(os.sep, '/')
+            return path.replace(os.sep, '/')
         return path
 
     def __del__(self):