Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (291986 => 291987)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-03-28 20:29:42 UTC (rev 291986)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-03-28 20:43:02 UTC (rev 291987)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.5.1',
+ version='4.6.0',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (291986 => 291987)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-03-28 20:29:42 UTC (rev 291986)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-03-28 20:43:02 UTC (rev 291987)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 5, 1)
+version = Version(4, 6, 0)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/command.py (291986 => 291987)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/command.py 2022-03-28 20:29:42 UTC (rev 291986)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/command.py 2022-03-28 20:43:02 UTC (rev 291987)
@@ -54,7 +54,7 @@
HASH = 'hash'
REVISION = 'revision'
- GIT_HEADER_RE = re.compile(r'^commit (?P<hash>[a-f0-9A-F]+)')
+ GIT_HEADER_RE = re.compile(r'^(commit )?(?P<hash>[a-f0-9A-F]+)')
SVN_HEADER_RE = re.compile(r'^(?P<revision>r/d+) | ')
REVISION_RES = (re.compile(r'^(?P<revision>\d+)\s'), re.compile(r'(?P<revision>[rR]\d+)'))
@@ -211,9 +211,9 @@
if representation == 'hash':
reference = reference[:Commit.HASH_LABEL_SIZE]
if mode == cls.APPEND_MODE:
- reference = '{} ({})'.format(match.group(1), reference)
+ reference = '{} ({})'.format(match.groups()[-1], reference)
if mode == cls.HEADER_MODE:
- alternates = [] if match.group(1).startswith(reference) else [match.group(1)]
+ alternates = [] if match.groups()[-1].startswith(reference) else [match.groups()[-1]]
for repr in {'revision', 'hash', 'identifier'} - {'hash' if repository.is_git else 'revision', representation}:
if repr in kwargs:
continue
@@ -224,7 +224,7 @@
other = other[:Commit.HASH_LABEL_SIZE]
alternates.append('r{}'.format(other) if isinstance(other, int) else other)
reference = '{} ({})'.format(reference, ', '.join(alternates))
- return match.group(0).replace(match.group(1), reference)
+ return match.group(0).replace(match.groups()[-1], reference)
return match.group(0)
res = {}
@@ -241,23 +241,40 @@
line = log_output.stdout.readline()
while line:
header = header_re.sub(
- lambda match: replace_line(match, mode=cls.HEADER_MODE, **{'hash' if repository.is_git else 'revision': match.group(1)}),
+ lambda match: replace_line(match, mode=cls.HEADER_MODE, **{'hash' if repository.is_git else 'revision': match.groups()[-1]}),
line,
)
if header != line:
+ index = 2 if header.startswith('commit') else 1
+ header = header.split(' ')
with Terminal.Style(color=Terminal.Text.yellow, style=Terminal.Text.bold).apply(sys.stdout):
- sys.stdout.write(' '.join(header.split(' ')[:2]))
+ sys.stdout.write(' '.join(header[:index]))
- sys.stdout.write(' ')
+ if index < len(header):
+ sys.stdout.write(' ')
+ in_red = index
+ while in_red < len(header):
+ if len(header[in_red]) < 2:
+ break
+ if header[in_red][-1] == ',':
+ in_red += 1
+ continue
+ if header[in_red][-1] == ')' or header[in_red][-2] == ')':
+ in_red += 1
+ break
with Terminal.Style(color=Terminal.Text.red).apply(sys.stdout):
- sys.stdout.write(' '.join(header.split(' ')[2:]))
+ sys.stdout.write(' '.join(header[index:in_red]))
+ if in_red < len(header):
+ sys.stdout.write(' ')
+ sys.stdout.write(' '.join(header[in_red:]))
+
line = log_output.stdout.readline()
continue
for repr, regexs in res.items():
line = regexs[0].sub(
- lambda match: replace_line(match, mode=cls.REPLACE_MODE, **{repr: match.group(1)}),
+ lambda match: replace_line(match, mode=cls.REPLACE_MODE, **{repr: match.group()[-1]}),
line,
)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/log.py (291986 => 291987)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/log.py 2022-03-28 20:29:42 UTC (rev 291986)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/log.py 2022-03-28 20:43:02 UTC (rev 291987)
@@ -24,7 +24,7 @@
import sys
-from webkitcorepy import Terminal
+from webkitcorepy import arguments, Terminal
from webkitscmpy import local
from webkitscmpy.program.command import FilteredCommand
@@ -34,9 +34,71 @@
help = "Filter raw output of 'git log' or 'svn log' to replace native commit representation with identifiers"
@classmethod
+ def parser(cls, parser, loggers=None):
+ FilteredCommand.parser(parser, loggers=loggers)
+ parser.add_argument(
+ '--max-count', '-n', type=int,
+ help='Limit the number of commits to output.',
+ dest='max_count',
+ default=None,
+ )
+ parser.add_argument(
+ '--skip', type=int,
+ help='Skip number commits before starting to show the commit output.',
+ dest='skip',
+ default=None,
+ )
+ parser.add_argument(
+ '--pretty', '--format', type=str,
+ help='Pretty-print the contents of the commit logs in a given format, where <format> can be\n'
+ 'one of oneline, short, medium, full, fuller, reference, email, raw, format:<string> and\n'
+ 'tformat:<string>. When <format> is none of the above, and has %%placeholder in it, it\n'
+ 'acts as if --pretty=tformat:<format> were given.\n\n'
+ 'See the "PRETTY FORMATS" section for some additional details for each format. When\n'
+ '=<format> part is omitted, it defaults to medium.\n\n'
+ 'Note: you can specify the default pretty format in the repository configuration (see\n'
+ 'git-config(1)).',
+ dest='pretty',
+ default=None,
+ )
+ parser.add_argument(
+ '--abbrev-commit', '--no-abbrev-commit',
+ help='Instead of showing the full 40-byte hexadecimal commit object name, show a prefix that\n'
+ 'names the object uniquely. "--abbrev=<n>" (which also modifies diff output, if it is\n'
+ 'displayed) option can be used to specify the minimum length of the prefix.',
+ action=""
+ dest='abbrev_commit',
+ default=None,
+ )
+ parser.add_argument(
+ '--oneline',
+ help='This is a shorthand for "--pretty=oneline --abbrev-commit" used together.',
+ action='',
+ dest='oneline',
+ default=None,
+ )
+
+ @classmethod
def main(cls, args, repository, **kwargs):
config = getattr(repository, 'config', lambda: {})()
Terminal.colors = config.get('color.diff', config.get('color.ui', 'auto')) != 'false'
+
+ max_count = getattr(args, 'max_count', None)
+ if max_count:
+ args.args.insert(0, '--max-count={}'.format(max_count))
+ skip = getattr(args, 'skip', None)
+ if skip:
+ args.args.insert(0, '--skip={}'.format(skip))
+ pretty = getattr(args, 'pretty', None)
+ if pretty:
+ args.args.insert(0, '--pretty={}'.format(pretty))
+ abbrev_commit = getattr(args, 'abbrev_commit', None)
+ if abbrev_commit is not None:
+ args.args.insert(0, '--abbrev-commit' if abbrev_commit else '--no-abbrev-commit')
+ _oneline_ = getattr(args, 'oneline', None)
+ if oneline is not None:
+ args.args.insert(0, '--oneline')
+
return cls.pager(args, repository, file=__file__, **kwargs)