The patch also changes the construction of the string when --patch is
supplied to avoid resource consumption (using a list and joining at
the end rather than creating a bigger and bigger string).
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
make_option('-p', '--patch',
help = 'show the refresh diffs',
action = 'store_true'),
make_option('-p', '--patch',
help = 'show the refresh diffs',
action = 'store_true'),
+ make_option('-n', '--number', type = 'int',
+ help = 'limit the output to NUMBER commits'),
make_option('-f', '--full',
help = 'show the full commit ids',
action = 'store_true'),
make_option('-f', '--full',
help = 'show the full commit ids',
action = 'store_true'),
"""List the patch changelog
"""
commit = git.get_commit(log)
"""List the patch changelog
"""
commit = git.get_commit(log)
+ if options.number != None:
+ n = options.number
+ else:
+ n = -1
+ diff_list = []
+ if n == 0:
+ # limit the output
+ break
+
log = commit.get_log().split('\n')
cmd_rev = log[0].split()
log = commit.get_log().split('\n')
cmd_rev = log[0].split()
if options.patch:
if cmd in ['refresh', 'undo', 'sync', 'edit']:
if options.patch:
if cmd in ['refresh', 'undo', 'sync', 'edit']:
- diff_str = '%s%s\n' % (diff_str,
- git.pretty_commit(commit.get_id_hash()))
+ diff_list.append(git.pretty_commit(commit.get_id_hash()))
+
+ # limiter decrement
+ n -= 1
else:
if len(log) >= 3:
notes = log[2]
else:
if len(log) >= 3:
notes = log[2]
out.stdout('%-8s [%-7s] %-28s %s' % \
(rev[:8], cmd[:7], notes[:28], date))
out.stdout('%-8s [%-7s] %-28s %s' % \
(rev[:8], cmd[:7], notes[:28], date))
+ # limiter decrement
+ n -= 1
+
parent = commit.get_parent()
if parent:
commit = git.get_commit(parent)
else:
commit = None
parent = commit.get_parent()
if parent:
commit = git.get_commit(parent)
else:
commit = None
- if options.patch and diff_str:
- pager(diff_str.rstrip())
+ if options.patch and diff_list:
+ pager('\n'.join(diff_list).rstrip())
def func(parser, options, args):
"""Show the patch changelog
def func(parser, options, args):
"""Show the patch changelog