[PATCH 1 of 3] patchbomb: extract 'getoutgoing' closure into its own function
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Dec 3 03:12:04 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1417567892 28800
# Tue Dec 02 16:51:32 2014 -0800
# Node ID f5b943c897859b30aa362e0a7c61daa14e928a57
# Parent fc76f55705eb5884707c977ecb756aee7c794676
patchbomb: extract 'getoutgoing' closure into its own function
This continue my crusade against closure complication.
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -304,10 +304,26 @@ def _getpatchmsgs(repo, sender, patches,
len(patches), numbered, name)
msgs.append(msg)
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')),
('i', 'inline', None, _('send patches as inline attachments')),
('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
@@ -428,25 +444,10 @@ def patchbomb(ui, repo, *revs, **opts):
outgoing = opts.get('outgoing')
rev = opts.get('rev')
# 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)
if not (revs or rev or outgoing or bundle or patches):
@@ -466,11 +467,11 @@ def patchbomb(ui, repo, *revs, **opts):
if revs:
raise util.Abort(_('use only one form to specify the revision'))
revs = rev
if outgoing:
- revs = getoutgoing(dest, rev)
+ revs = _getoutgoing(repo, dest, rev)
if bundle:
opts['revs'] = revs
# start
if date:
More information about the Mercurial-devel
mailing list