Rev 67: Move revision parse code to cmd_submit_bundle class. in file:///home/jelmer/bzr-submit/trunk/

Jelmer Vernooij jelmer at samba.org
Wed Apr 11 15:52:46 BST 2007


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

------------------------------------------------------------
revno: 67
revision-id: jelmer at samba.org-20070411145239-6scra7lush8lk57w
parent: jelmer at samba.org-20070411144429-a40kzl6gdnfqyazf
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Wed 2007-04-11 16:52:39 +0200
message:
  Move revision parse code to cmd_submit_bundle class.
modified:
  TODO                           todo-20061109184753-jxe69s6g2p00byt4-1
  __init__.py                    __init__.py-20060624164558-9aabyghnw7kxeuwg-1
  submit_helpers.py              submit_helpers.py-20060624164558-9aabyghnw7kxeuwg-2
=== modified file 'TODO'
--- a/TODO	2007-03-23 23:17:50 +0000
+++ b/TODO	2007-04-11 14:52:39 +0000
@@ -2,3 +2,4 @@
 - Convert to 0.15 hooks
 - Write tests!
 - Set content-type headers.
+- support submitting more than one bundle

=== modified file '__init__.py'
--- a/__init__.py	2007-04-11 14:34:22 +0000
+++ b/__init__.py	2007-04-11 14:52:39 +0000
@@ -55,12 +55,22 @@
                     ]
     aliases = ['submit']
 
-    def run(self, branch=None, from_address=None, **parameters):
+    def run(self, branch=None, from_address=None, revision=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)
+        if revision is None:
+            rev_id = branch.last_revision()
+        else:
+            if len(revision)==1:
+                rev_id = revision[0].in_history(branch).rev_id
+            else:
+                rev_id = revision[1].in_history(branch).rev_id    
+                if rev_id is None:
+                    rev_id = revision[0].in_history(branch).rev_id
+        return submit_bundle(branch, mail_from=from_address, revision=rev_id,
+                             **parameters)
 
 
 class cmd_apply_bundle(Command):

=== modified file 'submit_helpers.py'
--- a/submit_helpers.py	2007-04-11 14:44:29 +0000
+++ b/submit_helpers.py	2007-04-11 14:52:39 +0000
@@ -17,6 +17,7 @@
 from bzrlib import (bundle, errors, gpg, user_encoding) 
 from bzrlib.bundle.serializer import (read_bundle, write_bundle)
 from bzrlib.errors import BzrCommandError
+from bzrlib.testament import Testament
 from bzrlib.trace import (note, warning)
 
 # This allows easy extension
@@ -145,26 +146,6 @@
     return target_base
 
 
-def get_testament(branch, revision):
-    """ Get the testament for the specified revision. """
-    from bzrlib.testament import Testament
-    branch.lock_read()
-    try:
-        if revision is None:
-            rev_id = branch.last_revision()
-        else:
-            if len(revision)==1:
-                rev_id = revision[0].in_history(branch).rev_id
-            else:
-                rev_id = revision[1].in_history(branch).rev_id    
-                if rev_id is None:
-                    rev_id = revision[0].in_history(branch).rev_id
-        testament = Testament.from_revision(branch.repository, 
-            rev_id).as_short_text()
-    finally:
-        branch.unlock()
-    return testament
-
 def send_message(config, mail_from, mail_to, msg_text):
     """ Actually send the message via smtp. """
     username = config.get_smtp_user()
@@ -285,8 +266,9 @@
             base = public_branch(branch, config) 
         message_text = "patch %s" % base
 
-    message_text = message_text + "\n" + get_testament(branch, revision)
-    
+    message_text += "\n" + \
+            Testament.from_revision(branch.repository, revision).as_short_text()
+
     if not multipart:
         message_text = message_text + bundle_text
     
@@ -375,7 +357,6 @@
     
     from bzrlib.workingtree import WorkingTree
     from bzrlib.bundle.apply_bundle import install_bundle
-    from bzrlib.testament import Testament
     from bzrlib.merge import Merge3Merger
     testament_re = re.compile(r'bazaar-ng testament short form 1' +
         r'(?P<lineending>\r\n|\n)'+




More information about the bazaar-commits mailing list