/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/tests/script.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-12 22:51:31 UTC
  • mto: This revision was merged to the branch mainline in revision 4955.
  • Revision ID: john@arbash-meinel.com-20100112225131-he8h411p6aeeb947
Delay grabbing an output stream until we actually go to show a diff.

This makes the test suite happy, but it also seems to be reasonable.
If we aren't going to write anything, we don't need to hold an
output stream open.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 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
402
402
            retcode = 0
403
403
        return retcode, None, err
404
404
 
405
 
    def do_mv(self, test_case, input, args):
406
 
        err = None
407
 
        def error(msg, src, dst):
408
 
            return "mv: cannot move %s to %s: %s\n" % (src, dst, msg)
409
 
 
410
 
        if not args or len(args) != 2:
411
 
            raise SyntaxError("Usage: mv path1 path2")
412
 
        src, dst = args
413
 
        try:
414
 
            real_dst = dst
415
 
            if os.path.isdir(dst):
416
 
                real_dst = os.path.join(dst, os.path.basename(src))
417
 
            os.rename(src, real_dst)
418
 
        except OSError, e:
419
 
            if e.errno == errno.ENOENT:
420
 
                err = error('No such file or directory', src, dst)
421
 
            else:
422
 
                raise
423
 
        if err:
424
 
            retcode = 1
425
 
        else:
426
 
            retcode = 0
427
 
        return retcode, None, err
428
 
 
429
 
 
430
405
 
431
406
class TestCaseWithMemoryTransportAndScript(tests.TestCaseWithMemoryTransport):
432
407
    """Helper class to experiment shell-like test and memory fs.