~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/script.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-13 17:21:29 UTC
  • mto: (4956.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4957.
  • Revision ID: v.ladeuil+lp@free.fr-20100113172129-ih6sn8ho6b6pwuab
Use os.rename() and fix some typos.

* bzrlib/tests/test_script.py:
(TestMv.test_move_unknown_file): Check the error case.

* bzrlib/tests/script.py:
(ScriptRunner.do_mv): Us os.rename instead of shutil.move. It's
less powerful but reflects more closely the expected limitations
in the future transport-based implementation.

* NEWS: 
Always sorted in alphabetical order.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import glob
25
25
import os
26
26
import shlex
27
 
import shutil
28
27
from cStringIO import StringIO
29
28
 
30
29
from bzrlib import (
405
404
 
406
405
    def do_mv(self, test_case, input, args):
407
406
        err = None
408
 
        def error(msg, path1, path2):
409
 
            return "mv: cannot move %s to %s: %s\n" % (path1, path2, msg)
 
407
        def error(msg, src, dst):
 
408
            return "mv: cannot move %s to %s: %s\n" % (src, dst, msg)
410
409
 
411
410
        if not args or len(args) != 2:
412
411
            raise SyntaxError("Usage: mv path1 path2")
413
 
        path1, path2 = args
 
412
        src, dst = args
414
413
        try:
415
 
            shutil.move(path1, path2)
 
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)
416
418
        except OSError, e:
417
419
            if e.errno == errno.ENOENT:
418
 
                err = error('No such file or directory', path1)
 
420
                err = error('No such file or directory', src, dst)
419
421
            else:
420
422
                raise
421
423
        if err: