~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Detect duplicate inventory ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
        conflicts.extend(self._unversioned_parents(by_parent))
253
253
        conflicts.extend(self._parent_loops())
254
254
        conflicts.extend(self._duplicate_entries(by_parent))
 
255
        conflicts.extend(self._duplicate_ids())
255
256
        conflicts.extend(self._parent_type_conflicts(by_parent))
256
257
        conflicts.extend(self._improper_versioning())
257
258
        conflicts.extend(self._executability_conflicts())
267
268
        parents = self._by_parent().keys()
268
269
        parents.extend([t for t in self._removed_contents if 
269
270
                        self.tree_kind(t) == 'directory'])
270
 
        parents.extend([t for t in self._removed_id if 
271
 
                        self.tree_kind(t) == 'directory'])
 
271
        for trans_id in self._removed_id:
 
272
            file_id = self.get_tree_file_id(trans_id)
 
273
            if self._tree.inventory[file_id].kind == 'directory':
 
274
                parents.append(trans_id)
 
275
 
272
276
        for parent_id in parents:
273
277
            try:
274
278
                path = self._tree_id_paths[parent_id]
370
374
                last_trans_id = trans_id
371
375
        return conflicts
372
376
 
 
377
    def _duplicate_ids(self):
 
378
        """Each inventory id may only be used once"""
 
379
        conflicts = []
 
380
        removed_tree_ids = set((self.get_tree_file_id(trans_id) for trans_id in
 
381
                                self._removed_id))
 
382
        active_tree_ids = set((f for f in self._tree.inventory if
 
383
                               f not in removed_tree_ids))
 
384
        for trans_id, file_id in self._new_id.iteritems():
 
385
            if file_id in active_tree_ids:
 
386
                old_trans_id = self.get_id_tree(file_id)
 
387
                conflicts.append(('duplicate id', old_trans_id, trans_id))
 
388
        return conflicts
 
389
 
373
390
    def _parent_type_conflicts(self, by_parent):
374
391
        """parents must have directory 'contents'."""
375
392
        conflicts = []