tests/readlink.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Thu, 02 Jul 2015 23:46:18 -0700
changeset 25716 d50677c3bf44
parent 25660 328739ea70c3
child 29175 7bcfb9090c86
permissions -rwxr-xr-x
revset: prefetch method in "parents" As already demonstrated, saving attribute lookup gains us some minor but noticeable performance improvements. revset #0: parents(all()) before) 0.024169 after ) 0.022756 94%

#!/usr/bin/env python

import errno, os, sys

for f in sys.argv[1:]:
    try:
        print f, '->', os.readlink(f)
    except OSError as err:
        if err.errno != errno.EINVAL:
            raise
        print f, 'not a symlink'

sys.exit(0)