/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: Andrew Bennetts
  • Date: 2009-11-19 06:28:13 UTC
  • mfrom: (4811 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4812.
  • Revision ID: andrew.bennetts@canonical.com-20091119062813-t6sd6gwbot8nfyze
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
    else:
225
225
        file_existed = True
226
226
 
 
227
    failure_exc = None
227
228
    success = False
228
229
    try:
229
230
        try:
235
236
            # source and target may be aliases of each other (e.g. on a
236
237
            # case-insensitive filesystem), so we may have accidentally renamed
237
238
            # source by when we tried to rename target
238
 
            if not (file_existed and e.errno in (None, errno.ENOENT)):
239
 
                raise
 
239
            failure_exc = sys.exc_info()
 
240
            if (file_existed and e.errno in (None, errno.ENOENT)
 
241
                and old.lower() == new.lower()):
 
242
                # source and target are the same file on a case-insensitive
 
243
                # filesystem, so we don't generate an exception
 
244
                failure_exc = None
240
245
    finally:
241
246
        if file_existed:
242
247
            # If the file used to exist, rename it back into place
245
250
                unlink_func(tmp_name)
246
251
            else:
247
252
                rename_func(tmp_name, new)
 
253
    if failure_exc is not None:
 
254
        raise failure_exc[0], failure_exc[1], failure_exc[2]
248
255
 
249
256
 
250
257
# In Python 2.4.2 and older, os.path.abspath and os.path.realpath
1296
1303
 
1297
1304
def terminal_width():
1298
1305
    """Return estimated terminal width."""
1299
 
    isatty = getattr(sys.stdout, 'isatty', None)
1300
 
    if  isatty is None or not isatty():
1301
 
        # If it's not a tty, the width makes no sense. We just use a value bug
1302
 
        # enough to avoid truncations. When the output is redirected, the
1303
 
        # pagers can then handle that themselves. A cleaner implementation
1304
 
        # would be to fix the callers to not try to format at all in these
1305
 
        # circumstances.
1306
 
        return 65536
1307
 
 
1308
1306
    if sys.platform == 'win32':
1309
1307
        return win32utils.get_console_size()[0]
1310
1308
    width = 0