Comments
Patch
@@ -21,14 +21,32 @@ umask = os.umask(0)
os.umask(umask)
def split(p):
- '''Same as os.path.split, but faster'''
+ '''Same as os.path.split, but faster
+
+ >>> split('/absolute/path/to/file')
+ ('/absolute/path/to', 'file')
+ >>> split('relative/path/to/file')
+ ('relative/path/to', 'file')
+ >>> split('file_alone')
+ ('', 'file_alone')
+ >>> split('path/to/directory/')
+ ('path/to/directory', '')
+ >>> split('/multiple/path//separators')
+ ('/multiple/path', 'separators')
+ >>> split('/file_at_root')
+ ('/', 'file_at_root')
+ >>> split('///multiple_leading_separators_at_root')
+ ('///', 'multiple_leading_separators_at_root')
+ >>> split('')
+ ('', '')
+ '''
ht = p.rsplit('/', 1)
if len(ht) == 1:
return '', p
nh = ht[0].rstrip('/')
if nh:
return nh, ht[1]
- return ht
+ return ht[0] + '/', ht[1]
def openhardlinks():
'''return true if it is safe to hold open file handles to hardlinks'''
@@ -6,6 +6,7 @@ import doctest
import mercurial.util
doctest.testmod(mercurial.util)
+doctest.testmod(mercurial.util.platform)
import mercurial.changelog
doctest.testmod(mercurial.changelog)