changeset 14309:37e80214badf

patchbomb: use cmdutil.command decorator
author Adrian Buehlmann <adrian@cadifra.com>
date Thu, 12 May 2011 18:27:05 +0200
parents e7ea3e38fea8
children c16ec14d44b6
files hgext/patchbomb.py
diffstat 1 files changed, 37 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Thu May 12 17:50:07 2011 +0200
+++ b/hgext/patchbomb.py	Thu May 12 18:27:05 2011 +0200
@@ -52,6 +52,9 @@
 from mercurial.i18n import _
 from mercurial.node import bin
 
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
 def prompt(ui, prompt, default=None, rest=':'):
     if not ui.interactive() and default is None:
         raise util.Abort(_("%s Please enter a valid value" % (prompt + rest)))
@@ -146,6 +149,40 @@
     msg['X-Mercurial-Node'] = node
     return msg, subj, ds
 
+emailopts = [
+    ('a', 'attach', None, _('send patches as attachments')),
+    ('i', 'inline', None, _('send patches as inline attachments')),
+    ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
+    ('c', 'cc', [], _('email addresses of copy recipients')),
+    ('', 'confirm', None, _('ask for confirmation before sending')),
+    ('d', 'diffstat', None, _('add diffstat output to messages')),
+    ('', 'date', '', _('use the given date as the sending date')),
+    ('', 'desc', '', _('use the given file as the series description')),
+    ('f', 'from', '', _('email address of sender')),
+    ('n', 'test', None, _('print messages that would be sent')),
+    ('m', 'mbox', '', _('write messages to mbox file instead of sending them')),
+    ('', 'reply-to', [], _('email addresses replies should be sent to')),
+    ('s', 'subject', '', _('subject of first message (intro or single patch)')),
+    ('', 'in-reply-to', '', _('message identifier to reply to')),
+    ('', 'flag', [], _('flags to add in subject prefixes')),
+    ('t', 'to', [], _('email addresses of recipients'))]
+
+@command('email',
+    [('g', 'git', None, _('use git extended diff format')),
+    ('', 'plain', None, _('omit hg patch header')),
+    ('o', 'outgoing', None,
+     _('send changes not found in the target repository')),
+    ('b', 'bundle', None, _('send changes not in target as a binary bundle')),
+    ('', 'bundlename', 'bundle',
+     _('name of the bundle attachment file'), _('NAME')),
+    ('r', 'rev', [], _('a revision to send'), _('REV')),
+    ('', 'force', None, _('run even when remote repository is unrelated '
+       '(with -b/--bundle)')),
+    ('', 'base', [], _('a base changeset to specify instead of a destination '
+       '(with -b/--bundle)'), _('REV')),
+    ('', 'intro', None, _('send an introduction email for a single patch')),
+    ] + emailopts + commands.remoteopts,
+    _('hg email [OPTION]... [DEST]...'))
 def patchbomb(ui, repo, *revs, **opts):
     '''send changesets by email
 
@@ -511,52 +548,3 @@
 
     ui.progress(_('writing'), None)
     ui.progress(_('sending'), None)
-
-emailopts = [
-          ('a', 'attach', None, _('send patches as attachments')),
-          ('i', 'inline', None, _('send patches as inline attachments')),
-          ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
-          ('c', 'cc', [], _('email addresses of copy recipients')),
-          ('', 'confirm', None, _('ask for confirmation before sending')),
-          ('d', 'diffstat', None, _('add diffstat output to messages')),
-          ('', 'date', '', _('use the given date as the sending date')),
-          ('', 'desc', '', _('use the given file as the series description')),
-          ('f', 'from', '', _('email address of sender')),
-          ('n', 'test', None, _('print messages that would be sent')),
-          ('m', 'mbox', '',
-           _('write messages to mbox file instead of sending them')),
-          ('', 'reply-to', [], _('email addresses replies should be sent to')),
-          ('s', 'subject', '',
-           _('subject of first message (intro or single patch)')),
-          ('', 'in-reply-to', '',
-           _('message identifier to reply to')),
-          ('', 'flag', [], _('flags to add in subject prefixes')),
-          ('t', 'to', [], _('email addresses of recipients')),
-         ]
-
-
-cmdtable = {
-    "email":
-        (patchbomb,
-         [('g', 'git', None, _('use git extended diff format')),
-          ('', 'plain', None, _('omit hg patch header')),
-          ('o', 'outgoing', None,
-           _('send changes not found in the target repository')),
-          ('b', 'bundle', None,
-           _('send changes not in target as a binary bundle')),
-          ('', 'bundlename', 'bundle',
-           _('name of the bundle attachment file'), _('NAME')),
-          ('r', 'rev', [],
-           _('a revision to send'), _('REV')),
-          ('', 'force', None,
-           _('run even when remote repository is unrelated '
-             '(with -b/--bundle)')),
-          ('', 'base', [],
-           _('a base changeset to specify instead of a destination '
-             '(with -b/--bundle)'),
-           _('REV')),
-          ('', 'intro', None,
-           _('send an introduction email for a single patch')),
-         ] + emailopts + commands.remoteopts,
-         _('hg email [OPTION]... [DEST]...'))
-}