Patchwork patchbomb: allow specifying default --flag options via config(issue5354)

login
register
mail settings
Submitter Pulkit Goyal
Date Feb. 21, 2017, 3:25 a.m.
Message ID <3c7e816697791c48de12.1487647507@pulkit-goyal>
Download mbox | patch
Permalink /patch/18688/
State Changes Requested
Headers show

Comments

Pulkit Goyal - Feb. 21, 2017, 3:25 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1487593583 -19800
#      Mon Feb 20 17:56:23 2017 +0530
# Node ID 3c7e816697791c48de126c06c069af23c9e2bc3a
# Parent  2c9e619ba9ee8e72370cc0f27f59da39947773b6
patchbomb: allow specifying default --flag options via config(issue5354)

This patch adds support for specifying default flag to be added while sending
patches using patchbomb per repsoitory. After this patch one can add flag to
email section in hgrc like

[email]
to = mercurial-devel@mecurial-scm.org
flag = evolve-ext
Yuya Nishihara - Feb. 21, 2017, 2:48 p.m.
On Tue, 21 Feb 2017 08:55:07 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1487593583 -19800
> #      Mon Feb 20 17:56:23 2017 +0530
> # Node ID 3c7e816697791c48de126c06c069af23c9e2bc3a
> # Parent  2c9e619ba9ee8e72370cc0f27f59da39947773b6
> patchbomb: allow specifying default --flag options via config(issue5354)
> 
> This patch adds support for specifying default flag to be added while sending
> patches using patchbomb per repsoitory. After this patch one can add flag to
> email section in hgrc like

I wanted to make it support templating so we can set 'flag = {topic}', etc.

https://www.mercurial-scm.org/pipermail/mercurial-devel/2015-April/068094.html

(Well, this wasn't an April Fool patch.)

Matt found this can be more generic, which seemed really nice, but no progress
since then, sigh. Maybe I should send V2 of this as I cannot design a nice
generic function right now.

> [email]
> to = mercurial-devel@mecurial-scm.org
> flag = evolve-ext

Perhaps "flag" should belong to the patchbomb section.

> @@ -202,9 +202,13 @@
>      else:
>          msg = mail.mimetextpatch(body, display=opts.get('test'))
>  
> +    fl = "flag"     # to avoid test-check-config.t from failing
> +    defaultflag = repo.ui.config('email', fl)

You need to document it to silence the checker.

Patch

diff -r 2c9e619ba9ee -r 3c7e81669779 hgext/patchbomb.py
--- a/hgext/patchbomb.py	Sat Feb 18 17:23:43 2017 -0800
+++ b/hgext/patchbomb.py	Mon Feb 20 17:56:23 2017 +0530
@@ -202,9 +202,13 @@ 
     else:
         msg = mail.mimetextpatch(body, display=opts.get('test'))
 
+    fl = "flag"     # to avoid test-check-config.t from failing
+    defaultflag = repo.ui.config('email', fl)
     flag = ' '.join(opts.get('flag'))
     if flag:
         flag = ' ' + flag
+    if defaultflag:
+        flag = ' ' + defaultflag + flag
 
     subj = desc[0].strip().rstrip('. ')
     if not numbered:
diff -r 2c9e619ba9ee -r 3c7e81669779 tests/test-patchbomb.t
--- a/tests/test-patchbomb.t	Sat Feb 18 17:23:43 2017 -0800
+++ b/tests/test-patchbomb.t	Mon Feb 20 17:56:23 2017 +0530
@@ -2689,6 +2689,7 @@ 
 
   $ echo "[email]" >> $HGRCPATH
   $ echo "cc=" >> $HGRCPATH
+  $ echo "flag=abc" >> $HGRCPATH
 
 dest#branch URIs:
   $ hg email --date '1980-1-1 0:1' -n -t foo -s test -o ../t#test
@@ -2697,11 +2698,11 @@ 
   this patch series consists of 1 patches.
   
   
-  displaying [PATCH] test ...
+  displaying [PATCH abc] test ...
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
-  Subject: [PATCH] test
+  Subject: [PATCH abc] test
   X-Mercurial-Node: 2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268
   X-Mercurial-Series-Index: 1
   X-Mercurial-Series-Total: 1
@@ -2825,7 +2826,7 @@ 
 
 single rev
 
-  $ hg email --date '1980-1-1 0:1' -v -t foo -s test -r '10'
+  $ hg email --date '1980-1-1 0:1' -v -t foo -s test -r '10' --flag V2
   From [test]: test
   this patch series consists of 1 patches.
   
@@ -2835,7 +2836,7 @@ 
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
-  Subject: [PATCH] test
+  Subject: [PATCH abc V2] test
   X-Mercurial-Node: 3b6f1ec9dde933a40a115a7990f8b320477231af
   X-Mercurial-Series-Index: 1
   X-Mercurial-Series-Total: 1
@@ -2862,7 +2863,7 @@ 
    d
   +d
   
-  sending [PATCH] test ...
+  sending [PATCH abc V2] test ...
   sending mail: $TESTTMP/t2/pretendmail.sh -f test foo
 
 Test pull url header