purge: prefer util.unlink instead over own removefile
authorChristian Ebert <blacktrash@gmx.net>
Sat, 02 Aug 2014 09:45:21 +0100
changeset 21983 52d34d5415c9
parent 21982 97d5aca9bb66
child 21984 977a0b9af5ac
purge: prefer util.unlink instead over own removefile
hgext/purge.py
--- a/hgext/purge.py	Sat Aug 02 09:44:45 2014 +0100
+++ b/hgext/purge.py	Sat Aug 02 09:45:21 2014 +0100
@@ -95,17 +95,6 @@
         else:
             ui.write('%s%s' % (name, eol))
 
-    def removefile(path):
-        try:
-            os.remove(path)
-        except OSError:
-            # read-only files cannot be unlinked under Windows
-            s = os.stat(path)
-            if (s.st_mode & stat.S_IWRITE) != 0:
-                raise
-            os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)
-            os.remove(path)
-
     directories = []
     match = scmutil.match(repo[None], dirs, opts)
     match.explicitdir = match.traversedir = directories.append
@@ -115,7 +104,7 @@
         for f in sorted(status[4] + status[5]):
             if act:
                 ui.note(_('removing file %s\n') % f)
-            remove(removefile, f)
+            remove(util.unlink, f)
 
     if removedirs:
         for f in sorted(directories, reverse=True):