/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

Merge fetch-spec-everything-not-in-other.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
1461
1461
    # a similar effect.
1462
1462
 
1463
1463
    # If BZR_COLUMNS is set, take it, user is always right
 
1464
    # Except if they specified 0 in which case, impose no limit here
1464
1465
    try:
1465
 
        return int(os.environ['BZR_COLUMNS'])
 
1466
        width = int(os.environ['BZR_COLUMNS'])
1466
1467
    except (KeyError, ValueError):
1467
 
        pass
 
1468
        width = None
 
1469
    if width is not None:
 
1470
        if width > 0:
 
1471
            return width
 
1472
        else:
 
1473
            return None
1468
1474
 
1469
1475
    isatty = getattr(sys.stdout, 'isatty', None)
1470
1476
    if isatty is None or not isatty():
2376
2382
        counter += 1
2377
2383
        name = "%s.~%d~" % (base, counter)
2378
2384
    return name
 
2385
 
 
2386
 
 
2387
def set_fd_cloexec(fd):
 
2388
    """Set a Unix file descriptor's FD_CLOEXEC flag.  Do nothing if platform
 
2389
    support for this is not available.
 
2390
    """
 
2391
    try:
 
2392
        import fcntl
 
2393
        old = fcntl.fcntl(fd, fcntl.F_GETFD)
 
2394
        fcntl.fcntl(fd, fcntl.F_SETFD, old | fcntl.FD_CLOEXEC)
 
2395
    except (ImportError, AttributeError):
 
2396
        # Either the fcntl module or specific constants are not present
 
2397
        pass