mercurial/posix.py
changeset 17560 9ee25d7b1aed
parent 17391 fc24c10424d2
child 18017 74912fe3d718
--- 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