Mercurial > hg-stable
diff hgext/patchbomb.py @ 23486:1de214837f5e
patchbomb: extract 'getoutgoing' closure into its own function
This continues my crusade against closure complication.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 02 Dec 2014 16:51:32 -0800 |
parents | a074eeeabe32 |
children | c14af817ab76 |
line wrap: on
line diff
--- a/hgext/patchbomb.py Thu Nov 20 16:27:55 2014 -0800 +++ b/hgext/patchbomb.py Tue Dec 02 16:51:32 2014 -0800 @@ -306,6 +306,22 @@ return msgs +def _getoutgoing(repo, dest, revs): + '''Return the revisions present locally but not in dest''' + ui = repo.ui + url = ui.expandpath(dest or 'default-push', dest or 'default') + url = hg.parseurl(url)[0] + ui.status(_('comparing with %s\n') % util.hidepassword(url)) + + revs = [r for r in scmutil.revrange(repo, revs) if r >= 0] + if not revs: + revs = [len(repo) - 1] + revs = repo.revs('outgoing(%s) and ::%ld', dest or '', revs) + if not revs: + ui.status(_("no changes found\n")) + return [] + return [str(r) for r in revs] + emailopts = [ ('', 'body', None, _('send patches as inline message text (default)')), ('a', 'attach', None, _('send patches as attachments')), @@ -430,21 +446,6 @@ # internal option used by pbranches patches = opts.get('patches') - def getoutgoing(dest, revs): - '''Return the revisions present locally but not in dest''' - url = ui.expandpath(dest or 'default-push', dest or 'default') - url = hg.parseurl(url)[0] - ui.status(_('comparing with %s\n') % util.hidepassword(url)) - - revs = [r for r in scmutil.revrange(repo, revs) if r >= 0] - if not revs: - revs = [len(repo) - 1] - revs = repo.revs('outgoing(%s) and ::%ld', dest or '', revs) - if not revs: - ui.status(_("no changes found\n")) - return [] - return [str(r) for r in revs] - if not (opts.get('test') or mbox): # really sending mail.validateconfig(ui) @@ -468,7 +469,7 @@ revs = rev if outgoing: - revs = getoutgoing(dest, rev) + revs = _getoutgoing(repo, dest, rev) if bundle: opts['revs'] = revs