mercurial/subrepo.py
branchstable
changeset 13013 92b0d669637f
parent 12930 9bb180abc4d0
child 13014 d1c52354b0a9
equal deleted inserted replaced
13007:e98bf6948092 13013:92b0d669637f
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath
     8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath
       
     9 import stat
     9 from i18n import _
    10 from i18n import _
    10 import config, util, node, error, cmdutil
    11 import config, util, node, error, cmdutil
    11 hg = None
    12 hg = None
    12 
    13 
    13 nullstate = ('', '', 'empty')
    14 nullstate = ('', '', 'empty')
   547         if self.dirty():
   548         if self.dirty():
   548             self._ui.warn(_('not removing repo %s because '
   549             self._ui.warn(_('not removing repo %s because '
   549                             'it has changes.\n' % self._path))
   550                             'it has changes.\n' % self._path))
   550             return
   551             return
   551         self._ui.note(_('removing subrepo %s\n') % self._path)
   552         self._ui.note(_('removing subrepo %s\n') % self._path)
   552         shutil.rmtree(self._ctx._repo.wjoin(self._path))
   553 
       
   554         def onerror(function, path, excinfo):
       
   555             if function is not os.remove:
       
   556                 raise
       
   557             # read-only files cannot be unlinked under Windows
       
   558             s = os.stat(path)
       
   559             if (s.st_mode & stat.S_IWRITE) != 0:
       
   560                 raise
       
   561             os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)
       
   562             os.remove(path)
       
   563 
       
   564         shutil.rmtree(self._ctx._repo.wjoin(self._path), onerror=onerror)
   553 
   565 
   554     def get(self, state):
   566     def get(self, state):
   555         status = self._svncommand(['checkout', state[0], '--revision', state[1]])
   567         status = self._svncommand(['checkout', state[0], '--revision', state[1]])
   556         if not re.search('Checked out revision [0-9]+.', status):
   568         if not re.search('Checked out revision [0-9]+.', status):
   557             raise util.Abort(status.splitlines()[-1])
   569             raise util.Abort(status.splitlines()[-1])