##// END OF EJS Templates
purge: fix b777dd8f7836 (remove read-only files)...
Patrick Mezard -
r8044:c1e2b740 default
parent child Browse files
Show More
@@ -73,11 +73,15 b' def purge(ui, repo, *dirs, **opts):'
73 73 ui.write('%s%s' % (name, eol))
74 74
75 75 def removefile(path):
76 # read-only files cannot be unlinked under Windows
77 s = os.stat(path)
78 if (s.st_dev & stat.S_IWRITE) == 0:
79 os.chmod(path, s.st_mode | stat.S_IWRITE)
80 os.remove(path)
76 try:
77 os.remove(path)
78 except OSError:
79 # read-only files cannot be unlinked under Windows
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 86 directories = []
83 87 match = cmdutil.match(repo, dirs, opts)
@@ -38,7 +38,7 b' touch untracked_file_readonly'
38 38 python <<EOF
39 39 import os, stat
40 40 f= 'untracked_file_readonly'
41 os.chmod(f, os.stat(f).st_mode & ~stat.S_IWRITE)
41 os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
42 42 EOF
43 43 hg purge -p
44 44 hg purge -v
General Comments 0
You need to be logged in to leave comments. Login now