/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2007-02-25 15:15:16 UTC
  • mto: (2255.2.152 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070225151516-38bls2quulk8xsu5
Merge refactoring of add_reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
636
636
                inv.add_path(f, kind=kind, file_id=file_id)
637
637
        self._write_inventory(inv)
638
638
 
639
 
    def add_reference(self, sub_tree):
640
 
        """Add a TreeReference to the tree, pointing at sub_tree"""
641
 
        raise errors.UnsupportedOperation(self.add_reference, self)
642
 
 
643
639
    @needs_tree_write_lock
644
640
    def _gather_kinds(self, files, kinds):
645
641
        """See MutableTree._gather_kinds."""
2359
2355
        return kind
2360
2356
 
2361
2357
    def add_reference(self, sub_tree):
2362
 
        try:
2363
 
            sub_tree_path = self.relpath(sub_tree.basedir)
2364
 
        except errors.PathNotChild:
2365
 
            raise errors.BadReferenceTarget(self, sub_tree, 
2366
 
                                            'Target not inside tree.')
2367
 
        parent_id = self.path2id(osutils.dirname(sub_tree_path))
2368
 
        name = osutils.basename(sub_tree_path)
2369
 
        sub_tree_id = sub_tree.get_root_id()
2370
 
        if sub_tree_id == self.get_root_id():
2371
 
            raise errors.BadReferenceTarget(self, sub_tree, 
2372
 
                                     'Trees have the same root id.')
2373
 
        if sub_tree_id in self.inventory:
2374
 
            raise errors.BadReferenceTarget(self, sub_tree, 
2375
 
                                            'Root id already present in tree')
2376
 
        entry = TreeReference(sub_tree_id, name, parent_id, None, 
2377
 
                              None)
2378
 
        self.inventory.add(entry)
2379
 
        self._write_inventory(self.inventory)
 
2358
        return self._add_reference(sub_tree)
2380
2359
 
2381
2360
    def get_nested_tree(self, entry, path=None):
2382
2361
        if path is None: