Rev 65: Allow passing in a branch argument to submit_bundle (useful for testing). in file:///home/jelmer/bzr-submit/trunk/

Jelmer Vernooij jelmer at samba.org
Wed Apr 11 15:33:30 BST 2007


At file:///home/jelmer/bzr-submit/trunk/

------------------------------------------------------------
revno: 65
revision-id: jelmer at samba.org-20070411143326-mrw7kislpzv0scb9
parent: jelmer at samba.org-20070409153408-w669pmw6slksneh5
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Wed 2007-04-11 16:33:26 +0200
message:
  Allow passing in a branch argument to submit_bundle (useful for testing).
modified:
  __init__.py                    __init__.py-20060624164558-9aabyghnw7kxeuwg-1
  submit_helpers.py              submit_helpers.py-20060624164558-9aabyghnw7kxeuwg-2
=== modified file '__init__.py'
--- a/__init__.py	2007-04-07 20:42:19 +0000
+++ b/__init__.py	2007-04-11 14:33:26 +0000
@@ -57,6 +57,9 @@
 
     def run(self, branch=None, from_address=None, **parameters):
         from submit_helpers import submit_bundle
+        from bzrlib.branch import Branch
+
+        branch = Branch.open_containing('.')[0]
         return submit_bundle(branch, mail_from=from_address, **parameters)
 
 

=== modified file 'submit_helpers.py'
--- a/submit_helpers.py	2007-04-09 15:34:08 +0000
+++ b/submit_helpers.py	2007-04-11 14:33:26 +0000
@@ -128,7 +128,6 @@
     return (mail_to, multipart, pqm)
 
 
-
 # Taken from pqm-submit plugin. 
 # http://bazaar.launchpad.net/~bzr-pqm-devel/bzr-pqm/devel/
 def public_branch(branch, config):
@@ -265,13 +264,13 @@
         msg.attach(part)
     return msg.as_string()
 
-def submit_bundle(base=None, revision=None, subject=None, dry_run=False, 
+def submit_bundle(branch=None, revision=None, subject=None, dry_run=False, 
     message_file=None, address=None, remember=False, target='default', 
     mail_from=None, output_file=None):
     """Submit a bundle via email.
     
         Parameters:
-            base, revision: Same as the parameter to the bundle command
+            branch, revision: Same as the parameter to the bundle command
             subject: Message subject (defaults to [PATCH] + commit_message)
             dry_run: Print the message to stdout
             message_file: Read message from this file
@@ -283,8 +282,6 @@
                          (forces dry_run = True)
     """
     
-    from bzrlib.bzrdir import BzrDir
-    branch = BzrDir.open_containing('.')[0].open_branch()
     config = BranchConfigSubmitBundle(branch)
     
     if output_file:
@@ -295,13 +292,13 @@
         mail_from = config.username()
 
     try:
-        mail_to, multipart, pqm = get_mailto(address, target, 
+        mail_to, multipart, pqm = get_mailto(config, address, target, 
             remember, dry_run)
     except BzrCommandError:
         #Ugly hack
         import __init__
         __init__.read_options(branch)
-        mail_to, multipart, pqm = get_mailto(address, target, 
+        mail_to, multipart, pqm = get_mailto(config, address, target, 
             remember, dry_run)
     
     bundle_text = get_bundle_text(base, revision, remember)
@@ -342,9 +339,8 @@
             f.close()
         else:
             print msg
-        return
-    
-    send_message(config, mail_from, mail_to, msg)
+    else:
+        send_message(config, mail_from, mail_to, msg)
     return 0 # Everything OK
 
 




More information about the bazaar-commits mailing list