Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 17560:9ee25d7b1aed
util: implement a faster os.path.split for posix systems
This is not yet used.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 14 Sep 2012 12:08:17 -0700 |
parents | fc24c10424d2 |
children | 74912fe3d718 |
comparison
equal
deleted
inserted
replaced
17559:83785bb56062 | 17560:9ee25d7b1aed |
---|---|
17 rename = os.rename | 17 rename = os.rename |
18 expandglobs = False | 18 expandglobs = False |
19 | 19 |
20 umask = os.umask(0) | 20 umask = os.umask(0) |
21 os.umask(umask) | 21 os.umask(umask) |
22 | |
23 def split(p): | |
24 '''Same as os.path.split, but faster''' | |
25 ht = p.rsplit('/', 1) | |
26 if len(ht) == 1: | |
27 return '', p | |
28 nh = ht[0].rstrip('/') | |
29 if nh: | |
30 return nh, ht[1] | |
31 return ht | |
22 | 32 |
23 def openhardlinks(): | 33 def openhardlinks(): |
24 '''return true if it is safe to hold open file handles to hardlinks''' | 34 '''return true if it is safe to hold open file handles to hardlinks''' |
25 return True | 35 return True |
26 | 36 |