comparison mercurial/scmutil.py @ 18900:02ee846b246a

scmutil: rewrite dirs in C, use if available This is over twice as fast as the Python dirs code. Upcoming changes will nearly double its speed again. perfdirs results for a working dir with 170,000 files: Python 638 msec C 244
author Bryan O'Sullivan <bryano@fb.com>
date Wed, 10 Apr 2013 15:08:27 -0700
parents 856960173630
children e75b72fffdfe
comparison
equal deleted inserted replaced
18899:d8ff607ef721 18900:02ee846b246a
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from i18n import _ 8 from i18n import _
9 from mercurial.node import nullrev 9 from mercurial.node import nullrev
10 import util, error, osutil, revset, similar, encoding, phases 10 import util, error, osutil, revset, similar, encoding, phases, parsers
11 import match as matchmod 11 import match as matchmod
12 import os, errno, re, stat, glob 12 import os, errno, re, stat, glob
13 13
14 if os.name == 'nt': 14 if os.name == 'nt':
15 import scmwindows as scmplatform 15 import scmwindows as scmplatform
925 return self._dirs.iterkeys() 925 return self._dirs.iterkeys()
926 926
927 def __contains__(self, d): 927 def __contains__(self, d):
928 return d in self._dirs 928 return d in self._dirs
929 929
930 if util.safehasattr(parsers, 'dirs'):
931 dirs = parsers.dirs
932
930 def finddirs(path): 933 def finddirs(path):
931 pos = path.rfind('/') 934 pos = path.rfind('/')
932 while pos != -1: 935 while pos != -1:
933 yield path[:pos] 936 yield path[:pos]
934 pos = path.rfind('/', 0, pos) 937 pos = path.rfind('/', 0, pos)