Merge lp://staging/~james-w/tarmac/break-up-do-merges into lp://staging/~ubuntuone-hackers/tarmac/trunk
Proposed by
James Westby
Status: | Merged |
---|---|
Merged at revision: | 420 |
Proposed branch: | lp://staging/~james-w/tarmac/break-up-do-merges |
Merge into: | lp://staging/~ubuntuone-hackers/tarmac/trunk |
Prerequisite: | lp://staging/~james-w/tarmac/commit-message |
Diff against target: |
453 lines (+206/-191) 1 file modified
tarmac/bin/commands.py (+206/-191) |
To merge this branch: | bzr merge lp://staging/~james-w/tarmac/break-up-do-merges |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange (community) | Needs Fixing | ||
Review via email: mp+140554@code.staging.launchpad.net |
This proposal supersedes a proposal from 2012-12-18.
Description of the change
Hi,
This branch breaks up the _do_merges method a little, as it was huge.
I tried to keep changes to a minimum while moving the code around, but it
used "continue" for flow control, so I had to change it a little to
use return values.
Thanks,
James
To post a comment you must log in.
On 18 December 2012 21:26, James Westby <email address hidden> wrote: /code.launchpad .net/~james- w/tarmac/ break-up- do-merges/ +merge/ 140554
> James Westby has proposed merging lp:~james-w/tarmac/break-up-do-merges into lp:~ubuntuone-hackers/tarmac/trunk with lp:~james-w/tarmac/commit-message as a prerequisite.
>
> Requested reviews:
> Ubuntu One hackers (ubuntuone-hackers)
>
> For more details, see:
> https:/
>
> Hi,
>
> This branch breaks up the _do_merges method a little, as it was huge.
>
It was!
See inline.
> I tried to keep changes to a minimum while moving the code around, but it
> used "continue" for flow control, so I had to change it a little to
> use return values.
>
... bin/commands. py' bin/commands. py 2012-09-05 18:08:50 +0000 bin/commands. py 2012-12-18 21:25:42 +0000 self.outf) proposals_ for_branch( lp_branch, logger, imply_commit_ message= False): landing_ candidates: debug(" Considering merge proposal: {0}".format( entry.web_ link)) ".format( entry.queue_ status) ) message and not entry.commit_ message) : append( entry)
> === modified file 'tarmac/
> --- tarmac/
> +++ tarmac/
> @@ -134,6 +134,194 @@
> help_commands(
>
>
> +def _get_mergable_
> + """Return a list of the mergable proposals for the given branch."""
> + proposals = []
> + for entry in lp_branch.
> + logger.
> +
> + if entry.queue_status != u'Approved':
> + logger.debug(
> + " Skipping proposal: status is {0}, not "
> + "'Approved'
> + continue
> +
> + if (not imply_commit_
> + logger.debug(
> + " Skipping proposal: proposal has no commit message")
> + continue
> +
> + proposals.
> + return proposals
> +
This seems a natural candidate for an iterator. Still, no big deal.
> +def _get_reviews( proposal) : append( '%s;%s' % (vote.reviewer. display_ name,
> + """Get the set of reviews from the proposal."""
> + reviews = []
> + for vote in proposal.votes:
> + if not vote.comment:
> + continue
> + else:
> + reviews.
> + vote.comment.vote))
> +
> + if len(reviews) == 0:
> + return None
> +
> + return reviews
> +
Again, a potential iterator, and again, I don't care enough for this branch.
Implementation could probably be more functional, but even this is a
huge step forwards.
> +
> +def setup(logger, debug=False, http_debug=False):
"setup" is a noun, "set up" a verb phrase. This should be spelled
"set_up". Also, it should probably say what it's going to set up.
> +def merge_proposals (target, proposals, logger, config, command): debug(' Firing tarmac_pre_merge hook') hooks.fire( 'tarmac_ pre_merge' , target, proposal, logger, append( status)
> + logger.
> + tarmac_
> + command, target)
> +
> + statuses = []
> + try:
> + for proposal in proposals:
> + status = merge_proposal(
> + config, command)
> + statuses.
> + # This except is here because we need the else and can't have it
> + # without an except as well.
Wat.
try:
thing()
except:
raise
else:
another_thing()
...