/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: Martin Pool
  • Date: 2010-04-28 07:03:38 UTC
  • mfrom: (5188 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@sourcefrog.net-20100428070338-2af8y3takgfkrkyp
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
from shutil import (
40
40
    rmtree,
41
41
    )
42
 
import signal
43
42
import socket
44
43
import subprocess
45
44
import tempfile
1366
1365
        platform or Python version.
1367
1366
    """
1368
1367
    try:
 
1368
        import signal
1369
1369
        siginterrupt = signal.siginterrupt
 
1370
    except ImportError:
 
1371
        # This python implementation doesn't provide signal support, hence no
 
1372
        # handler exists
 
1373
        return None
1370
1374
    except AttributeError:
1371
1375
        # siginterrupt doesn't exist on this platform, or for this version
1372
1376
        # of Python.
1483
1487
 
1484
1488
 
1485
1489
_registered_sigwinch = False
1486
 
 
1487
1490
def watch_sigwinch():
1488
 
    """Register for SIGWINCH, once and only once."""
 
1491
    """Register for SIGWINCH, once and only once.
 
1492
 
 
1493
    Do nothing if the signal module is not available.
 
1494
    """
1489
1495
    global _registered_sigwinch
1490
1496
    if not _registered_sigwinch:
1491
 
        if sys.platform == 'win32':
1492
 
            # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from
1493
 
            # ReadConsoleInput but I've no idea how to plug that in
1494
 
            # the current design -- vila 20091216
 
1497
        try:
 
1498
            import signal
 
1499
            if getattr(signal, "SIGWINCH", None) is not None:
 
1500
                set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
 
1501
        except ImportError:
 
1502
            # python doesn't provide signal support, nothing we can do about it
1495
1503
            pass
1496
 
        else:
1497
 
            set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
1498
1504
        _registered_sigwinch = True
1499
1505
 
1500
1506
 
1821
1827
            real_handlers[kind](abspath, relpath)
1822
1828
 
1823
1829
 
1824
 
def copy_ownership(dst, src=None):
 
1830
def copy_ownership_from_path(dst, src=None):
1825
1831
    """Copy usr/grp ownership from src file/dir to dst file/dir.
1826
1832
 
1827
1833
    If src is None, the containing directory is used as source. If chown
1843
1849
        trace.warning("Unable to copy ownership from '%s' to '%s': IOError: %s." % (src, dst, e))
1844
1850
 
1845
1851
 
1846
 
def mkdir_with_ownership(path, ownership_src=None):
1847
 
    """Create the directory 'path' with specified ownership.
1848
 
 
1849
 
    If ownership_src is given, copies (chown) usr/grp ownership
1850
 
    from 'ownership_src' to 'path'. If ownership_src is None, use the
1851
 
    containing dir ownership.
1852
 
    """
1853
 
    os.mkdir(path)
1854
 
    copy_ownership(path, ownership_src)
1855
 
 
1856
 
 
1857
 
def open_with_ownership(filename, mode='r', bufsize=-1, ownership_src=None):
1858
 
    """Open the file 'filename' with the specified ownership.
1859
 
 
1860
 
    If ownership_src is specified, copy usr/grp ownership from ownership_src
1861
 
    to filename. If ownership_src is None, copy ownership from containing
1862
 
    directory.
1863
 
    Returns the opened file object.
1864
 
    """
1865
 
    f = open(filename, mode, bufsize)
1866
 
    copy_ownership(filename, ownership_src)
1867
 
    return f
1868
 
 
1869
 
 
1870
1852
def path_prefix_key(path):
1871
1853
    """Generate a prefix-order path key for path.
1872
1854