diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -86,7 +86,13 @@ def patchbomb(ui, repo, *revs, **opts): The message contains two or three body parts. First, the rest of the changeset description. Next, (optionally) if the diffstat program is installed, the result of running diffstat on the patch. - Finally, the patch itself, as generated by "hg export".''' + Finally, the patch itself, as generated by "hg export". + + With --outgoing, emails will be generated for patches not + found in the target repository (or only those which are + ancestors of the specified revisions if any are provided) + ''' + def prompt(prompt, default = None, rest = ': ', empty_ok = False): if default: prompt += ' [%s]' % default prompt += rest @@ -165,6 +171,36 @@ def patchbomb(ui, repo, *revs, **opts): msg['X-Mercurial-Node'] = node return msg + def outgoing(dest, revs): + '''Return the revisions present locally but not in dest''' + dest = ui.expandpath(dest or 'default-push', dest or 'default') + revs = [repo.lookup(rev) for rev in revs] + other = hg.repository(ui, dest) + ui.status(_('comparing with %s\n') % dest) + o = repo.findoutgoing(other) + if not o: + ui.status(_("no changes found\n")) + return [] + o = repo.changelog.nodesbetween(o, revs or None)[0] + return [str(repo.changelog.rev(r)) for r in o] + + # option handling + commands.setremoteconfig(ui, opts) + if opts.get('outgoing'): + if len(revs) > 1: + raise util.Abort(_("too many destinations")) + dest = revs and revs[0] or None + revs = [] + + if opts.get('rev'): + if revs: + raise util.Abort(_('use only one form to specify the revision')) + revs = opts.get('rev') + + if opts.get('outgoing'): + revs = outgoing(dest, opts.get('rev')) + + # start start_time = util.makedate() def genmsgid(id): @@ -299,7 +335,9 @@ cmdtable = { ('', 'plain', None, 'omit hg patch header'), ('n', 'test', None, 'print messages that would be sent'), ('m', 'mbox', '', 'write messages to mbox file instead of sending them'), + ('o', 'outgoing', None, _('send changes not found in the target repository')), + ('r', 'rev', [], _('a revision to send')), ('s', 'subject', '', 'subject of first message (intro or single patch)'), - ('t', 'to', [], 'email addresses of recipients')], - "hg email [OPTION]... [REV]...") + ('t', 'to', [], 'email addresses of recipients')] + commands.remoteopts, + "hg email [OPTION]... [DEST]...") }