~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-17 23:32:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1462.
  • Revision ID: robertc@robertcollins.net-20051017233206-cbd6059e27bd4e39
Branch.remove has been moved to WorkingTree.

Part of this is providing WorkingTree with locking primitives,
to allow the use of the needs_write_lock decorator.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
633
633
            raise BzrError("%r is not present in revision %s" % (file, revno))
634
634
        tree.print_file(file_id)
635
635
 
636
 
    @needs_write_lock
637
 
    def remove(self, files, verbose=False):
638
 
        """Mark nominated files for removal from the inventory.
639
 
 
640
 
        This does not remove their text.  This does not run on 
641
 
 
642
 
        TODO: Refuse to remove modified files unless --force is given?
643
 
 
644
 
        TODO: Do something useful with directories.
645
 
 
646
 
        TODO: Should this remove the text or not?  Tough call; not
647
 
        removing may be useful and the user can just use use rm, and
648
 
        is the opposite of add.  Removing it is consistent with most
649
 
        other tools.  Maybe an option.
650
 
        """
651
 
        ## TODO: Normalize names
652
 
        ## TODO: Remove nested loops; better scalability
653
 
        if isinstance(files, basestring):
654
 
            files = [files]
655
 
 
656
 
        tree = self.working_tree()
657
 
        inv = tree.inventory
658
 
 
659
 
        # do this before any modifications
660
 
        for f in files:
661
 
            fid = inv.path2id(f)
662
 
            if not fid:
663
 
                raise BzrError("cannot remove unversioned file %s" % quotefn(f))
664
 
            mutter("remove inventory entry %s {%s}" % (quotefn(f), fid))
665
 
            if verbose:
666
 
                # having remove it, it must be either ignored or unknown
667
 
                if tree.is_ignored(f):
668
 
                    new_status = 'I'
669
 
                else:
670
 
                    new_status = '?'
671
 
                show_status(new_status, inv[fid].kind, quotefn(f))
672
 
            del inv[fid]
673
 
 
674
 
        self._write_inventory(inv)
675
 
 
676
636
    # FIXME: this doesn't need to be a branch method
677
637
    def set_inventory(self, new_inventory_list):
678
638
        from bzrlib.inventory import Inventory, InventoryEntry
704
664
        >>> b.add('foo')
705
665
        >>> list(b.unknowns())
706
666
        []
707
 
        >>> b.remove('foo')
 
667
        >>> WorkingTree(b.base, b).remove('foo')
708
668
        >>> list(b.unknowns())
709
669
        ['foo']
710
670
        """