~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Robert Collins
  • Date: 2005-09-29 02:55:34 UTC
  • mfrom: (1185.1.47)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050929025534-1782933743abbfd5
update with integration

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
501
502
        return os.path.join(p1, p2)
502
503
    
503
504
 
504
 
def extern_command(cmd, ignore_errors = False):
505
 
    mutter('external command: %s' % `cmd`)
506
 
    if os.system(cmd):
507
 
        if not ignore_errors:
508
 
            raise BzrError('command failed')
509
 
 
510
 
 
511
505
def _read_config_value(name):
512
506
    """Read a config value from the file ~/.bzr.conf/<name>
513
507
    Return None if the file does not exist"""
518
512
        if e.errno == errno.ENOENT:
519
513
            return None
520
514
        raise
 
515
 
 
516
 
 
517
def hardlinks_good():
 
518
    return sys.platform not in ('win32', 'cygwin', 'darwin')
 
519
 
 
520
 
 
521
def link_or_copy(src, dest):
 
522
    """Hardlink a file, or copy it if it can't be hardlinked."""
 
523
    if not hardlinks_good():
 
524
        copyfile(src, dest)
 
525
        return
 
526
    try:
 
527
        os.link(src, dest)
 
528
    except (OSError, IOError), e:
 
529
        if e.errno != errno.EXDEV:
 
530
            raise
 
531
        copyfile(src, dest)