tests/readlink.py
author skarlage <skarlage@fb.com>
Thu, 30 Jun 2016 08:38:19 -0700
changeset 29498 1b38cfde9530
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
revert: don't backup if no files reverted in interactive mode (issue4793) When reverting interactively, we always backup files before prompting the user to find out if they actually want to revert them. This can create spurious *.orig files if a user enters an interactive revert session and then doesn't revert any files. Instead, we should only backup files that are actually being touched.

#!/usr/bin/env python

from __future__ import absolute_import, print_function

import errno
import os
import 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, '->', f, 'not a symlink')

sys.exit(0)