patchbomb: add a 'bundletype' config under 'patchbomb'
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 01 Oct 2015 23:13:57 -0700
changeset 26563 d4a1bfe1de63
parent 26562 dd2f5e014806
child 26564 bed9e6c706f6
patchbomb: add a 'bundletype' config under 'patchbomb' patchbomb relies on the 'hg bundle' command to generate an attached bundle using --bundle. However, while 'hg bundle' has a --type option, patchbomb did not. This is becoming very relevant since we are about to issue bundle2 for general-delta repository. This was tracked as issue4863
hgext/patchbomb.py
tests/test-patchbomb.t
--- a/hgext/patchbomb.py	Wed Oct 07 13:05:25 2015 -0700
+++ b/hgext/patchbomb.py	Thu Oct 01 23:13:57 2015 -0700
@@ -223,6 +223,9 @@
     ui = repo.ui
     tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
     tmpfn = os.path.join(tmpdir, 'bundle')
+    btype = ui.config('patchbomb', 'bundletype')
+    if btype:
+        opts['type'] = btype
     try:
         commands.bundle(ui, repo, tmpfn, dest, **opts)
         fp = open(tmpfn, 'rb')
@@ -434,7 +437,8 @@
 
     With -b/--bundle, changesets are selected as for --outgoing, but a
     single email containing a binary Mercurial bundle as an attachment
-    will be sent.
+    will be sent. Use the ``patchbomb.bundletype`` config option to
+    control the bundle type as with :hg:`bundle --type`.
 
     With -m/--mbox, instead of previewing each patchbomb message in a
     pager or sending the messages directly, it will create a UNIX
--- a/tests/test-patchbomb.t	Wed Oct 07 13:05:25 2015 -0700
+++ b/tests/test-patchbomb.t	Thu Oct 01 23:13:57 2015 -0700
@@ -356,6 +356,48 @@
   Q70eyNw=
   --===*=-- (glob)
 
+with a specific bundle type
+(binary part must be different)
+
+  $ hg email --date '1970-1-1 0:3' -n -f quux -t foo \
+  >  -c bar -s test -r tip -b --desc description \
+  > --config patchbomb.bundletype=gzip | $FILTERBOUNDARY
+  searching for changes
+  1 changesets found
+  
+  displaying test ...
+  Content-Type: multipart/mixed; boundary="===*==" (glob)
+  MIME-Version: 1.0
+  Subject: test
+  Message-Id: <patchbomb.180@*> (glob)
+  User-Agent: Mercurial-patchbomb/* (glob)
+  Date: Thu, 01 Jan 1970 00:03:00 +0000
+  From: quux
+  To: foo
+  Cc: bar
+  
+  --===*= (glob)
+  Content-Type: text/plain; charset="us-ascii"
+  MIME-Version: 1.0
+  Content-Transfer-Encoding: 7bit
+  
+  a multiline
+  
+  description
+  
+  --===*= (glob)
+  Content-Type: application/x-mercurial-bundle
+  MIME-Version: 1.0
+  Content-Disposition: attachment; filename="bundle.hg"
+  Content-Transfer-Encoding: base64
+  
+  SEcxMEdaeJxjYGBY8V9n/iLGbtFfJZuNk/euDCpWfrRy/vTrevFCx1/4t7J5LdeL0ix0Opx3kwEL
+  wKYXKqUJwqnG5sYWSWmmJsaWlqYWaRaWJpaWiWamZpYWRgZGxolJiabmSQbmZqlcQMV6QGwCxGzG
+  CgZcySARUyA2A2LGZKiZ3Y+Lu786z4z4MWXmsrAZCsqrl1az5y21PMcjpbThzWeXGT+/nutbmvvz
+  zXYS3BoGxdrJDIYmlimJJiZpRokmqYYmaSYWFknmSSkmhqbmliamiZYWxuYmBhbJBgZcUBNZQe5K
+  Epm7xF/LT+RLx/a9juFTomaYO/Rgsx4rwBN+IMCUDLOKAQBrsmti
+  --===============*==-- (glob)
+
 utf-8 patch:
   $ $PYTHON -c 'fp = open("utf", "wb"); fp.write("h\xC3\xB6mma!\n"); fp.close();'
   $ hg commit -A -d '4 0' -m 'utf-8 content'