~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2007-09-28 07:05:56 UTC
  • mto: (2592.3.161 repository)
  • mto: This revision was merged to the branch mainline in revision 2880.
  • Revision ID: robertc@robertcollins.net-20070928070556-lxsw7332u3kdltwz
* The CommitBuilder method ``record_entry_contents`` now returns summary
  information about the effect of the commit on the repository. This tuple
  contains an inventory delta item if the entry changed from the basis, and a
  boolean indicating whether a new file graph node was recorded.
  (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
        :param path: The path the entry is at in the tree.
211
211
        :param tree: The tree which contains this entry and should be used to 
212
212
        obtain content.
213
 
        :return: True if a new version of the entry has been recorded.
214
 
            (Committing a merge where a file was only changed on the other side
215
 
            will not return True.)
 
213
        :return: A tuple (change_delta, version_recorded). change_delta is 
 
214
            an inventory_delta change for this entry against the basis tree of
 
215
            the commit, or None if no change occured against the basis tree.
 
216
            version_recorded is True if a new version of the entry has been
 
217
            recorded. For instance, committing a merge where a file was only
 
218
            changed on the other side will return (delta, False).
216
219
        """
217
220
        if self.new_inventory.root is None:
218
221
            if ie.parent_id is not None:
220
223
            self._check_root(ie, parent_invs, tree)
221
224
        self.new_inventory.add(ie)
222
225
 
 
226
        # TODO: slow, take it out of the inner loop.
 
227
        try:
 
228
            basis_inv = parent_invs[0]
 
229
        except IndexError:
 
230
            basis_inv = Inventory(root_id=None)
 
231
 
223
232
        # ie.revision is always None if the InventoryEntry is considered
224
233
        # for committing. ie.snapshot will record the correct revision 
225
234
        # which may be the sole parent if it is untouched.
226
235
        if ie.revision is not None:
227
 
            return ie.revision == self._new_revision_id and (path != '' or
 
236
            if self._versioned_root or path != '':
 
237
                # not considered for commit
 
238
                delta = None
 
239
            else:
 
240
                # repositories that do not version the root set the root's
 
241
                # revision to the new commit even when no change occurs, and
 
242
                # this masks when a change may have occurred against the basis,
 
243
                # so calculate if one happened.
 
244
                if ie.file_id not in basis_inv:
 
245
                    # add
 
246
                    delta = (None, path, ie.file_id, ie)
 
247
                else:
 
248
                    basis_id = basis_inv[ie.file_id]
 
249
                    if basis_id.name != '':
 
250
                        # not the root
 
251
                        delta = (basis_inv.id2path(ie.file_id), path,
 
252
                            ie.file_id, ie)
 
253
                    else:
 
254
                        # common, unaltered
 
255
                        delta = None
 
256
            # not considered for commit, OR, for non-rich-root 
 
257
            return delta, ie.revision == self._new_revision_id and (path != '' or
228
258
                self._versioned_root)
229
259
 
230
260
        parent_candiate_entries = ie.parent_candidates(parent_invs)
236
266
        # we are creating a new revision for ie in the history store and
237
267
        # inventory.
238
268
        ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
239
 
        return ie.revision == self._new_revision_id and (path != '' or
 
269
        if ie.file_id not in basis_inv:
 
270
            # add
 
271
            delta = (None, path, ie.file_id, ie)
 
272
        elif ie != basis_inv[ie.file_id]:
 
273
            # common but altered
 
274
            delta = (basis_inv.id2path(ie.file_id), path, ie.file_id,
 
275
                ie)
 
276
        else:
 
277
            # common, unaltered
 
278
            delta = None
 
279
        return delta, ie.revision == self._new_revision_id and (path != '' or
240
280
            self._versioned_root)
241
281
 
242
282
    def modified_directory(self, file_id, file_parents):