~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: John Arbash Meinel
  • Date: 2008-12-05 22:18:09 UTC
  • mto: (3735.13.1 merge_dev)
  • mto: This revision was merged to the branch mainline in revision 3889.
  • Revision ID: john@arbash-meinel.com-20081205221809-d3c4cz1jyv9p1y1h
Bring in Inventory._make_delta

Show diffs side-by-side

added added

removed removed

Lines of Context:
1233
1233
    def has_id(self, file_id):
1234
1234
        return (file_id in self._byid)
1235
1235
 
 
1236
    def _make_delta(self, old):
 
1237
        """Make an inventory delta from two inventories."""
 
1238
        old_ids = set(old)
 
1239
        new_ids = set(self)
 
1240
        adds = new_ids - old_ids
 
1241
        deletes = old_ids - new_ids
 
1242
        common = old_ids.intersection(new_ids)
 
1243
        delta = []
 
1244
        for file_id in deletes:
 
1245
            delta.append((old.id2path(file_id), None, file_id, None))
 
1246
        for file_id in adds:
 
1247
            delta.append((None, self.id2path(file_id), file_id, self[file_id]))
 
1248
        for file_id in common:
 
1249
            if old[file_id] != self[file_id]:
 
1250
                delta.append((old.id2path(file_id), self.id2path(file_id),
 
1251
                    file_id, self[file_id]))
 
1252
        return delta
 
1253
 
1236
1254
    def remove_recursive_id(self, file_id):
1237
1255
        """Remove file_id, and children, from the inventory.
1238
 
        
 
1256
 
1239
1257
        :param file_id: A file_id to remove.
1240
1258
        """
1241
1259
        to_find_delete = [self._byid[file_id]]