##// END OF EJS Templates
patchbomb: add --flag to put flags in subject prefixes...
Nicolas Dumazet -
r9346:bb3f8f69 default
parent child Browse files
Show More
@@ -162,12 +162,16 b' def makepatch(ui, repo, patch, opts, _ch'
162 body += '\n'.join(patch)
162 body += '\n'.join(patch)
163 msg = mail.mimetextpatch(body, display=opts.get('test'))
163 msg = mail.mimetextpatch(body, display=opts.get('test'))
164
164
165 flag = ' '.join(opts.get('flag'))
166 if flag:
167 flag = ' ' + flag
168
165 subj = desc[0].strip().rstrip('. ')
169 subj = desc[0].strip().rstrip('. ')
166 if total == 1 and not opts.get('intro'):
170 if total == 1 and not opts.get('intro'):
167 subj = '[PATCH] ' + (opts.get('subject') or subj)
171 subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
168 else:
172 else:
169 tlen = len(str(total))
173 tlen = len(str(total))
170 subj = '[PATCH %0*d of %d] %s' % (tlen, idx, total, subj)
174 subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
171 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
175 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
172 msg['X-Mercurial-Node'] = node
176 msg['X-Mercurial-Node'] = node
173 return msg, subj
177 return msg, subj
@@ -322,11 +326,13 b' def patchbomb(ui, repo, *revs, **opts):'
322 if len(patches) > 1 or opts.get('intro'):
326 if len(patches) > 1 or opts.get('intro'):
323 tlen = len(str(len(patches)))
327 tlen = len(str(len(patches)))
324
328
325 subj = '[PATCH %0*d of %d] %s' % (
329 flag = ' '.join(opts.get('flag'))
326 tlen, 0, len(patches),
330 if flag:
327 opts.get('subject') or
331 subj = '[PATCH %0*d of %d %s] ' % (tlen, 0, len(patches), flag)
328 prompt(ui, 'Subject:',
332 else:
329 rest=' [PATCH %0*d of %d] ' % (tlen, 0, len(patches))))
333 subj = '[PATCH %0*d of %d] ' % (tlen, 0, len(patches))
334 subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj,
335 default='None')
330
336
331 body = ''
337 body = ''
332 if opts.get('diffstat'):
338 if opts.get('diffstat'):
@@ -477,6 +483,7 b' emailopts = ['
477 _('subject of first message (intro or single patch)')),
483 _('subject of first message (intro or single patch)')),
478 ('', 'in-reply-to', '',
484 ('', 'in-reply-to', '',
479 _('message identifier to reply to')),
485 _('message identifier to reply to')),
486 ('', 'flag', [], _('flags to add in subject prefixes')),
480 ('t', 'to', [], _('email addresses of recipients')),
487 ('t', 'to', [], _('email addresses of recipients')),
481 ]
488 ]
482
489
@@ -151,3 +151,19 b" hg email --date '1970-1-1 0:1' -n -f quu"
151
151
152 hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar --in-reply-to baz \
152 hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar --in-reply-to baz \
153 -r 0:1 | fixheaders
153 -r 0:1 | fixheaders
154
155 echo "% test single flag for single patch"
156 hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \
157 -r 2 | fixheaders
158
159 echo "% test single flag for multiple patches"
160 hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \
161 -r 0:1 | fixheaders
162
163 echo "% test mutiple flags for single patch"
164 hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \
165 -c bar -s test -r 2 | fixheaders
166
167 echo "% test multiple flags for multiple patches"
168 hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \
169 -c bar -s test -r 0:1 | fixheaders
@@ -1254,3 +1254,215 b' diff -r 8580ff50825a -r 97d72e5f12c7 b'
1254 @@ -0,0 +1,1 @@
1254 @@ -0,0 +1,1 @@
1255 +b
1255 +b
1256
1256
1257 % test single flag for single patch
1258 This patch series consists of 1 patches.
1259
1260
1261 Displaying [PATCH fooFlag] test ...
1262 Content-Type: text/plain; charset="us-ascii"
1263 MIME-Version: 1.0
1264 Content-Transfer-Encoding: 7bit
1265 Subject: [PATCH fooFlag] test
1266 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
1267 Message-Id: <ff2c9fa2018b15fa74b3.60@
1268 User-Agent: Mercurial-patchbomb
1269 Date: Thu, 01 Jan 1970 00:01:00 +0000
1270 From: quux
1271 To: foo
1272 Cc: bar
1273
1274 # HG changeset patch
1275 # User test
1276 # Date 3 0
1277 # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
1278 # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1279 c
1280
1281 diff -r 97d72e5f12c7 -r ff2c9fa2018b c
1282 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1283 +++ b/c Thu Jan 01 00:00:03 1970 +0000
1284 @@ -0,0 +1,1 @@
1285 +c
1286
1287 % test single flag for multiple patches
1288 This patch series consists of 2 patches.
1289
1290
1291 Write the introductory message for the patch series.
1292
1293
1294 Displaying [PATCH 0 of 2 fooFlag] test ...
1295 Content-Type: text/plain; charset="us-ascii"
1296 MIME-Version: 1.0
1297 Content-Transfer-Encoding: 7bit
1298 Subject: [PATCH 0 of 2 fooFlag] test
1299 Message-Id: <patchbomb.60@
1300 User-Agent: Mercurial-patchbomb
1301 Date: Thu, 01 Jan 1970 00:01:00 +0000
1302 From: quux
1303 To: foo
1304 Cc: bar
1305
1306
1307 Displaying [PATCH 1 of 2 fooFlag] a ...
1308 Content-Type: text/plain; charset="us-ascii"
1309 MIME-Version: 1.0
1310 Content-Transfer-Encoding: 7bit
1311 Subject: [PATCH 1 of 2 fooFlag] a
1312 X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
1313 Message-Id: <8580ff50825a50c8f716.61@
1314 In-Reply-To: <patchbomb.60@
1315 References: <patchbomb.60@
1316 User-Agent: Mercurial-patchbomb
1317 Date: Thu, 01 Jan 1970 00:01:01 +0000
1318 From: quux
1319 To: foo
1320 Cc: bar
1321
1322 # HG changeset patch
1323 # User test
1324 # Date 1 0
1325 # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
1326 # Parent 0000000000000000000000000000000000000000
1327 a
1328
1329 diff -r 000000000000 -r 8580ff50825a a
1330 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1331 +++ b/a Thu Jan 01 00:00:01 1970 +0000
1332 @@ -0,0 +1,1 @@
1333 +a
1334
1335 Displaying [PATCH 2 of 2 fooFlag] b ...
1336 Content-Type: text/plain; charset="us-ascii"
1337 MIME-Version: 1.0
1338 Content-Transfer-Encoding: 7bit
1339 Subject: [PATCH 2 of 2 fooFlag] b
1340 X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1341 Message-Id: <97d72e5f12c7e84f8506.62@
1342 In-Reply-To: <patchbomb.60@
1343 References: <patchbomb.60@
1344 User-Agent: Mercurial-patchbomb
1345 Date: Thu, 01 Jan 1970 00:01:02 +0000
1346 From: quux
1347 To: foo
1348 Cc: bar
1349
1350 # HG changeset patch
1351 # User test
1352 # Date 2 0
1353 # Node ID 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1354 # Parent 8580ff50825a50c8f716709acdf8de0deddcd6ab
1355 b
1356
1357 diff -r 8580ff50825a -r 97d72e5f12c7 b
1358 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1359 +++ b/b Thu Jan 01 00:00:02 1970 +0000
1360 @@ -0,0 +1,1 @@
1361 +b
1362
1363 % test mutiple flags for single patch
1364 This patch series consists of 1 patches.
1365
1366
1367 Displaying [PATCH fooFlag barFlag] test ...
1368 Content-Type: text/plain; charset="us-ascii"
1369 MIME-Version: 1.0
1370 Content-Transfer-Encoding: 7bit
1371 Subject: [PATCH fooFlag barFlag] test
1372 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
1373 Message-Id: <ff2c9fa2018b15fa74b3.60@
1374 User-Agent: Mercurial-patchbomb
1375 Date: Thu, 01 Jan 1970 00:01:00 +0000
1376 From: quux
1377 To: foo
1378 Cc: bar
1379
1380 # HG changeset patch
1381 # User test
1382 # Date 3 0
1383 # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
1384 # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1385 c
1386
1387 diff -r 97d72e5f12c7 -r ff2c9fa2018b c
1388 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1389 +++ b/c Thu Jan 01 00:00:03 1970 +0000
1390 @@ -0,0 +1,1 @@
1391 +c
1392
1393 % test multiple flags for multiple patches
1394 This patch series consists of 2 patches.
1395
1396
1397 Write the introductory message for the patch series.
1398
1399
1400 Displaying [PATCH 0 of 2 fooFlag barFlag] test ...
1401 Content-Type: text/plain; charset="us-ascii"
1402 MIME-Version: 1.0
1403 Content-Transfer-Encoding: 7bit
1404 Subject: [PATCH 0 of 2 fooFlag barFlag] test
1405 Message-Id: <patchbomb.60@
1406 User-Agent: Mercurial-patchbomb
1407 Date: Thu, 01 Jan 1970 00:01:00 +0000
1408 From: quux
1409 To: foo
1410 Cc: bar
1411
1412
1413 Displaying [PATCH 1 of 2 fooFlag barFlag] a ...
1414 Content-Type: text/plain; charset="us-ascii"
1415 MIME-Version: 1.0
1416 Content-Transfer-Encoding: 7bit
1417 Subject: [PATCH 1 of 2 fooFlag barFlag] a
1418 X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
1419 Message-Id: <8580ff50825a50c8f716.61@
1420 In-Reply-To: <patchbomb.60@
1421 References: <patchbomb.60@
1422 User-Agent: Mercurial-patchbomb
1423 Date: Thu, 01 Jan 1970 00:01:01 +0000
1424 From: quux
1425 To: foo
1426 Cc: bar
1427
1428 # HG changeset patch
1429 # User test
1430 # Date 1 0
1431 # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
1432 # Parent 0000000000000000000000000000000000000000
1433 a
1434
1435 diff -r 000000000000 -r 8580ff50825a a
1436 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1437 +++ b/a Thu Jan 01 00:00:01 1970 +0000
1438 @@ -0,0 +1,1 @@
1439 +a
1440
1441 Displaying [PATCH 2 of 2 fooFlag barFlag] b ...
1442 Content-Type: text/plain; charset="us-ascii"
1443 MIME-Version: 1.0
1444 Content-Transfer-Encoding: 7bit
1445 Subject: [PATCH 2 of 2 fooFlag barFlag] b
1446 X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1447 Message-Id: <97d72e5f12c7e84f8506.62@
1448 In-Reply-To: <patchbomb.60@
1449 References: <patchbomb.60@
1450 User-Agent: Mercurial-patchbomb
1451 Date: Thu, 01 Jan 1970 00:01:02 +0000
1452 From: quux
1453 To: foo
1454 Cc: bar
1455
1456 # HG changeset patch
1457 # User test
1458 # Date 2 0
1459 # Node ID 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1460 # Parent 8580ff50825a50c8f716709acdf8de0deddcd6ab
1461 b
1462
1463 diff -r 8580ff50825a -r 97d72e5f12c7 b
1464 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1465 +++ b/b Thu Jan 01 00:00:02 1970 +0000
1466 @@ -0,0 +1,1 @@
1467 +b
1468
General Comments 0
You need to be logged in to leave comments. Login now