Merge lp:~jelmer/bzr-email/cmd into lp:bzr-email

Proposed by Jelmer Vernooij
Status: Rejected
Rejected by: Jelmer Vernooij
Proposed branch: lp:~jelmer/bzr-email/cmd
Merge into: lp:bzr-email
Diff against target: 57 lines (+40/-0)
1 file modified
__init__.py (+40/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-email/cmd
To post a comment you must log in.

Unmerged revisions

30. By Jelmer Vernooij

Merge trunk.

29. By Jelmer Vernooij

Proper help for dry-run option.

28. By Jelmer Vernooij

Support send-email command in other directories than the root of a branch.

27. By Jelmer Vernooij

Merge trunk.

26. By Jelmer Vernooij

Use right branch object.

25. By Jelmer Vernooij

Add command for manually invoking the send email plugin.

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2010-03-11 07:24:31 +0000
3+++ __init__.py 2010-05-04 14:42:25 +0000
4@@ -74,6 +74,8 @@
5 # These three are used during import: No point lazy_importing them.
6 from bzrlib import errors
7 from bzrlib.branch import Branch
8+from bzrlib.commands import Command, register_command
9+from bzrlib.option import Option
10 from bzrlib.lazy_import import lazy_import
11
12 # lazy_import emailer so that it doesn't get loaded if it isn't used
13@@ -124,6 +126,44 @@
14 return result
15
16
17+class cmd_send_email(Command):
18+ """Send email for specified revision.
19+
20+ """
21+ takes_args = ['branch?']
22+ takes_options = ['revision', Option('dry-run',
23+ help="Show what would be done, but don't actually do anything.")]
24+
25+ def run(self, branch='.', revision=None,dry_run=False):
26+ br = Branch.open_containing(branch)[0]
27+
28+ if revision is None:
29+ revs = [br.last_revision()]
30+ elif len(revision) == 1:
31+ revs = [revision[0].in_history(br).rev_id]
32+ elif len(revision) == 2:
33+ if revision[0].spec is None:
34+ from_revno = 1
35+ else:
36+ from_revno = revision[0].in_history(br).revno
37+
38+ if revision[1].spec is None:
39+ to_revno = br.revno()
40+ else:
41+ to_revno = revision[1].in_history(br).revno
42+ revs = br.revision_history()[from_revno:to_revno]
43+ else:
44+ raise BzrCommandError('bzr send-email --revision takes one or two arguments')
45+
46+ for rev_id in revs:
47+ _emailer.EmailSender(br, rev_id, br.get_config()).send()
48+
49+ return 0
50+
51+
52+register_command(cmd_send_email)
53+
54+
55 # setup the email plugin with > 0.15 hooks.
56 try:
57 install_hooks()

Subscribers

People subscribed via source and target branches

to all changes: