~james-w/bzr-builddeb/import-scripts

« back to all changes in this revision

Viewing changes to import_package.py

  • Committer: James Westby
  • Date: 2010-02-10 23:06:24 UTC
  • Revision ID: james.westby@canonical.com-20100210230624-qren9wmqe7fge8v1
Defer the filing of merge proposals until we push the branches back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
389
389
    f.close()
390
390
 
391
391
 
392
 
def bug_description(importp, lp_side_branch_path):
393
 
    suite = icommon.make_suite(importp.release, importp.pocket)
 
392
def bug_description(distro, release, pocket, name, lp_side_branch_path):
 
393
    suite = icommon.make_suite(release, pocket)
394
394
    lp_path = "lp:" + lp_side_branch_path[lp_side_branch_path.index("~"):]
395
395
    description = ("The package history in the archive and the history "
396
396
            "in the bzr branch differ. As the archive is authoritative "
397
397
            "the history of lp:%s/%s/%s now reflects that and the old "
398
398
            "bzr branch has been pushed to %s. A merge should be performed "
399
 
            "if necessary." % (importp.distro, suite, importp.name, lp_path))
 
399
            "if necessary." % (distro, suite, name, lp_path))
400
400
    return description
401
401
 
402
402
 
403
 
def file_bug(importp, lp_side_branch_path):
404
 
    suite = icommon.make_suite(importp.release, importp.pocket)
405
 
    description = bug_description(importp, lp_side_branch_path)
 
403
def file_bug(distro, release, pocket, name, lp_side_branch_path):
 
404
    suite = icommon.make_suite(release, pocket)
 
405
    description = bug_description(distro, release, pocket, name, lp_side_branch_path)
406
406
    udd = icommon.lp_call(operator.getitem, lp.projects, 'udd')
407
407
    new_bug = icommon.lp_call(lp.bugs.createBug, target=udd,
408
 
            title="Collision for %s %s" % (importp.name, suite),
 
408
            title="Collision for %s %s" % (name, suite),
409
409
            description=description)
410
410
    mutter("Bug filed: %s" % str(new_bug.id))
411
411
 
412
412
 
413
 
def file_mp(importp, bstore, lp_side_branch_path):
 
413
def file_mp(distro, release, pocket, name, bstore, lp_side_branch_path):
414
414
    lp_url = icommon.SERVICE_ROOT \
415
415
              + lp_side_branch_path[lp_side_branch_path.index("~"):]
416
416
    lp_branch = icommon.lp_call(lp.load, lp_url)
417
 
    target_branch_url = bstore._branch_url(importp.distro, importp.release,
418
 
            importp.pocket)
 
417
    target_branch_url = bstore._branch_url(distro, release, pocket)
419
418
    target_lp_branch = icommon.lp_call(lp.load, target_branch_url)
420
419
    ubuntu_dev = icommon.lp_call(operator.getitem, lp.people, 'ubuntu-dev')
421
420
    mp = icommon.lp_call(lp_branch.createMergeProposal,
422
421
            target_branch=target_lp_branch,
423
 
            initial_comment=bug_description(importp, lp_side_branch_path),
 
422
            initial_comment=bug_description(distro, release, pocket, name,
 
423
                lp_side_branch_path),
424
424
            needs_review=True,
425
425
            #reviewers=[ubuntu_dev.self_link],
426
426
            )
467
467
                tag._merge_tags_if_possible(updates_branch, lp_side_branch)
468
468
            finally:
469
469
                updates_branch.unlock()
470
 
            if importp.distro == "debian":
471
 
                file_bug(importp, lp_side_branch_path)
472
 
            else:
473
 
                file_mp(importp, bstore, lp_side_branch_path)
 
470
            f = open(updates_branch_path + ".collisions", "a")
 
471
            try:
 
472
                f.write(lp_side_branch + "\n")
 
473
            finally:
 
474
                f.close()
474
475
            # Then we move it to one side and branch back the revision we want
475
476
            side_dir = tempfile.mkdtemp(dir=temp_dir)
476
477
            try:
604
605
                    except HTTPError, e:
605
606
                        print e.content.decode("utf-8", "replace")
606
607
                        raise
 
608
                    if os.path.exists(source_branch_path + ".collisions"):
 
609
                        mutter("sleeping to file merge proposal")
 
610
                        time.sleep(120)
 
611
                        f = open(source_branch_path + ".collisions")
 
612
                        try:
 
613
                            for line in f:
 
614
                                lp_side_branch_path = line.strip()
 
615
                                if d == "debian":
 
616
                                    file_bug(d, known_release, known_pocket, package,
 
617
                                            lp_side_branch_path)
 
618
                                else:
 
619
                                    file_mp(d, known_release, known_pocket, package,
 
620
                                            bstore, lp_side_branch_path)
 
621
                        finally:
 
622
                            f.close()
607
623
                finally:
608
624
                    push_lock.release()
609
625