/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-10 19:59:55 UTC
  • mfrom: (1704 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060510195955-df080afb1daa3a96
[merge] bzr.dev 1704

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import os
25
25
import re
26
26
import sha
 
27
import shutil
27
28
import string
28
29
import sys
29
30
import time
224
225
    fancy_rename(old, new, rename_func=os.rename, unlink_func=os.unlink)
225
226
 
226
227
 
227
 
# Default is to just use the python builtins
 
228
# Default is to just use the python builtins, but these can be rebound on
 
229
# particular platforms.
228
230
abspath = _posix_abspath
229
231
realpath = _posix_realpath
230
232
pathjoin = os.path.join
234
236
rename = os.rename
235
237
dirname = os.path.dirname
236
238
basename = os.path.basename
 
239
rmtree = shutil.rmtree
237
240
 
238
241
MIN_ABS_PATHLENGTH = 1
239
242
 
249
252
 
250
253
    MIN_ABS_PATHLENGTH = 3
251
254
 
 
255
    def _win32_delete_readonly(function, path, excinfo):
 
256
        """Error handler for shutil.rmtree function [for win32]
 
257
        Helps to remove files and dirs marked as read-only.
 
258
        """
 
259
        type_, value = excinfo[:2]
 
260
        if function in (os.remove, os.rmdir) \
 
261
            and type_ == OSError \
 
262
            and value.errno == errno.EACCES:
 
263
            bzrlib.osutils.make_writable(path)
 
264
            function(path)
 
265
        else:
 
266
            raise
 
267
 
 
268
    def rmtree(path, ignore_errors=False, onerror=_win32_delete_readonly):
 
269
        """Replacer for shutil.rmtree: could remove readonly dirs/files"""
 
270
        return shutil.rmtree(path, ignore_errors, onerror)
 
271
 
252
272
 
253
273
def normalizepath(f):
254
274
    if hasattr(os.path, 'realpath'):