~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
                  S_ISCHR, S_ISBLK, S_ISFIFO, S_ISSOCK)
22
22
import sys
23
23
import time
 
24
import codecs
24
25
import warnings
25
26
 
26
27
from bzrlib.lazy_import import lazy_import
27
28
lazy_import(globals(), """
28
 
import codecs
29
29
from datetime import datetime
30
30
import errno
31
31
from ntpath import (abspath as _nt_abspath,
179
179
    try:
180
180
        return _kind_marker_map[kind]
181
181
    except KeyError:
182
 
        raise errors.BzrError('invalid file kind %r' % kind)
 
182
        # Slightly faster than using .get(, '') when the common case is that
 
183
        # kind will be found
 
184
        return ''
183
185
 
184
186
 
185
187
lexists = getattr(os.path, 'lexists', None)
1438
1440
    if width is not None:
1439
1441
        os.environ['COLUMNS'] = str(width)
1440
1442
 
1441
 
if sys.platform == 'win32':
1442
 
    # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from ReadConsoleInput but
1443
 
    # I've no idea how to plug that in the current design -- vila 20091216
1444
 
    pass
1445
 
else:
1446
 
    signal.signal(signal.SIGWINCH, _terminal_size_changed)
 
1443
 
 
1444
_registered_sigwinch = False
 
1445
 
 
1446
def watch_sigwinch():
 
1447
    """Register for SIGWINCH, once and only once."""
 
1448
    global _registered_sigwinch
 
1449
    if not _registered_sigwinch:
 
1450
        if sys.platform == 'win32':
 
1451
            # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from
 
1452
            # ReadConsoleInput but I've no idea how to plug that in
 
1453
            # the current design -- vila 20091216
 
1454
            pass
 
1455
        else:
 
1456
            signal.signal(signal.SIGWINCH, _terminal_size_changed)
 
1457
        _registered_sigwinch = True
1447
1458
 
1448
1459
 
1449
1460
def supports_executable():