##// END OF EJS Templates
vfs: add rmtree...
FUJIWARA Katsunori -
r24689:ca3a9009 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from mercurial.node import nullrev'
10 import util, error, osutil, revset, similar, encoding, phases
10 import util, error, osutil, revset, similar, encoding, phases
11 import pathutil
11 import pathutil
12 import match as matchmod
12 import match as matchmod
13 import os, errno, re, glob, tempfile
13 import os, errno, re, glob, tempfile, shutil, stat
14
14
15 if os.name == 'nt':
15 if os.name == 'nt':
16 import scmwindows as scmplatform
16 import scmwindows as scmplatform
@@ -316,6 +316,26 b' class abstractvfs(object):'
316 def readlink(self, path):
316 def readlink(self, path):
317 return os.readlink(self.join(path))
317 return os.readlink(self.join(path))
318
318
319 def rmtree(self, path=None, ignore_errors=False, forcibly=False):
320 """Remove a directory tree recursively
321
322 If ``forcibly``, this tries to remove READ-ONLY files, too.
323 """
324 if forcibly:
325 def onerror(function, path, excinfo):
326 if function is not os.remove:
327 raise
328 # read-only files cannot be unlinked under Windows
329 s = os.stat(path)
330 if (s.st_mode & stat.S_IWRITE) != 0:
331 raise
332 os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)
333 os.remove(path)
334 else:
335 onerror = None
336 return shutil.rmtree(self.join(path),
337 ignore_errors=ignore_errors, onerror=onerror)
338
319 def setflags(self, path, l, x):
339 def setflags(self, path, l, x):
320 return util.setflags(self.join(path), l, x)
340 return util.setflags(self.join(path), l, x)
321
341
General Comments 0
You need to be logged in to leave comments. Login now