/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2008-09-11 19:36:38 UTC
  • mfrom: (3703 +trunk)
  • mto: (3705.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 3708.
  • Revision ID: v.ladeuil+lp@free.fr-20080911193638-wtjyc1kcmacc6t1f
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1278
1278
    """
1279
1279
    _lstat = os.lstat
1280
1280
    _directory = _directory_kind
1281
 
    _listdir = os.listdir
 
1281
    # Use C accelerated directory listing.
 
1282
    _listdir = _read_dir
1282
1283
    _kind_from_mode = _formats.get
1283
1284
 
1284
1285
    # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
1294
1295
 
1295
1296
        dirblock = []
1296
1297
        append = dirblock.append
1297
 
        for name in sorted(_listdir(top)):
 
1298
        # read_dir supplies in should-stat order.
 
1299
        for _, name in sorted(_listdir(top)):
1298
1300
            abspath = top_slash + name
1299
1301
            statvalue = _lstat(abspath)
1300
1302
            kind = _kind_from_mode(statvalue.st_mode & 0170000, 'unknown')
1301
1303
            append((relprefix + name, name, kind, statvalue, abspath))
 
1304
        dirblock.sort()
1302
1305
        yield (relroot, top), dirblock
1303
1306
 
1304
1307
        # push the user specified dirs from dirblock
1467
1470
    return user_encoding
1468
1471
 
1469
1472
 
 
1473
def get_host_name():
 
1474
    """Return the current unicode host name.
 
1475
 
 
1476
    This is meant to be used in place of socket.gethostname() because that
 
1477
    behaves inconsistently on different platforms.
 
1478
    """
 
1479
    if sys.platform == "win32":
 
1480
        import win32utils
 
1481
        return win32utils.get_host_name()
 
1482
    else:
 
1483
        import socket
 
1484
        return socket.gethostname().decode(get_user_encoding())
 
1485
 
 
1486
 
1470
1487
def recv_all(socket, bytes):
1471
1488
    """Receive an exact number of bytes.
1472
1489
 
1543
1560
        base = abspath(pathjoin(base, '..', '..'))
1544
1561
    filename = pathjoin(base, resource_relpath)
1545
1562
    return open(filename, 'rU').read()
 
1563
 
 
1564
 
 
1565
try:
 
1566
    from bzrlib._readdir_pyx import read_dir as _read_dir
 
1567
except ImportError:
 
1568
    from bzrlib._readdir_py import read_dir as _read_dir