~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-12 08:03:28 UTC
  • mfrom: (4949.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100112080328-cb0tvu90uglxlrw0
(mbp) merge 2.0 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
    :param unlink_func: A way to delete the target file if the full rename
206
206
        succeeds
207
207
    """
 
208
    new = safe_unicode(new)
208
209
    # sftp rename doesn't allow overwriting, so play tricks:
209
210
    base = os.path.basename(new)
210
211
    dirname = os.path.dirname(new)
211
 
    # callers use different encodings for the paths so the following MUST
212
 
    # respect that. We rely on python upcasting to unicode if new is unicode
213
 
    # and keeping a str if not.
214
 
    tmp_name = 'tmp.%s.%.9f.%d.%s' % (base, time.time(),
215
 
                                      os.getpid(), rand_chars(10))
 
212
    tmp_name = u'tmp.%s.%.9f.%d.%s' % (base, time.time(),
 
213
                                       os.getpid(), rand_chars(10))
216
214
    tmp_name = pathjoin(dirname, tmp_name)
217
215
 
218
216
    # Rename the file out of the way, but keep track if it didn't exist