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