497
499
for f in descend('', inv.root.file_id, self.basedir):
503
def rename_one(self, from_rel, to_rel):
506
This can change the directory or the filename or both.
509
if not self.has_filename(from_rel):
510
raise BzrError("can't rename: old working file %r does not exist" % from_rel)
511
if self.has_filename(to_rel):
512
raise BzrError("can't rename: new working file %r already exists" % to_rel)
514
file_id = inv.path2id(from_rel)
516
raise BzrError("can't rename: old name %r is not versioned" % from_rel)
519
from_parent = entry.parent_id
520
from_name = entry.name
522
if inv.path2id(to_rel):
523
raise BzrError("can't rename: new name %r is already versioned" % to_rel)
525
to_dir, to_tail = os.path.split(to_rel)
526
to_dir_id = inv.path2id(to_dir)
527
if to_dir_id == None and to_dir != '':
528
raise BzrError("can't determine destination directory id for %r" % to_dir)
530
mutter("rename_one:")
531
mutter(" file_id {%s}" % file_id)
532
mutter(" from_rel %r" % from_rel)
533
mutter(" to_rel %r" % to_rel)
534
mutter(" to_dir %r" % to_dir)
535
mutter(" to_dir_id {%s}" % to_dir_id)
537
inv.rename(file_id, to_dir_id, to_tail)
539
from_abs = self.abspath(from_rel)
540
to_abs = self.abspath(to_rel)
542
rename(from_abs, to_abs)
544
inv.rename(file_id, from_parent, from_name)
545
raise BzrError("failed to rename %r to %r: %s"
546
% (from_abs, to_abs, e[1]),
547
["rename rolled back"])
548
self._write_inventory(inv)
500
551
def unknowns(self):
501
552
"""Return all unknown files.