~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Alexander Belchenko
  • Date: 2007-11-12 21:35:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3008.
  • Revision ID: bialix@ukr.net-20071112213515-oteyfud32v1yzgrl
teach fancy_rename to handle change case renames in possible case-insensitive filesystem

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
 
235
235
    success = False
236
236
    try:
237
 
        # This may throw an exception, in which case success will
238
 
        # not be set.
239
 
        rename_func(old, new)
240
 
        success = True
 
237
        try:
 
238
            # This may throw an exception, in which case success will
 
239
            # not be set.
 
240
            rename_func(old, new)
 
241
            success = True
 
242
        except (IOError, OSError), e:
 
243
            # case insensitive filesystem may be?
 
244
            if (not file_existed
 
245
                or e.errno not in (None, errno.ENOENT, errno.ENOTDIR)
 
246
                or old.lower() != new.lower()):
 
247
                raise
241
248
    finally:
242
249
        if file_existed:
243
250
            # If the file used to exist, rename it back into place
340
347
    On win32, if new exists, it must be moved out of the way first,
341
348
    and then deleted. 
342
349
    """
343
 
    # to change case on win32 you don't need fancy rename
344
 
    if old.lower() == new.lower():
345
 
        os.rename(old,new)
346
 
        return
347
350
    try:
348
351
        fancy_rename(old, new, rename_func=os.rename, unlink_func=os.unlink)
349
352
    except OSError, e: