@@ -128,6 +128,10 @@ The following flags are common to both commands:
b4 am -P _ <msgid>
+ This picks just the last patch from a series::
+
+ b4 am -P -1 <msgid>
+
This picks all patches where the subject matches "iscsi"::
b4 am -P *iscsi*
@@ -92,8 +92,10 @@ Optional flags
``-t THANKFOR, --thank-for THANKFOR``
From the listing generated by ``--list``, specify which thank-you
notes should be sent. This command accepts comma-separated values and
- ranges, including open-ended ranges, e.g.: ``-t 1,3,5-7,9-``. It also
- accepts ``all``.
+ ranges, including open-ended ranges, e.g.: ``-t 1,3,5-7,9-``. When using
+ a sing number, it's possible to use negative values to refer to the
+ latest patch series, e.g.: ``-t -1`` refers to the last patch series.
+ It also accepts ``all``.
``-d DISCARD, --discard DISCARD``
From the listing generated by ``--list``, specify which thank-you
@@ -3545,9 +3545,15 @@ def parse_int_range(intrange: str, upper: int) -> Iterator[int]:
# Remove all whitespace
intrange = re.sub(r'\s', '', intrange)
for n in intrange.split(','):
- if n.isdigit():
- yield int(n)
- elif n.find('<') == 0 and len(n) > 1 and n[1:].isdigit():
+ # Allow single numbers to be negative
+ try:
+ i = int(n)
+ if i < 0 and abs(i) <= upper:
+ yield upper + i + 1
+ except ValueError:
+ pass
+
+ if n.find('<') == 0 and len(n) > 1 and n[1:].isdigit():
yield from range(1, int(n[1:]))
elif n.find('-') > 0:
nr = n.split('-')
This is useful when applying patches and sending a thank you note following that, which can now be done with `b4 ty -t -1`. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- docs/maintainer/am-shazam.rst | 4 ++++ docs/maintainer/ty.rst | 6 ++++-- src/b4/__init__.py | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-)