changeset 5755:43ee007dbd0e

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Fri, 28 Dec 2007 16:46:44 +0100
parents 75c2071385da (current diff) ea1016b32e94 (diff)
children 3aa0af7d539d
files hgext/patchbomb.py
diffstat 3 files changed, 79 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Fri Dec 28 14:51:16 2007 +0100
+++ b/hgext/patchbomb.py	Fri Dec 28 16:46:44 2007 +0100
@@ -216,7 +216,7 @@
         tmpfn = os.path.join(tmpdir, 'bundle')
         try:
             commands.bundle(ui, repo, tmpfn, dest, **opts)
-            return open(tmpfn).read()
+            return open(tmpfn, 'rb').read()
         finally:
             try:
                 os.unlink(tmpfn)
@@ -261,6 +261,15 @@
     def genmsgid(id):
         return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
 
+    def getdescription(body, sender):
+        if opts['desc']:
+            body = open(opts['desc']).read()
+        else:
+            ui.write(_('\nWrite the introductory message for the '
+                       'patch series.\n\n'))
+            body = ui.edit(body, sender)
+        return body
+
     def getexportmsgs():
         patches = []
 
@@ -306,13 +315,7 @@
                 d = cdiffstat(_('Final summary:\n'), jumbo)
                 if d: body = '\n' + d
 
-            if opts['desc']:
-                body = open(opts['desc']).read()
-            else:
-                ui.write(_('\nWrite the introductory message for the '
-                           'patch series.\n\n'))
-                body = ui.edit(body, sender)
-
+            body = getdescription(body, sender)
             msg = email.MIMEText.MIMEText(body)
             msg['Subject'] = subj
 
@@ -322,9 +325,8 @@
     def getbundlemsgs(bundle):
         subj = (opts['subject']
                 or prompt('Subject:', default='A bundle for your repository'))
-        ui.write(_('\nWrite the introductory message for the bundle.\n\n'))
-        body = ui.edit('', sender)
 
+        body = getdescription('', sender)
         msg = email.MIMEMultipart.MIMEMultipart()
         if body:
             msg.attach(email.MIMEText.MIMEText(body, 'plain'))
--- a/tests/test-patchbomb	Fri Dec 28 14:51:16 2007 +0100
+++ b/tests/test-patchbomb	Fri Dec 28 16:46:44 2007 +0100
@@ -1,20 +1,46 @@
 #!/bin/sh
 
+fixheaders()
+{
+    sed -e 's/\(Message-Id:.*@\).*/\1/'  \
+        -e 's/\(In-Reply-To:.*@\).*/\1/' \
+        -e 's/===.*/===/'
+}
+
 echo "[extensions]" >> $HGRCPATH
 echo "patchbomb=" >> $HGRCPATH
 
-hg init
+hg init t
+cd t
 echo a > a
 hg commit -Ama -d '1 0'
 
 hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar tip | \
-  sed -e 's/\(Message-Id:.*@\).*/\1/'
+  fixheaders
 
 echo b > b
 hg commit -Amb -d '2 0'
 
 hg email --date '1970-1-1 0:2' -n -f quux -t foo -c bar -s test 0:tip | \
-  sed -e 's/\(Message-Id:.*@\).*/\1/' | \
-  sed -e 's/\(In-Reply-To:.*@\).*/\1/'
+  fixheaders
 
 hg email -m test.mbox -f quux -t foo -c bar -s test 0:tip
+
+cd ..
+
+hg clone -q t t2
+cd t2
+echo c > c
+hg commit -Amc -d '3 0'
+
+cat > description <<EOF
+a multiline
+
+description
+EOF
+
+echo % test bundle and description
+hg email --date '1970-1-1 0:3' -n -f quux -t foo \
+    -c bar -s test -r tip -b --desc description | \
+    fixheaders
+
--- a/tests/test-patchbomb.out	Fri Dec 28 14:51:16 2007 +0100
+++ b/tests/test-patchbomb.out	Fri Dec 28 16:46:44 2007 +0100
@@ -107,3 +107,40 @@
 Writing [PATCH 0 of 2] test ...
 Writing [PATCH 1 of 2] a ...
 Writing [PATCH 2 of 2] b ...
+adding c
+% test bundle and description
+searching for changes
+
+Displaying test ...
+Content-Type: multipart/mixed; boundary="===
+MIME-Version: 1.0
+Subject: test
+Message-Id: <patchbomb.180@
+Date: Thu, 01 Jan 1970 00:03:00 +0000
+From: quux
+To: foo
+Cc: bar
+
+--===
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+a multiline
+
+description
+
+--===
+Content-Type: application/x-mercurial-bundle
+MIME-Version: 1.0
+Content-Disposition: attachment; filename="bundle.hg"
+Content-Transfer-Encoding: base64
+
+SEcxMEJaaDkxQVkmU1nvR7I3AAAN////lFYQWj1/4HwRkdC/AywIAk0E4pfoSIIIgQCgGEQOcLAA
+2tA1VPyp4mkeoG0EaaPU0GTT1GjRiNPIg9CZGBqZ6UbU9J+KFU09DNUaGgAAAAAANAGgAAAAA1U8
+oGgAADQGgAANNANAAAAAAZipFLz3XoakCEQB3PVPyHJVi1iYkAAKQAZQGpQGZESInRnCFMqLDla2
+Bx3qfRQeA2N4lnzKkAmP8kR2asievLLXXebVU8Vg4iEBqcJNJAxIapSU6SM4888ZAciRG6MYAIEE
+SlIBpFisgGkyRjX//TMtfcUAEsGu56+YnE1OlTZmzKm8BSu2rvo4rHAYYaadIFFuTy0LYgIkgLVD
+sgVa2F19D1tx9+hgbAygLgQwaIqcDdgA4BjQgIiz/AEP72++llgDKhKducqodGE4B0ETqF3JFOFC
+Q70eyNw=
+--===