~psivaa/tarmac/list-all-mps

« back to all changes in this revision

Viewing changes to tarmac/bin/commands.py

  • Committer: Parameswaran Sivatharman
  • Date: 2015-07-27 13:08:42 UTC
  • Revision ID: para.siva@canonical.com-20150727130842-xxgsp0efoq7r1d3o
Adding option to list all MP's that needs review

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
        options.imply_commit_message_option,
175
175
        options.one_option,
176
176
        options.list_approved_option,
 
177
        options.list_all_option,
177
178
        options.proposal_option,
178
179
    ]
179
180
 
213
214
            proposals = [source_mp]
214
215
        else:
215
216
            proposals = self._get_mergable_proposals_for_branch(lp_branch)
 
217
            all_proposals = self._get_all_proposals_for_branch(lp_branch)
216
218
 
217
219
        if not proposals:
218
220
            self.logger.info(
225
227
                print(proposal.web_link)
226
228
            return
227
229
 
 
230
        if self.config.list_all:
 
231
            for proposal in all_proposals:
 
232
                print(proposal.web_link)
 
233
            return
 
234
 
228
235
        try:
229
236
            target = Branch.create(lp_branch, self.config, create_tree=True,
230
237
                                   launchpad=self.launchpad)
383
390
            proposals.append(entry)
384
391
        return proposals
385
392
 
 
393
    def _get_all_proposals_for_branch(self, lp_branch):
 
394
        """
 
395
        Return a list of proposals for the given branch.
 
396
        """
 
397
        proposals = []
 
398
        sorted_proposals = sorted(
 
399
            lp_branch.landing_candidates, cmp=_compare_proposals)
 
400
        for entry in sorted_proposals:
 
401
            self.logger.debug("Considering merge "
 
402
                              "proposal: {0}".format(entry.web_link))
 
403
            prereqs = self._get_prerequisite_proposals(entry)
 
404
 
 
405
            if (entry.queue_status != u'Needs review' and
 
406
                    entry.queue_status != u'Approved'):
 
407
                self.logger.debug(
 
408
                    "  Skipping proposal: status is {0}, not "
 
409
                    "'Approved' or 'Needs review'".format(entry.queue_status))
 
410
                continue
 
411
 
 
412
            proposals.append(entry)
 
413
        return proposals
 
414
 
386
415
    def _get_prerequisite_proposals(self, proposal):
387
416
        """
388
417
        Given a proposal, return all prerequisite
470
499
                        'An error occurred trying to merge %s: %s',
471
500
                        branch, error)
472
501
                    raise
473