~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-04 03:35:31 UTC
  • mfrom: (1393.1.30)
  • Revision ID: robertc@robertcollins.net-20051004033531-f057603b470ca4a2
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
 
25
25
import bzrlib
 
26
from bzrlib.inventory import InventoryEntry
 
27
import bzrlib.inventory as inventory
26
28
from bzrlib.trace import mutter, note
27
29
from bzrlib.osutils import (isdir, quotefn, compact_date, rand_bytes, 
28
30
                            rename, splitpath, sha_file, appendpath, 
578
580
                    # maybe something better?
579
581
                    raise BzrError('cannot add: not a regular file, symlink or directory: %s' % quotefn(f))
580
582
 
581
 
                if kind not in ('file', 'directory', 'symlink'):
582
 
                    raise BzrError('cannot add: not a regular file, symlink or directory: %s' % quotefn(f))
 
583
                if not InventoryEntry.versionable_kind(kind):
 
584
                    raise BzrError('cannot add: not a versionable file ('
 
585
                                   'i.e. regular file, symlink or directory): %s' % quotefn(f))
583
586
 
584
587
                if file_id is None:
585
588
                    file_id = gen_file_id(f)
658
661
            name = os.path.basename(path)
659
662
            if name == "":
660
663
                continue
661
 
            inv.add(InventoryEntry(file_id, name, kind, parent))
 
664
            # fixme, there should be a factory function inv,add_?? 
 
665
            if kind == 'directory':
 
666
                inv.add(inventory.InventoryDirectory(file_id, name, parent))
 
667
            elif kind == 'file':
 
668
                inv.add(inventory.InventoryFile(file_id, name, parent))
 
669
            elif kind == 'symlink':
 
670
                inv.add(inventory.InventoryLink(file_id, name, parent))
 
671
            else:
 
672
                raise BzrError("unknown kind %r" % kind)
662
673
        self._write_inventory(inv)
663
674
 
664
675
    def unknowns(self):
989
1000
        """Return a `Tree` for the working copy."""
990
1001
        from bzrlib.workingtree import WorkingTree
991
1002
        # TODO: In the future, WorkingTree should utilize Transport
 
1003
        # RobertCollins 20051003 - I don't think it should - working trees are
 
1004
        # much more complex to keep consistent than our careful .bzr subset.
 
1005
        # instead, we should say that working trees are local only, and optimise
 
1006
        # for that.
992
1007
        return WorkingTree(self._transport.base, self.read_working_inventory())
993
1008
 
994
1009