~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2009-05-29 15:06:16 UTC
  • mfrom: (4392 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4460.
  • Revision ID: john@arbash-meinel.com-20090529150616-m29oaesf6ekxr489
Merge bzr.dev, bringing in the gc stacking fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
O_BINARY = getattr(os, 'O_BINARY', 0)
78
78
 
79
79
 
 
80
def get_unicode_argv():
 
81
    try:
 
82
        user_encoding = get_user_encoding()
 
83
        return [a.decode(user_encoding) for a in sys.argv[1:]]
 
84
    except UnicodeDecodeError:
 
85
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
 
86
                                                            "encoding." % a))
 
87
 
 
88
 
80
89
def make_readonly(filename):
81
90
    """Make a filename read-only."""
82
91
    mod = os.lstat(filename).st_mode
390
399
    def rmtree(path, ignore_errors=False, onerror=_win32_delete_readonly):
391
400
        """Replacer for shutil.rmtree: could remove readonly dirs/files"""
392
401
        return shutil.rmtree(path, ignore_errors, onerror)
 
402
 
 
403
    f = win32utils.get_unicode_argv     # special function or None
 
404
    if f is not None:
 
405
        get_unicode_argv = f
 
406
 
393
407
elif sys.platform == 'darwin':
394
408
    getcwd = _mac_getcwd
395
409
 
853
867
    return pathjoin(*p)
854
868
 
855
869
 
 
870
def parent_directories(filename):
 
871
    """Return the list of parent directories, deepest first.
 
872
    
 
873
    For example, parent_directories("a/b/c") -> ["a/b", "a"].
 
874
    """
 
875
    parents = []
 
876
    parts = splitpath(dirname(filename))
 
877
    while parts:
 
878
        parents.append(joinpath(parts))
 
879
        parts.pop()
 
880
    return parents
 
881
 
 
882
 
856
883
try:
857
884
    from bzrlib._chunks_to_lines_pyx import chunks_to_lines
858
885
except ImportError: