##// END OF EJS Templates
purge: prefer util.unlink instead over own removefile
Christian Ebert -
r21983:52d34d54 default
parent child Browse files
Show More
@@ -95,17 +95,6 b' def purge(ui, repo, *dirs, **opts):'
95 else:
95 else:
96 ui.write('%s%s' % (name, eol))
96 ui.write('%s%s' % (name, eol))
97
97
98 def removefile(path):
99 try:
100 os.remove(path)
101 except OSError:
102 # read-only files cannot be unlinked under Windows
103 s = os.stat(path)
104 if (s.st_mode & stat.S_IWRITE) != 0:
105 raise
106 os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)
107 os.remove(path)
108
109 directories = []
98 directories = []
110 match = scmutil.match(repo[None], dirs, opts)
99 match = scmutil.match(repo[None], dirs, opts)
111 match.explicitdir = match.traversedir = directories.append
100 match.explicitdir = match.traversedir = directories.append
@@ -115,7 +104,7 b' def purge(ui, repo, *dirs, **opts):'
115 for f in sorted(status[4] + status[5]):
104 for f in sorted(status[4] + status[5]):
116 if act:
105 if act:
117 ui.note(_('removing file %s\n') % f)
106 ui.note(_('removing file %s\n') % f)
118 remove(removefile, f)
107 remove(util.unlink, f)
119
108
120 if removedirs:
109 if removedirs:
121 for f in sorted(directories, reverse=True):
110 for f in sorted(directories, reverse=True):
General Comments 0
You need to be logged in to leave comments. Login now