~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/script.py

  • Committer: Martin Pool
  • Date: 2010-01-12 06:30:41 UTC
  • mfrom: (4634.119.3 2.0)
  • mto: This revision was merged to the branch mainline in revision 4951.
  • Revision ID: mbp@sourcefrog.net-20100112063041-qp2ei0clx5gh0e9e
merge 2.0 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.