~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-12 07:17:28 UTC
  • mto: (1185.11.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050712071728-ab7234b176ee64ed
Moving the multi-get functionality higher up into the Branch class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
627
627
            
628
628
        assert r.revision_id == revision_id
629
629
        return r
630
 
        
 
630
 
 
631
    def get_revisions(self, revision_ids. pb=None):
 
632
        """Return the Revision object for a set of named revisions"""
 
633
        from bzrlib.revision import Revision
 
634
        from bzrlib.xml import unpack_xml
 
635
 
 
636
        self.lock_read()
 
637
        try:
 
638
            for f in self.revision_store.get(revision_ids, pb=pb):
 
639
                yield unpack_xml(Revision, f)
 
640
        finally:
 
641
            self.unlock()
 
642
            
631
643
 
632
644
    def get_revision_sha1(self, revision_id):
633
645
        """Hash the stored value of a revision, and return it."""
649
661
        from bzrlib.inventory import Inventory
650
662
        from bzrlib.xml import unpack_xml
651
663
 
652
 
        return unpack_xml(Inventory, self.inventory_store[inventory_id])
 
664
        self.lock_read()
 
665
        try:
 
666
            return unpack_xml(Inventory, self.inventory_store[inventory_id])
 
667
        finally:
 
668
            self.unlock()
 
669
 
 
670
    def get_inventories(self, inventory_ids, pb=None):
 
671
        """Get Inventory objects by id
 
672
        """
 
673
        from bzrlib.inventory import Inventory
 
674
        from bzrlib.xml import unpack_xml
 
675
 
 
676
        self.lock_read()
 
677
        try:
 
678
            for f in self.inventory_store.get(inventory_ids, pb=pb):
 
679
                yield unpack_xml(Inventory, f)
 
680
        finally:
 
681
            self.unlock()
653
682
            
654
683
 
655
684
    def get_inventory_sha1(self, inventory_id):
849
878
        if hasattr(other.revision_store, "prefetch"):
850
879
            other.revision_store.prefetch(revision_ids)
851
880
        if hasattr(other.inventory_store, "prefetch"):
852
 
            inventory_ids = [other.get_revision(r).inventory_id
853
 
                             for r in revision_ids]
854
 
            other.inventory_store.prefetch(inventory_ids)
 
881
            other.inventory_store.prefetch(revision_ids)
855
882
                
856
 
        revisions = []
 
883
        revisions = self.get_revisions(revision_ids, pb=pb)
 
884
        inventories = self.get_inventories(revision_ids, pb=pb)
857
885
        needed_texts = set()
858
886
        i = 0
859
 
        for rev_id in revision_ids:
 
887
 
 
888
        for rev, inv in zip(revisions, inventories):
860
889
            i += 1
861
890
            pb.update('fetching revision', i, len(revision_ids))
862
 
            rev = other.get_revision(rev_id)
863
 
            revisions.append(rev)
864
 
            inv = other.get_inventory(str(rev.inventory_id))
 
891
            text_ids = []
865
892
            for key, entry in inv.iter_entries():
866
893
                if entry.text_id is None:
867
894
                    continue
868
 
                if entry.text_id not in self.text_store:
869
 
                    needed_texts.add(entry.text_id)
 
895
                text_ids.append(entry.text_id)
 
896
            has_ids = self.text_store.has(text_ids)
 
897
            for has, text_id in zip(has_ids, text_ids):
 
898
                if not has:
 
899
                    needed_texts.add(text_id)
870
900
 
871
901
        pb.clear()
872
902