changeset 4566:087b3ae4f08a

patchbomb: add --date option
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 12 Jun 2007 14:52:34 -0700
parents 1cf908c00479
children 8b87bd4fb7ce
files hgext/patchbomb.py tests/test-patchbomb
diffstat 2 files changed, 108 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Tue Jun 12 14:44:47 2007 -0700
+++ b/hgext/patchbomb.py	Tue Jun 12 14:52:34 2007 -0700
@@ -252,7 +252,10 @@
         opts['revs'] = revs
 
     # start
-    start_time = util.makedate()
+    if opts.get('date'):
+        start_time = util.parsedate(opts['date'])
+    else:
+        start_time = util.makedate()
 
     def genmsgid(id):
         return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
@@ -407,6 +410,7 @@
       ('', 'bcc', [], 'email addresses of blind copy recipients'),
       ('c', 'cc', [], 'email addresses of copy recipients'),
       ('d', 'diffstat', None, 'add diffstat output to messages'),
+      ('', 'date', '', _('use the given date as the sending date')),
       ('g', 'git', None, _('use git extended diff format')),
       ('f', 'from', '', 'email address of sender'),
       ('', 'plain', None, 'omit hg patch header'),
--- a/tests/test-patchbomb	Tue Jun 12 14:44:47 2007 -0700
+++ b/tests/test-patchbomb	Tue Jun 12 14:52:34 2007 -0700
@@ -1,19 +1,109 @@
-#!/bin/sh
+adding a
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH] a
+X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+Message-Id: <8580ff50825a50c8f716.60@
+Date: Thu, 01 Jan 1970 00:01:00 +0000
+From: quux
+To: foo
+Cc: bar
+
+# HG changeset patch
+# User test
+# Date 1 0
+# Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+# Parent  0000000000000000000000000000000000000000
+a
+
+diff -r 000000000000 -r 8580ff50825a a
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/a	Thu Jan 01 00:00:01 1970 +0000
+@@ -0,0 +1,1 @@
++a
 
-echo "[extensions]" >> $HGRCPATH
-echo "patchbomb=" >> $HGRCPATH
+This patch series consists of 1 patches.
+
 
-hg init
-echo a > a
-hg commit -Ama -d '1 0'
+Displaying [PATCH] a ...
+adding b
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 0 of 2] test
+Message-Id: <patchbomb.120@
+Date: Thu, 01 Jan 1970 00:02:00 +0000
+From: quux
+To: foo
+Cc: bar
+
+
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 1 of 2] a
+X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+Message-Id: <8580ff50825a50c8f716.121@
+In-Reply-To: <patchbomb.120@
+Date: Thu, 01 Jan 1970 00:02:01 +0000
+From: quux
+To: foo
+Cc: bar
 
-hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar tip | \
-  sed -e 's/\(Message-Id:.*@\).*/\1/'
+# HG changeset patch
+# User test
+# Date 1 0
+# Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+# Parent  0000000000000000000000000000000000000000
+a
+
+diff -r 000000000000 -r 8580ff50825a a
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/a	Thu Jan 01 00:00:01 1970 +0000
+@@ -0,0 +1,1 @@
++a
+
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 2 of 2] b
+X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+Message-Id: <97d72e5f12c7e84f8506.122@
+In-Reply-To: <patchbomb.120@
+Date: Thu, 01 Jan 1970 00:02:02 +0000
+From: quux
+To: foo
+Cc: bar
 
-echo b > b
-hg commit -Amb -d '2 0'
+# HG changeset patch
+# User test
+# Date 2 0
+# Node ID 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+# Parent  8580ff50825a50c8f716709acdf8de0deddcd6ab
+b
+
+diff -r 8580ff50825a -r 97d72e5f12c7 b
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/b	Thu Jan 01 00:00:02 1970 +0000
+@@ -0,0 +1,1 @@
++b
+
+This patch series consists of 2 patches.
+
 
-hg email --date '1970-1-1 0:2' -n -f quux -t foo -c bar -s test 0:tip | \
-  sed -e 's/\(Message-Id:.*@\|In-Reply-To:.*@\).*/\1/'
+Write the introductory message for the patch series.
+
+
+Displaying [PATCH 0 of 2] test ...
+Displaying [PATCH 1 of 2] a ...
+Displaying [PATCH 2 of 2] b ...
+This patch series consists of 2 patches.
 
-hg email -m test.mbox -f quux -t foo -c bar -s test 0:tip
+
+Write the introductory message for the patch series.
+
+
+Writing [PATCH 0 of 2] test ...
+Writing [PATCH 1 of 2] a ...
+Writing [PATCH 2 of 2] b ...