~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Aaron Bentley
  • Date: 2005-09-25 23:51:03 UTC
  • mto: (1185.14.1) (1393.1.21)
  • mto: This revision was merged to the branch mainline in revision 1391.
  • Revision ID: aaron.bentley@utoronto.ca-20050925235103-08e4e26ee781cb74
Made copy_multi_immutable create hardlinks opportunistically

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.errors import BzrError
24
24
from bzrlib.trace import mutter
25
25
import bzrlib
 
26
from shutil import copyfile
26
27
 
27
28
def make_readonly(filename):
28
29
    """Make a filename read-only."""
488
489
        return os.path.join(p1, p2)
489
490
    
490
491
 
491
 
def extern_command(cmd, ignore_errors = False):
492
 
    mutter('external command: %s' % `cmd`)
493
 
    if os.system(cmd):
494
 
        if not ignore_errors:
495
 
            raise BzrError('command failed')
496
 
 
497
 
 
498
492
def _read_config_value(name):
499
493
    """Read a config value from the file ~/.bzr.conf/<name>
500
494
    Return None if the file does not exist"""
506
500
            return None
507
501
        raise
508
502
 
509
 
 
 
503
def link_or_copy(src, dest):
 
504
    """Hardlink a file, or copy it if it can't be hardlinked."""
 
505
    if sys.platform == 'win32':
 
506
        copyfile(src, dest)
 
507
        return
 
508
    try:
 
509
        os.link(src, dest)
 
510
    except (OSError, IOError), e:
 
511
        if e.errno != errno.EXDEV:
 
512
            raise
 
513
        copyfile(src, dest)