Submitting Patches by Email
Email a Single Patch
When a patch is ready for submission, we can send it on by email with ease. This is basically the same as the patchbomb extension (hg email
), but for patch branches. In this script I don’t actually send the email, so I specify the --test
option:
$ cd patches
hg pemail
$ hg pemail --test --from john@example.com --to jane@example.com patchA
this patch series consists of 1 patches.
_
Cc:
_
displaying [PATCH] a nifty patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH] a nifty patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:20 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
a nifty patch
_
diff --git a/file-from-A b/file-from-A
new file mode 100644
--- /dev/null
+++ b/file-from-A
@@ -0,0 +1,2 @@
+One
+Later
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -1,1 +1,1 @@
-One
+Eins
Email Multiple Patches
When sending multiple patches, we need a subject and body for the introductory message for the series. This adds more clutter to the pemail
command. To highlight the relevant parts of the command in the following samples, I have factored out the mail formatting and addressing options:
$ cat >maildesc <<-eof
This is the patch series description.
eof
$ cat >mailopts <<-eof
--test --from john@example.com --to jane@example.com --subject "Intro" --desc maildesc
eof
Patch Series
To send a patch series, we can specify just the head patches in the patch graph. Then pbranch will email them and all their dependencies in topological order, meaning base patches are sent before dependent patches:
hg pemail—with-deps
$ hg pemail $(cat mailopts) --with-deps patchB
this patch series consists of 2 patches.
_
Cc:
_
displaying [PATCH 0 of 2] "Intro" ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 0 of 2] "Intro"
Message-Id: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:20 +0100
From: john@example.com
To: jane@example.com
_
This is the patch series description.
_
displaying [PATCH 1 of 2] a nifty patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 1 of 2] a nifty patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186081@sapient>
In-Reply-To: <patchbomb.1353186080@sapient>
References: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:21 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
a nifty patch
_
diff --git a/file-from-A b/file-from-A
new file mode 100644
--- /dev/null
+++ b/file-from-A
@@ -0,0 +1,2 @@
+One
+Later
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -1,1 +1,1 @@
-One
+Eins
displaying [PATCH 2 of 2] another patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 2 of 2] another patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186082@sapient>
In-Reply-To: <patchbomb.1353186080@sapient>
References: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:22 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
another patch
_
diff --git a/file-from-B b/file-from-B
new file mode 100644
--- /dev/null
+++ b/file-from-B
@@ -0,0 +1,1 @@
+Two
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -3,1 +3,1 @@
-Two
+Zwei
Specified Patches In Specified Order
Finally, we can send multiple patches in arbitrary order by naming them all explicitly:
$ hg pemail $(cat mailopts) patchA patchB patchC
this patch series consists of 3 patches.
_
Cc:
_
displaying [PATCH 0 of 3] "Intro" ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 0 of 3] "Intro"
Message-Id: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:20 +0100
From: john@example.com
To: jane@example.com
_
This is the patch series description.
_
displaying [PATCH 1 of 3] a nifty patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 1 of 3] a nifty patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186081@sapient>
In-Reply-To: <patchbomb.1353186080@sapient>
References: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:21 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
a nifty patch
_
diff --git a/file-from-A b/file-from-A
new file mode 100644
--- /dev/null
+++ b/file-from-A
@@ -0,0 +1,2 @@
+One
+Later
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -1,1 +1,1 @@
-One
+Eins
displaying [PATCH 2 of 3] another patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 2 of 3] another patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186082@sapient>
In-Reply-To: <patchbomb.1353186080@sapient>
References: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:22 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
another patch
_
diff --git a/file-from-B b/file-from-B
new file mode 100644
--- /dev/null
+++ b/file-from-B
@@ -0,0 +1,1 @@
+Two
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -3,1 +3,1 @@
-Two
+Zwei
displaying [PATCH 3 of 3] yet another patch ...
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 3 of 3] yet another patch
X-Mercurial-Node:
Message-Id: <patchbomb.1353186083@sapient>
In-Reply-To: <patchbomb.1353186080@sapient>
References: <patchbomb.1353186080@sapient>
User-Agent: Mercurial-patchbomb/3e673c988c85
Date: Sat, 17 Nov 2012 22:01:23 +0100
From: john@example.com
To: jane@example.com
_
# HG changeset patch
# User john
# Date 0 0
yet another patch
_
diff --git a/file-from-A b/file-from-A
--- a/file-from-A
+++ b/file-from-A
@@ -2,1 +2,1 @@
-Later
+EvenLater
diff --git a/file-from-C b/file-from-C
new file mode 100644
--- /dev/null
+++ b/file-from-C
@@ -0,0 +1,1 @@
+Three
diff --git a/main-file-1 b/main-file-1
--- a/main-file-1
+++ b/main-file-1
@@ -5,1 +5,1 @@
-Three
+Drei