~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Robert Collins
  • Date: 2005-09-28 07:03:54 UTC
  • mfrom: (1185.10.7)
  • mto: (1092.2.19)
  • mto: This revision was merged to the branch mainline in revision 1391.
  • Revision ID: robertc@robertcollins.net-20050928070354-fb49ab0b2563d5b2
Aarons branch --basis patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
 
19
from shutil import copyfile
19
20
from stat import (S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE,
20
21
                  S_ISCHR, S_ISBLK, S_ISFIFO, S_ISSOCK)
21
22
import errno
471
472
        return os.path.join(p1, p2)
472
473
    
473
474
 
474
 
def extern_command(cmd, ignore_errors = False):
475
 
    mutter('external command: %s' % `cmd`)
476
 
    if os.system(cmd):
477
 
        if not ignore_errors:
478
 
            raise BzrError('command failed')
479
 
 
480
 
 
481
475
def _read_config_value(name):
482
476
    """Read a config value from the file ~/.bzr.conf/<name>
483
477
    Return None if the file does not exist"""
488
482
        if e.errno == errno.ENOENT:
489
483
            return None
490
484
        raise
 
485
 
 
486
 
 
487
def hardlinks_good():
 
488
    return sys.platform not in ('win32', 'cygwin', 'darwin')
 
489
 
 
490
 
 
491
def link_or_copy(src, dest):
 
492
    """Hardlink a file, or copy it if it can't be hardlinked."""
 
493
    if not hardlinks_good():
 
494
        copyfile(src, dest)
 
495
        return
 
496
    try:
 
497
        os.link(src, dest)
 
498
    except (OSError, IOError), e:
 
499
        if e.errno != errno.EXDEV:
 
500
            raise
 
501
        copyfile(src, dest)