~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 11:57:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220115714-2ru3hfappjweeg7q
Don't use no-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
967
967
    # they tend to happen very early in startup when we can't check config
968
968
    # files etc, and also we want to report all failures but not spam the user
969
969
    # with 10 warnings.
970
 
    from bzrlib import trace
971
970
    exception_str = str(exception)
972
971
    if exception_str not in _extension_load_failures:
973
972
        trace.mutter("failed to load compiled extension: %s" % exception_str)
1875
1874
        s = os.stat(src)
1876
1875
        chown(dst, s.st_uid, s.st_gid)
1877
1876
    except OSError, e:
1878
 
        trace.warning("Unable to copy ownership from '%s' to '%s': IOError: %s." % (src, dst, e))
 
1877
        trace.warning(
 
1878
            'Unable to copy ownership from "%s" to "%s". '
 
1879
            'You may want to set it manually.', src, dst)
 
1880
        trace.log_exception_quietly()
1879
1881
 
1880
1882
 
1881
1883
def path_prefix_key(path):
2354
2356
        raise errors.BzrError("Can't decode username as %s." % \
2355
2357
                user_encoding)
2356
2358
    return username
 
2359
 
 
2360
 
 
2361
def available_backup_name(base, exists):
 
2362
    """Find a non-existing backup file name.
 
2363
 
 
2364
    This will *not* create anything, this only return a 'free' entry.  This
 
2365
    should be used for checking names in a directory below a locked
 
2366
    tree/branch/repo to avoid race conditions. This is LBYL (Look Before You
 
2367
    Leap) and generally discouraged.
 
2368
 
 
2369
    :param base: The base name.
 
2370
 
 
2371
    :param exists: A callable returning True if the path parameter exists.
 
2372
    """
 
2373
    counter = 1
 
2374
    name = "%s.~%d~" % (base, counter)
 
2375
    while exists(name):
 
2376
        counter += 1
 
2377
        name = "%s.~%d~" % (base, counter)
 
2378
    return name