hgext/purge.py
changeset 8044 c1e2b7407dc3
parent 8043 b777dd8f7836
child 8076 5ec526c1a32f
equal deleted inserted replaced
8043:b777dd8f7836 8044:c1e2b7407dc3
    71                 ui.warn(_('warning: %s\n') % m)
    71                 ui.warn(_('warning: %s\n') % m)
    72         else:
    72         else:
    73             ui.write('%s%s' % (name, eol))
    73             ui.write('%s%s' % (name, eol))
    74 
    74 
    75     def removefile(path):
    75     def removefile(path):
    76         # read-only files cannot be unlinked under Windows
    76         try:
    77         s = os.stat(path)
    77             os.remove(path)
    78         if (s.st_dev & stat.S_IWRITE) == 0:
    78         except OSError:
    79             os.chmod(path, s.st_mode | stat.S_IWRITE)
    79             # read-only files cannot be unlinked under Windows
    80         os.remove(path)
    80             s = os.stat(path)
       
    81             if (s.st_mode & stat.S_IWRITE) != 0:
       
    82                 raise
       
    83             os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)
       
    84             os.remove(path)
    81 
    85 
    82     directories = []
    86     directories = []
    83     match = cmdutil.match(repo, dirs, opts)
    87     match = cmdutil.match(repo, dirs, opts)
    84     match.dir = directories.append
    88     match.dir = directories.append
    85     status = repo.status(match=match, ignored=opts['all'], unknown=True)
    89     status = repo.status(match=match, ignored=opts['all'], unknown=True)