~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2005-10-19 09:34:39 UTC
  • mfrom: (1185.16.78)
  • mto: (1185.16.102)
  • mto: This revision was merged to the branch mainline in revision 1488.
  • Revision ID: jelmer@samba.org-20051019093439-e1d8e3508d1ba46b
MergeĀ fromĀ Martin

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        return F(f)
120
120
    else:
121
121
        return os.path.join(F(p), e)
122
 
    
 
122
 
 
123
if os.name == "posix":
 
124
    # In Python 2.4.2 and older, os.path.abspath and os.path.realpath
 
125
    # choke on a Unicode string containing a relative path if
 
126
    # os.getcwd() returns a non-sys.getdefaultencoding()-encoded
 
127
    # string.
 
128
    _fs_enc = sys.getfilesystemencoding()
 
129
    def abspath(path):
 
130
        return os.path.abspath(path.encode(_fs_enc)).decode(_fs_enc)
 
131
    def realpath(path):
 
132
        return os.path.realpath(path.encode(_fs_enc)).decode(_fs_enc)
 
133
else:
 
134
    # We need to use the Unicode-aware os.path.abspath and
 
135
    # os.path.realpath on Windows systems.
 
136
    abspath = os.path.abspath
 
137
    realpath = os.path.realpath
123
138
 
124
139
def backup_file(fn):
125
140
    """Copy a file to a backup.
453
468
    os.path.commonprefix (python2.4) has a bad bug that it works just
454
469
    on string prefixes, assuming that '/u' is a prefix of '/u2'.  This
455
470
    avoids that problem."""
456
 
    rp = os.path.abspath(path)
 
471
    rp = abspath(path)
457
472
 
458
473
    s = []
459
474
    head = rp