~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-14 05:44:08 UTC
  • mfrom: (1551.19.20 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20071214054408-5xnavnb30uddiqxh
Merge directives now fetch bundle prerequisites from submit branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
                    StringIO(self.get_raw_bundle()))
191
191
                # We don't use the bundle's target revision, because
192
192
                # MergeDirective.revision_id is authoritative.
193
 
                info.install_revisions(target_repo, stream_input=False)
 
193
                try:
 
194
                    info.install_revisions(target_repo, stream_input=False)
 
195
                except errors.RevisionNotPresent:
 
196
                    # At least one dependency isn't present.  Try installing
 
197
                    # missing revisions from the submit branch
 
198
                    submit_branch = _mod_branch.Branch.open(self.target_branch)
 
199
                    missing_revisions = []
 
200
                    bundle_revisions = set(r.revision_id for r in
 
201
                                           info.real_revisions)
 
202
                    for revision in info.real_revisions:
 
203
                        for parent_id in revision.parent_ids:
 
204
                            if (parent_id not in bundle_revisions and
 
205
                                not target_repo.has_revision(parent_id)):
 
206
                                missing_revisions.append(parent_id)
 
207
                    # reverse missing revisions to try to get heads first
 
208
                    unique_missing = []
 
209
                    unique_missing_set = set()
 
210
                    for revision in reversed(missing_revisions):
 
211
                        if revision in unique_missing_set:
 
212
                            continue
 
213
                        unique_missing.append(revision)
 
214
                        unique_missing_set.add(revision)
 
215
                    for missing_revision in unique_missing:
 
216
                        target_repo.fetch(submit_branch.repository,
 
217
                                          missing_revision)
 
218
                    info.install_revisions(target_repo, stream_input=False)
194
219
            else:
195
220
                source_branch = _mod_branch.Branch.open(self.source_branch)
196
221
                target_repo.fetch(source_branch.repository, self.revision_id)