Mercurial > hg
view tests/ls-l.py @ 40710:50a64c321c1e
branchmap: build the revbranchcache._namesreverse() only when required
On big repositories with a lot of named branches and that also increasing over
time, building of this dict can be expensive and shows up in profile.
For our internal repository, this saves ~0.05 seconds.
Thanks to Yuya for suggesting using util.propertycache() and
util.clearcachedproperty().
Differential Revision: https://phab.mercurial-scm.org/D5291
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Wed, 21 Nov 2018 17:17:26 +0300 |
parents | 3a333a582d7b |
children | 2372284d9457 |
line wrap: on
line source
#!/usr/bin/env python # like ls -l, but do not print date, user, or non-common mode bit, to avoid # using globs in tests. from __future__ import absolute_import, print_function import os import stat import sys def modestr(st): mode = st.st_mode result = '' if mode & stat.S_IFDIR: result += 'd' else: result += '-' for owner in ['USR', 'GRP', 'OTH']: for action in ['R', 'W', 'X']: if mode & getattr(stat, 'S_I%s%s' % (action, owner)): result += action.lower() else: result += '-' return result def sizestr(st): if st.st_mode & stat.S_IFREG: return '%7d' % st.st_size else: # do not show size for non regular files return ' ' * 7 os.chdir((sys.argv[1:] + ['.'])[0]) for name in sorted(os.listdir('.')): st = os.stat(name) print('%s %s %s' % (modestr(st), sizestr(st), name))