~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-12-11 03:11:05 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20061211031105-xne52056x5ozz8yc
Add add_reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
                           MergeModifiedFormatError,
85
85
                           UnsupportedOperation,
86
86
                           )
87
 
from bzrlib.inventory import InventoryEntry, Inventory, ROOT_ID
 
87
from bzrlib.inventory import InventoryEntry, Inventory, ROOT_ID, TreeReference
88
88
from bzrlib.lockable_files import LockableFiles, TransportLock
89
89
from bzrlib.lockdir import LockDir
90
90
import bzrlib.mutabletree
593
593
                inv.add_path(f, kind=kind, file_id=file_id)
594
594
        self._write_inventory(inv)
595
595
 
 
596
    def add_reference(self, sub_tree):
 
597
        """Add a TreeReference to the tree, pointing at sub_tree"""
 
598
        raise UnsupportedOperation(self.add_reference, self)
 
599
 
596
600
    @needs_tree_write_lock
597
601
    def _gather_kinds(self, files, kinds):
598
602
        """See MutableTree._gather_kinds."""
1991
1995
 
1992
1996
 
1993
1997
class WorkingTree4(WorkingTree3):
1994
 
    pass
 
1998
 
 
1999
    def add_reference(self, sub_tree):
 
2000
        try:
 
2001
            sub_tree_path = self.relpath(sub_tree.basedir)
 
2002
        except errors.PathNotChild:
 
2003
            raise errors.BadReferenceTarget(self, sub_tree, 
 
2004
                                            'Target not inside tree.')
 
2005
        parent_id = self.path2id(osutils.dirname(sub_tree_path))
 
2006
        name = osutils.basename(sub_tree_path)
 
2007
        sub_tree_id = sub_tree.get_root_id()
 
2008
        if sub_tree_id == self.get_root_id():
 
2009
            raise errors.BadReferenceTarget(self, sub_tree, 
 
2010
                                     'Trees have the same root id.')
 
2011
        if sub_tree_id in self.inventory:
 
2012
            raise errors.BadReferenceTarget(self, sub_tree, 
 
2013
                                            'Root id already present in tree')
 
2014
        entry = TreeReference(sub_tree_id, name, parent_id, None, 
 
2015
                              None)
 
2016
        self.inventory.add(entry)
1995
2017
 
1996
2018
 
1997
2019
def get_conflicted_stem(path):
2213
2235
        if revision_id is None:
2214
2236
            revision_id = branch.last_revision()
2215
2237
        inv = Inventory(root_id=generate_ids.gen_root_id())
2216
 
        wt = WorkingTree3(a_bzrdir.root_transport.local_abspath('.'),
 
2238
        wt = self._tree_class(a_bzrdir.root_transport.local_abspath('.'),
2217
2239
                         branch,
2218
2240
                         inv,
2219
2241
                         _internal=True,