~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-09-12 01:29:49 UTC
  • mto: (1092.2.12) (974.1.76) (1185.8.2)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: mbp@sourcefrog.net-20050912012949-73a539d3f2542173
- patch from mpe to automatically add parent directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
584
584
        try:
585
585
            try:
586
586
                return self.revision_store[revision_id]
587
 
            except KeyError:
 
587
            except IndexError:
588
588
                raise bzrlib.errors.NoSuchRevision(self, revision_id)
589
589
        finally:
590
590
            self.unlock()
805
805
        """Pull in all new revisions from other branch.
806
806
        """
807
807
        from bzrlib.fetch import greedy_fetch
808
 
        from bzrlib.revision import get_intervening_revisions
809
808
 
810
809
        pb = bzrlib.ui.ui_factory.progress_bar()
811
810
        pb.update('comparing histories')
812
 
        if stop_revision is None:
813
 
            other_revision = other.last_patch()
 
811
 
 
812
        revision_ids = self.missing_revisions(other, stop_revision)
 
813
 
 
814
        if len(revision_ids) > 0:
 
815
            count = greedy_fetch(self, other, revision_ids[-1], pb)[0]
814
816
        else:
815
 
            other_revision = other.lookup_revision(stop_revision)
816
 
        count = greedy_fetch(self, other, other_revision, pb)[0]
817
 
        try:
818
 
            revision_ids = self.missing_revisions(other, stop_revision)
819
 
        except DivergedBranches, e:
820
 
            try:
821
 
                revision_ids = get_intervening_revisions(self.last_patch(), 
822
 
                                                         other_revision, self)
823
 
                assert self.last_patch() not in revision_ids
824
 
            except bzrlib.errors.NotAncestor:
825
 
                raise e
826
 
 
 
817
            count = 0
827
818
        self.append_revision(*revision_ids)
 
819
        ## note("Added %d revisions." % count)
828
820
        pb.clear()
829
821
 
830
822
    def install_revisions(self, other, revision_ids, pb):
831
823
        if hasattr(other.revision_store, "prefetch"):
832
824
            other.revision_store.prefetch(revision_ids)
833
825
        if hasattr(other.inventory_store, "prefetch"):
834
 
            inventory_ids = []
835
 
            for rev_id in revision_ids:
836
 
                try:
837
 
                    revision = other.get_revision(rev_id).inventory_id
838
 
                    inventory_ids.append(revision)
839
 
                except bzrlib.errors.NoSuchRevision:
840
 
                    pass
 
826
            inventory_ids = [other.get_revision(r).inventory_id
 
827
                             for r in revision_ids]
841
828
            other.inventory_store.prefetch(inventory_ids)
842
829
 
843
830
        if pb is None:
1091
1078
                    return (i+1,)
1092
1079
    REVISION_NAMESPACES['date:'] = _namespace_date
1093
1080
 
1094
 
 
1095
 
    def _namespace_ancestor(self, revs, revision):
1096
 
        from revision import common_ancestor, MultipleRevisionSources
1097
 
        other_branch = find_branch(_trim_namespace('ancestor', revision))
1098
 
        revision_a = self.last_patch()
1099
 
        revision_b = other_branch.last_patch()
1100
 
        for r, b in ((revision_a, self), (revision_b, other_branch)):
1101
 
            if r is None:
1102
 
                raise bzrlib.errors.NoCommits(b)
1103
 
        revision_source = MultipleRevisionSources(self, other_branch)
1104
 
        result = common_ancestor(revision_a, revision_b, revision_source)
1105
 
        try:
1106
 
            revno = self.revision_id_to_revno(result)
1107
 
        except bzrlib.errors.NoSuchRevision:
1108
 
            revno = None
1109
 
        return revno,result
1110
 
        
1111
 
 
1112
 
    REVISION_NAMESPACES['ancestor:'] = _namespace_ancestor
1113
 
 
1114
1081
    def revision_tree(self, revision_id):
1115
1082
        """Return Tree for a revision on this branch.
1116
1083
 
1561
1528
    
1562
1529
    from_location = pull_loc(branch_from)
1563
1530
    br_to.set_parent(pull_loc(branch_from))
1564
 
    return br_to
1565
1531
 
1566
 
def _trim_namespace(namespace, spec):
1567
 
    full_namespace = namespace + ':'
1568
 
    assert spec.startswith(full_namespace)
1569
 
    return spec[len(full_namespace):]