Mercurial > hg
changeset 3291:0b5d626b354e
[patchbomb] prepend leading zeros in the "[PATCH N of M]" string
Without this patch, if one tries to send a patch bomb with more than 9
patches, the resulting subjects are not easily alphabetically sortable.
For example:
...
[PATCH 9 of 10]
[PATCH 10 of 10]
This patch prepends as many leading zeros as necessary. E.g.,
[PATCH 09 of 10]
or
[PATCH 009 of 100]
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 07 Oct 2006 15:16:47 -0400 |
parents | ae8583e746f1 |
children | 764688cf51e5 399c04369a1b a225055b3b59 |
files | hgext/patchbomb.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/patchbomb.py Sun Oct 08 10:56:21 2006 +0200 +++ b/hgext/patchbomb.py Sat Oct 07 15:16:47 2006 -0400 @@ -158,7 +158,8 @@ if total == 1: subj = '[PATCH] ' + desc[0].strip() else: - subj = '[PATCH %d of %d] %s' % (idx, total, desc[0].strip()) + tlen = len(str(total)) + subj = '[PATCH %0*d of %d] %s' % (tlen, idx, total, desc[0].strip()) if subj.endswith('.'): subj = subj[:-1] msg['Subject'] = subj msg['X-Mercurial-Node'] = node @@ -217,10 +218,14 @@ if len(patches) > 1: ui.write(_('\nWrite the introductory message for the patch series.\n\n')) - subj = '[PATCH 0 of %d] %s' % ( + tlen = len(str(len(patches))) + + subj = '[PATCH %0*d of %d] %s' % ( + tlen, 0, len(patches), opts['subject'] or - prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches))) + prompt('Subject:', rest = ' [PATCH %0*d of %d] ' % (tlen, 0, + len(patches)))) ui.write(_('Finish with ^D or a dot on a line by itself.\n\n'))