comparison mercurial/subrepo.py @ 24688:897a0715ee71

subrepo: use vfs.readdir instead of os.listdir to avoid expensive stat calls "kind" information given from "vfs.readdir()" makes expensive stat calls "os.path.isdir()" and "os.path.islink()" useless.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 11 Apr 2015 00:47:09 +0900
parents 47e7d5fbbf04
children d1ddf1fe5d33
comparison
equal deleted inserted replaced
24687:28d76bc069db 24688:897a0715ee71
1630 return 1630 return
1631 # we can't fully delete the repository as it may contain 1631 # we can't fully delete the repository as it may contain
1632 # local-only history 1632 # local-only history
1633 self.ui.note(_('removing subrepo %s\n') % self._relpath) 1633 self.ui.note(_('removing subrepo %s\n') % self._relpath)
1634 self._gitcommand(['config', 'core.bare', 'true']) 1634 self._gitcommand(['config', 'core.bare', 'true'])
1635 for f in os.listdir(self._abspath): 1635 for f, kind in self.wvfs.readdir():
1636 if f == '.git': 1636 if f == '.git':
1637 continue 1637 continue
1638 path = os.path.join(self._abspath, f) 1638 path = os.path.join(self._abspath, f)
1639 if os.path.isdir(path) and not os.path.islink(path): 1639 if kind == stat.S_IFDIR:
1640 shutil.rmtree(path) 1640 shutil.rmtree(path)
1641 else: 1641 else:
1642 os.remove(path) 1642 os.remove(path)
1643 1643
1644 def archive(self, archiver, prefix, match=None): 1644 def archive(self, archiver, prefix, match=None):