Mercurial > hg
changeset 13013:92b0d669637f stable
subrepo: fix removing read-only svn files on Windows
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 17 Nov 2010 21:00:47 +0100 |
parents | e98bf6948092 |
children | d1c52354b0a9 |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Tue Nov 16 21:35:58 2010 +0100 +++ b/mercurial/subrepo.py Wed Nov 17 21:00:47 2010 +0100 @@ -6,6 +6,7 @@ # GNU General Public License version 2 or any later version. import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath +import stat from i18n import _ import config, util, node, error, cmdutil hg = None @@ -549,7 +550,18 @@ 'it has changes.\n' % self._path)) return self._ui.note(_('removing subrepo %s\n') % self._path) - shutil.rmtree(self._ctx._repo.wjoin(self._path)) + + def onerror(function, path, excinfo): + if function is not os.remove: + raise + # 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) + + shutil.rmtree(self._ctx._repo.wjoin(self._path), onerror=onerror) def get(self, state): status = self._svncommand(['checkout', state[0], '--revision', state[1]])