util: implement a faster os.path.split for posix systems
This is not yet used.
--- a/mercurial/posix.py Fri Sep 14 12:07:33 2012 -0700
+++ b/mercurial/posix.py Fri Sep 14 12:08:17 2012 -0700
@@ -20,6 +20,16 @@
umask = os.umask(0)
os.umask(umask)
+def split(p):
+ '''Same as os.path.split, but faster'''
+ ht = p.rsplit('/', 1)
+ if len(ht) == 1:
+ return '', p
+ nh = ht[0].rstrip('/')
+ if nh:
+ return nh, ht[1]
+ return ht
+
def openhardlinks():
'''return true if it is safe to hold open file handles to hardlinks'''
return True
--- a/mercurial/util.py Fri Sep 14 12:07:33 2012 -0700
+++ b/mercurial/util.py Fri Sep 14 12:08:17 2012 -0700
@@ -62,6 +62,7 @@
setsignalhandler = platform.setsignalhandler
shellquote = platform.shellquote
spawndetached = platform.spawndetached
+split = platform.split
sshargs = platform.sshargs
statfiles = platform.statfiles
termwidth = platform.termwidth
--- a/mercurial/windows.py Fri Sep 14 12:07:33 2012 -0700
+++ b/mercurial/windows.py Fri Sep 14 12:08:17 2012 -0700
@@ -20,6 +20,7 @@
samefile = win32.samefile
setsignalhandler = win32.setsignalhandler
spawndetached = win32.spawndetached
+split = os.path.split
termwidth = win32.termwidth
testpid = win32.testpid
unlink = win32.unlink