~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2005-10-06 00:52:53 UTC
  • Revision ID: robertc@robertcollins.net-20051006005253-415c38ad22094f13
define some expected behaviour for inventory_entry.snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
             output_to, reverse=False):
147
147
        """Perform a diff between two entries of the same kind."""
148
148
 
149
 
    def find_previous_heads(self, previous_inventories, entry_weave):
150
 
        """Return the revisions and entries that directly preceed this.
151
 
 
152
 
        Returned as a map from revision to inventory entry.
153
 
 
154
 
        This is a map containing the file revisions in all parents
155
 
        for which the file exists, and its revision is not a parent of
156
 
        any other. If the file is new, the set will be empty.
157
 
        """
158
 
        def get_ancestors(weave, entry):
159
 
            return set(map(weave.idx_to_name,
160
 
                           weave.inclusions([weave.lookup(entry.revision)])))
161
 
        heads = {}
162
 
        head_ancestors = {}
163
 
        for inv in previous_inventories:
164
 
            if self.file_id in inv:
165
 
                ie = inv[self.file_id]
166
 
                assert ie.file_id == self.file_id
167
 
                if ie.revision in heads:
168
 
                    assert heads[ie.revision] == ie
169
 
                else:
170
 
                    # may want to add it.
171
 
                    # may already be covered:
172
 
                    already_present = 0 != len(
173
 
                        [head for head in heads 
174
 
                         if ie.revision in head_ancestors[head]])
175
 
                    if already_present:
176
 
                        # an ancestor of a known head.
177
 
                        continue
178
 
                    # definately a head:
179
 
                    ancestors = get_ancestors(entry_weave, ie)
180
 
                    # may knock something else out:
181
 
                    check_heads = list(heads.keys())
182
 
                    for head in check_heads:
183
 
                        if head in ancestors:
184
 
                            # this head is not really a head
185
 
                            heads.pop(head)
186
 
                    head_ancestors[ie.revision] = ancestors
187
 
                    heads[ie.revision] = ie
188
 
        return heads
189
 
 
190
149
    def get_tar_item(self, root, dp, now, tree):
191
150
        """Get a tarfile item and a file stream for its content."""
192
151
        item = tarfile.TarInfo(os.path.join(root, dp))
309
268
                   self.name,
310
269
                   self.parent_id))
311
270
 
312
 
    def snapshot(self, revision, path, previous_entries,
313
 
                 work_tree, weave_store):
 
271
    def snapshot(self, revision, path, previous_entries, work_tree, 
 
272
                 weave_store):
314
273
        """Make a snapshot of this entry which may or may not have changed.
315
274
        
316
275
        This means that all its fields are populated, that it has its