~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Marius Kruger
  • Date: 2006-12-21 19:14:35 UTC
  • mto: (2220.1.1 bzr.enhanced_move)
  • mto: This revision was merged to the branch mainline in revision 2241.
  • Revision ID: marius.kruger@enerweb.co.za-20061221191435-3y22jy8raa6959yk
* errors
  - Add AlreadyVersionedError
  - Fix type
  - Add 'extra' capability to PathsDoNotExist.
* update test_mv
* workingtre
  - Convert more BzrErrors to mores specialised ones.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 
73
73
from bzrlib import symbol_versioning
74
74
from bzrlib.decorators import needs_read_lock, needs_write_lock
75
 
from bzrlib.errors import (BzrCheckError,
 
75
from bzrlib.errors import (AlreadyVersionedError,
 
76
                           BzrCheckError,
76
77
                           BzrError,
77
78
                           ConflictFormatError,
78
 
                           WeaveRevisionNotPresent,
 
79
                           FilesExist,                     
79
80
                           NotADirectory,
80
81
                           NotBranchError,
81
82
                           NotInWorkingDirectory,
83
84
                           NotVersionedError,
84
85
                           MergeModifiedFormatError,
85
86
                           UnsupportedOperation,
 
87
                           WeaveRevisionNotPresent,
86
88
                           )
87
89
from bzrlib.inventory import InventoryEntry, Inventory, ROOT_ID
88
90
from bzrlib.lockable_files import LockableFiles, TransportLock
1045
1047
        inv = self.inventory
1046
1048
        to_abs = self.abspath(to_dir)
1047
1049
        if not isdir(to_abs):
1048
 
            raise NotADirectory(to_abs, extra="(Invalid move destination)")
 
1050
            raise NotADirectory(to_abs, extra="Invalid move destination")
1049
1051
        if not self.has_filename(to_dir):
1050
1052
            raise NotInWorkingDirectory(to_dir, extra=
1051
1053
                "(Invalid move destination)")
1056
1058
            
1057
1059
        to_dir_ie = inv[to_dir_id]
1058
1060
        if to_dir_ie.kind != 'directory':
1059
 
            raise NotADirectory(to_abs, extra="(Invalid move destination)")
 
1061
            raise NotADirectory(to_abs, extra="Invalid move destination")
1060
1062
 
1061
1063
        # create rename entries and tuples
1062
1064
        for from_rel in from_paths:
1112
1114
 
1113
1115
            # check the inventory for source and destination
1114
1116
            if from_id is None:
1115
 
                raise BzrError("can't rename: old name %r is not versioned" % 
1116
 
                               from_rel)
 
1117
                raise NotVersionedError(path=str(from_rel),
 
1118
                    contextInfo="Invalid move source")
1117
1119
            if to_id is not None:
1118
 
                raise BzrError("can't rename: new name %r is already"
1119
 
                               " versioned" % to_rel)
 
1120
                raise AlreadyVersionedError(path=str(to_rel),
 
1121
                    contextInfo="Invalid move destination")
1120
1122
 
1121
1123
            # try to determine the mode for rename (only change inv or change 
1122
1124
            # inv and file system)
1123
1125
            if after:
1124
1126
                if not self.has_filename(to_rel):
1125
 
                    raise BzrError("can't rename: new working file %r does not"
1126
 
                                   " exist" % to_rel)
 
1127
                    raise NoSuchFile(path=str(to_rel),
 
1128
                        extra="New file has not been created yet")
1127
1129
                only_change_inv = True
1128
1130
            elif not self.has_filename(from_rel) and self.has_filename(to_rel):
1129
1131
                only_change_inv = True
1133
1135
                # something is wrong, so lets determine what exactly
1134
1136
                if not self.has_filename(from_rel) and \
1135
1137
                   not self.has_filename(to_rel):
1136
 
                    raise BzrError("can't rename: neither old name %r nor new"
1137
 
                                   " name %r exist" % (from_rel, to_rel))
 
1138
                    raise PathsDoNotExist(paths=(str(from_rel), str(to_rel)),
 
1139
                        extra="can't rename")
1138
1140
                else:
1139
 
                    raise BzrError("can't rename: both, old name %r and new"
1140
 
                                   " name %r exist. Use option '--after' to"
1141
 
                                   " force rename." % (from_rel, to_rel))
 
1141
                    raise FilesExist(paths=(str(from_rel), str(to_rel)),
 
1142
                        extra="can't rename. Use option '--after' to"
 
1143
                              " force rename.")
1142
1144
            rename_entry.only_change_inv = only_change_inv                       
1143
1145
        return rename_entries
1144
1146