~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-03-07 10:45:44 UTC
  • mfrom: (2321.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070307104544-59e3e6358e4bdb29
(robertc) Merge dirstate and subtrees. (Robert Collins, Martin Pool, Aaaron Bentley, John A Meinel, James Westby)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
 
22
22
 
23
23
from bzrlib import (
 
24
    errors,
24
25
    osutils,
25
26
    tree,
26
27
    )
61
62
    branch and bzrdir attributes.
62
63
    """
63
64
 
64
 
    @needs_write_lock
 
65
    @needs_tree_write_lock
65
66
    def add(self, files, ids=None, kinds=None):
66
67
        """Add paths to the set of versioned paths.
67
68
 
110
111
        self._gather_kinds(files, kinds)
111
112
        self._add(files, ids, kinds)
112
113
 
 
114
    def add_reference(self, sub_tree):
 
115
        """Add a TreeReference to the tree, pointing at sub_tree"""
 
116
        raise errors.UnsupportedOperation(self.add_reference, self)
 
117
 
 
118
    def _add_reference(self, sub_tree):
 
119
        """Standard add_reference implementation, for use by subclasses"""
 
120
        try:
 
121
            sub_tree_path = self.relpath(sub_tree.basedir)
 
122
        except errors.PathNotChild:
 
123
            raise errors.BadReferenceTarget(self, sub_tree,
 
124
                                            'Target not inside tree.')
 
125
        sub_tree_id = sub_tree.get_root_id()
 
126
        if sub_tree_id == self.get_root_id():
 
127
            raise errors.BadReferenceTarget(self, sub_tree,
 
128
                                     'Trees have the same root id.')
 
129
        if sub_tree_id in self.inventory:
 
130
            raise errors.BadReferenceTarget(self, sub_tree,
 
131
                                            'Root id already present in tree')
 
132
        self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
 
133
 
113
134
    def _add(self, files, ids, kinds):
114
 
        """Helper function for add - updates the inventory."""
 
135
        """Helper function for add - updates the inventory.
 
136
 
 
137
        :param files: sequence of pathnames, relative to the tree root
 
138
        :param ids: sequence of suggested ids for the files (may be None)
 
139
        :param kinds: sequence of  inventory kinds of the files (i.e. may
 
140
            contain "tree-reference")
 
141
        """
115
142
        raise NotImplementedError(self._add)
116
143
 
117
144
    @needs_write_lock
118
 
    def commit(self, message=None, revprops=None, *args, **kwargs):
 
145
    def commit(self, message=None, revprops=None, *args,
 
146
               **kwargs):
119
147
        # avoid circular imports
120
148
        from bzrlib import commit
121
149
        if revprops is None: