Show More
@@ -29,7 +29,7 b'' | |||
|
29 | 29 | |
|
30 | 30 | from mercurial import util, commands, cmdutil |
|
31 | 31 | from mercurial.i18n import _ |
|
32 | import os | |
|
32 | import os, stat | |
|
33 | 33 | |
|
34 | 34 | def purge(ui, repo, *dirs, **opts): |
|
35 | 35 | '''removes files not tracked by Mercurial |
@@ -72,6 +72,13 b' def purge(ui, repo, *dirs, **opts):' | |||
|
72 | 72 | else: |
|
73 | 73 | ui.write('%s%s' % (name, eol)) |
|
74 | 74 | |
|
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) | |
|
81 | ||
|
75 | 82 | directories = [] |
|
76 | 83 | match = cmdutil.match(repo, dirs, opts) |
|
77 | 84 | match.dir = directories.append |
@@ -79,7 +86,7 b' def purge(ui, repo, *dirs, **opts):' | |||
|
79 | 86 | |
|
80 | 87 | for f in util.sort(status[4] + status[5]): |
|
81 | 88 | ui.note(_('Removing file %s\n') % f) |
|
82 |
remove( |
|
|
89 | remove(removefile, f) | |
|
83 | 90 | |
|
84 | 91 | for f in util.sort(directories)[::-1]: |
|
85 | 92 | if match(f) and not os.listdir(repo.wjoin(f)): |
General Comments 0
You need to be logged in to leave comments.
Login now