~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2005-05-19 09:59:49 UTC
  • Revision ID: mbp@sourcefrog.net-20050519095949-2aaed7613265e594
- More cleanups for set type

- Clean up Inventory cmp method

- Remove the Inventory.id_set and Tree.id_set methods: don't built
  sets when just using the dictionaries will do.

Show diffs side-by-side

added added

removed removed

Lines of Context:
453
453
        del self[ie.parent_id].children[ie.name]
454
454
 
455
455
 
456
 
    def id_set(self):
457
 
        from bzrlib import frozenset
458
 
        return frozenset(self._byid)
459
 
 
460
 
 
461
456
    def to_element(self):
462
457
        """Convert to XML Element"""
463
458
        e = Element('inventory')
506
501
        if not isinstance(other, Inventory):
507
502
            return NotImplemented
508
503
 
509
 
        if self.id_set() ^ other.id_set():
510
 
            return 1
 
504
        byid = self._byid
 
505
        otherids = other._byid
511
506
 
512
 
        for file_id in self._byid:
513
 
            c = cmp(self[file_id], other[file_id])
 
507
        if len(byid) != len(otherids):
 
508
            # shortcut: obviously not the same
 
509
            return 1                    
 
510
        
 
511
        for file_id in byid:
 
512
            if file_id not in otherids:
 
513
                return 1
 
514
            
 
515
            c = cmp(byid[file_id], otherids[file_id])
514
516
            if c: return c
515
517
 
 
518
        for file_id in otherids:
 
519
            if file_id not in byid:
 
520
                return 1
 
521
 
516
522
        return 0
517
523
 
518
524