~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Robert Collins
  • Date: 2005-10-18 06:42:17 UTC
  • mfrom: (0.2.1)
  • mto: This revision was merged to the branch mainline in revision 1463.
  • Revision ID: robertc@robertcollins.net-20051018064217-e810bd94c74a9ad1
Factor out the guts of 'pull' from the command into WorkingTree.pull().
(Robert Collins)

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
 
 
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
 
122
    
138
123
 
139
124
def backup_file(fn):
140
125
    """Copy a file to a backup.
468
453
    os.path.commonprefix (python2.4) has a bad bug that it works just
469
454
    on string prefixes, assuming that '/u' is a prefix of '/u2'.  This
470
455
    avoids that problem."""
471
 
    rp = abspath(path)
 
456
    rp = os.path.abspath(path)
472
457
 
473
458
    s = []
474
459
    head = rp