[PATCH 06 of 10] scmutil: make join cheaper

Bryan O'Sullivan bos at serpentine.com
Thu Sep 13 14:01:19 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1347562630 25200
# Node ID 38159ce2f0115498a0c43b4c84a3f9ba87d08561
# Parent  d311c3d3c70fabe73f1053d238fc319ebdee20cb
scmutil: make join cheaper

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -229,6 +229,7 @@
         if expand:
             base = os.path.realpath(util.expandpath(base))
         self.base = base
+        self.basesep = self.base + os.sep
         self._setmustaudit(audit)
         self.createmode = None
         self._trustnlink = None
@@ -331,9 +332,8 @@
 
     def join(self, path):
         if path:
-            return os.path.join(self.base, path)
-        else:
-            return self.base
+            return path.startswith('/') and path or (self.basesep + path)
+        return self.base
 
 class filteropener(abstractopener):
     '''Wrapper opener for filtering filenames with a function.'''


More information about the Mercurial-devel mailing list