~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/interfaces/branch.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-27 22:07:33 UTC
  • mfrom: (13084.5.8 handle-concurrent)
  • Revision ID: launchpad@pqm.canonical.com-20110527220733-te7l2w4xkifac1mf
[r=jcsackett][bug=648075] Exporting translations detects branches
 with stale db info and schedules scan

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    'BzrIdentityMixin',
14
14
    'DEFAULT_BRANCH_STATUS_IN_LISTING',
15
15
    'get_blacklisted_hostnames',
 
16
    'get_db_branch_info',
16
17
    'IBranch',
17
18
    'IBranchBatchNavigator',
18
19
    'IBranchCloud',
180
181
            raise LaunchpadValidationError(structured(message))
181
182
 
182
183
        if IBranch.providedBy(self.context) and self.context.url == str(uri):
183
 
            return # url was not changed
 
184
            return  # url was not changed
184
185
 
185
186
        if uri.path == '/':
186
187
            message = _(
407
408
            title=_("The bug-branch link objects that link this branch "
408
409
                    "to bugs."),
409
410
            readonly=True,
410
 
            value_type=Reference(schema=Interface)) # Really IBugBranch
 
411
            value_type=Reference(schema=Interface))  # Really IBugBranch
411
412
 
412
413
    linked_bugs = exported(
413
414
        CollectionField(
414
415
            title=_("The bugs linked to this branch."),
415
416
        readonly=True,
416
 
        value_type=Reference(schema=Interface))) # Really IBug
 
417
        value_type=Reference(schema=Interface)))  # Really IBug
417
418
 
418
419
    def getLinkedBugTasks(user, status_filter):
419
420
        """Return a result set for the tasks that are relevant to this branch.
428
429
 
429
430
    @call_with(registrant=REQUEST_USER)
430
431
    @operation_parameters(
431
 
        bug=Reference(schema=Interface)) # Really IBug
 
432
        bug=Reference(schema=Interface))  # Really IBug
432
433
    @export_write_operation()
433
434
    @operation_for_version('beta')
434
435
    def linkBug(bug, registrant):
440
441
 
441
442
    @call_with(user=REQUEST_USER)
442
443
    @operation_parameters(
443
 
        bug=Reference(schema=Interface)) # Really IBug
 
444
        bug=Reference(schema=Interface))  # Really IBug
444
445
    @export_write_operation()
445
446
    @operation_for_version('beta')
446
447
    def unlinkBug(bug, user):
455
456
        CollectionField(
456
457
            title=_("Specification linked to this branch."),
457
458
            readonly=True,
458
 
            value_type=Reference(Interface)), # Really ISpecificationBranch
 
459
            value_type=Reference(Interface)),  # Really ISpecificationBranch
459
460
        as_of="beta")
460
461
 
461
462
    @call_with(registrant=REQUEST_USER)
462
463
    @operation_parameters(
463
 
        spec=Reference(schema=Interface)) # Really ISpecification
 
464
        spec=Reference(schema=Interface))  # Really ISpecification
464
465
    @export_write_operation()
465
466
    @operation_for_version('beta')
466
467
    def linkSpecification(spec, registrant):
472
473
 
473
474
    @call_with(user=REQUEST_USER)
474
475
    @operation_parameters(
475
 
        spec=Reference(schema=Interface)) # Really ISpecification
 
476
        spec=Reference(schema=Interface))  # Really ISpecification
476
477
    @export_write_operation()
477
478
    @operation_for_version('beta')
478
479
    def unlinkSpecification(spec, user):
497
498
        CollectionField(
498
499
            title=_("BranchSubscriptions associated to this branch."),
499
500
            readonly=True,
500
 
            value_type=Reference(Interface))) # Really IBranchSubscription
 
501
            value_type=Reference(Interface)))  # Really IBranchSubscription
501
502
 
502
503
    subscribers = exported(
503
504
        CollectionField(
614
615
        merged_revnos=List(Int(
615
616
            title=_('The target-branch revno of the merge.'))))
616
617
    @call_with(visible_by_user=REQUEST_USER)
617
 
    @operation_returns_collection_of(Interface) # Really IBranchMergeProposal.
 
618
    # Really IBranchMergeProposal
 
619
    @operation_returns_collection_of(Interface)
618
620
    @export_read_operation()
619
621
    @operation_for_version('beta')
620
622
    def getMergeProposals(status=None, visible_by_user=None,
722
724
 
723
725
    def associatedSuiteSourcePackages():
724
726
        """Return the suite source packages that this branch is linked to.
725
 
        
 
727
 
726
728
        :return: A list of suite source packages ordered by pocket.
727
729
        """
728
730
 
771
773
        code_review_level=Choice(
772
774
            title=_("The level of code review notification emails."),
773
775
            vocabulary=CodeReviewNotificationLevel))
774
 
    @operation_returns_entry(Interface) # Really IBranchSubscription
 
776
    @operation_returns_entry(Interface)  # Really IBranchSubscription
775
777
    @call_with(subscribed_by=REQUEST_USER)
776
778
    @export_write_operation()
777
779
    @operation_for_version('beta')
794
796
        person=Reference(
795
797
            title=_("The person to unsubscribe"),
796
798
            schema=IPerson))
797
 
    @operation_returns_entry(Interface) # Really IBranchSubscription
 
799
    @operation_returns_entry(Interface)  # Really IBranchSubscription
798
800
    @export_read_operation()
799
801
    @operation_for_version('beta')
800
802
    def getSubscription(person):
1042
1044
    @operation_parameters(
1043
1045
        project=Reference(
1044
1046
            title=_("The project the branch belongs to."),
1045
 
            schema=Interface, required=False), # Really IProduct
 
1047
            schema=Interface, required=False),  # Really IProduct
1046
1048
        source_package=Reference(
1047
1049
            title=_("The source package the branch belongs to."),
1048
 
            schema=Interface, required=False)) # Really ISourcePackage
 
1050
            schema=Interface, required=False))  # Really ISourcePackage
1049
1051
    @export_write_operation()
1050
1052
    @operation_for_version('beta')
1051
1053
    def setTarget(user, project=None, source_package=None):
1307
1309
    @collection_default_content()
1308
1310
    def getBranches(limit=50, eager_load=True):
1309
1311
        """Return a collection of branches.
1310
 
        
1311
 
        :param eager_load: If True (the default because this is used in the 
1312
 
            web service and it needs the related objects to create links) eager
1313
 
            load related objects (products, code imports etc).
 
1312
 
 
1313
        :param eager_load: If True (the default because this is used in the
 
1314
            web service and it needs the related objects to create links)
 
1315
            eager load related objects (products, code imports etc).
1314
1316
        """
1315
1317
 
1316
1318
 
1425
1427
        return False
1426
1428
    celebs = getUtility(ILaunchpadCelebrities)
1427
1429
    return user.inTeam(celebs.admin) or user.inTeam(celebs.bazaar_experts)
 
1430
 
 
1431
 
 
1432
def get_db_branch_info(stacked_on_url, last_revision_id, control_string,
 
1433
                       branch_string, repository_string):
 
1434
    """Return a dict of branch info suitable for Branch.branchChanged.
 
1435
 
 
1436
    :param stacked_on_url: The URL the branch is stacked on.
 
1437
    :param last_revision_id: The branch tip revision_id.
 
1438
    :param control_string: The control format marker as a string.
 
1439
    :param branch_string: The branch format marker as a string.
 
1440
    :param repository_string: The repository format marker as a string.
 
1441
    """
 
1442
    info = {}
 
1443
    info['stacked_on_url'] = stacked_on_url
 
1444
    info['last_revision_id'] = last_revision_id
 
1445
    info['control_format'] = ControlFormat.get_enum(control_string)
 
1446
    info['branch_format'] = BranchFormat.get_enum(branch_string)
 
1447
    info['repository_format'] = RepositoryFormat.get_enum(repository_string)
 
1448
    return info