summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0bc1343)
With the '--annotate' option, the patch log entry generated by refresh
can contain an additional message. The patch also removes the '-a'
shortcut for '--author' and adds it to '--annotate' (the latter would
be used more often).
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('-f', '--full',
+ help = 'show the full commit ids',
+ action = 'store_true'),
make_option('-g', '--graphical',
help = 'run gitk instead of printing',
action = 'store_true')]
make_option('-g', '--graphical',
help = 'run gitk instead of printing',
action = 'store_true')]
-def show_log(log, show_patch):
+def show_log(log, options):
"""List the patch changelog
"""
commit = git.get_commit(log)
diff_str = ''
while commit:
"""List the patch changelog
"""
commit = git.get_commit(log)
diff_str = ''
while commit:
- descr = commit.get_log().rstrip()
+ log = commit.get_log().split('\n')
+
+ cmd_rev = log[0].split()
+ if len(cmd_rev) >= 2:
+ cmd = cmd_rev[0]
+ rev = cmd_rev[1]
+ elif len(cmd_rev) == 1:
+ cmd = cmd_rev[0]
+ rev = ''
+ else:
+ cmd = rev = ''
- if show_patch:
- if descr.startswith('refresh') or descr.startswith('undo') \
- or descr.startswith('sync'):
+ if options.patch:
+ if cmd in ['refresh', 'undo', 'sync']:
diff_str = '%s%s\n' % (diff_str,
git.pretty_commit(commit.get_id_hash()))
else:
diff_str = '%s%s\n' % (diff_str,
git.pretty_commit(commit.get_id_hash()))
else:
+ if len(log) >= 3:
+ notes = log[2]
+ else:
+ notes = ''
author_name, author_email, author_date = \
name_email_date(commit.get_author())
secs, tz = author_date.split()
date = '%s %s' % (time.ctime(int(secs)), tz)
author_name, author_email, author_date = \
name_email_date(commit.get_author())
secs, tz = author_date.split()
date = '%s %s' % (time.ctime(int(secs)), tz)
- out.stdout('%s %s' % (descr, date))
+ if options.full:
+ out.stdout('%-7s %-40s %s' % (cmd[:7], rev[:40], date))
+ else:
+ out.stdout('%-8s [%-7s] %-28s %s' % \
+ (rev[:8], cmd[:7], notes[:28], date))
parent = commit.get_parent()
if parent:
parent = commit.get_parent()
if parent:
- if show_patch and diff_str:
+ if options.patch and diff_str:
pager(diff_str.rstrip())
def func(parser, options, args):
pager(diff_str.rstrip())
def func(parser, options, args):
if os.system('gitk %s' % log) != 0:
raise CmdException, 'gitk execution failed'
else:
if os.system('gitk %s' % log) != 0:
raise CmdException, 'gitk execution failed'
else:
- show_log(log, options.patch)
make_option('-m', '--message',
help = 'use MESSAGE as the patch ' \
'description'),
make_option('-m', '--message',
help = 'use MESSAGE as the patch ' \
'description'),
- make_option('-a', '--author', metavar = '"NAME <EMAIL>"',
+ make_option('-a', '--annotate', metavar = 'NOTE',
+ help = 'annotate the patch log entry'),
+ make_option('--author', metavar = '"NAME <EMAIL>"',
help = 'use "NAME <EMAIL>" as the author details'),
make_option('--authname',
help = 'use AUTHNAME as the author name'),
help = 'use "NAME <EMAIL>" as the author details'),
make_option('--authname',
help = 'use AUTHNAME as the author name'),
or options.edit or options.message \
or options.authname or options.authemail or options.authdate \
or options.commname or options.commemail \
or options.edit or options.message \
or options.authname or options.authemail or options.authdate \
or options.commname or options.commemail \
- or options.sign or options.ack:
+ or options.sign or options.ack or options.annotate:
if options.patch:
applied = crt_series.get_applied()
if options.patch:
applied = crt_series.get_applied()
author_date = options.authdate,
committer_name = options.commname,
committer_email = options.commemail,
author_date = options.authdate,
committer_name = options.commname,
committer_email = options.commemail,
- backup = True, sign_str = sign_str)
+ backup = True, sign_str = sign_str,
+ notes = options.annotate)
if crt_series.empty_patch(patch):
out.done('empty patch')
if crt_series.empty_patch(patch):
out.done('empty patch')
author_name = None, author_email = None,
author_date = None,
committer_name = None, committer_email = None,
author_name = None, author_email = None,
author_date = None,
committer_name = None, committer_email = None,
- backup = False, sign_str = None, log = 'refresh'):
+ backup = False, sign_str = None, log = 'refresh',
+ notes = None):
"""Generates a new commit for the given patch
"""
name = self.get_current()
"""Generates a new commit for the given patch
"""
name = self.get_current()
patch.set_commemail(committer_email)
if log:
patch.set_commemail(committer_email)
if log:
- self.log_patch(patch, log)
+ self.log_patch(patch, log, notes)
else:
raise StackException, 'Unknown patch "%s"' % oldname
else:
raise StackException, 'Unknown patch "%s"' % oldname
- def log_patch(self, patch, message):
+ def log_patch(self, patch, message, notes = None):
"""Generate a log commit for a patch
"""
top = git.get_commit(patch.get_top())
msg = '%s\t%s' % (message, top.get_id_hash())
"""Generate a log commit for a patch
"""
top = git.get_commit(patch.get_top())
msg = '%s\t%s' % (message, top.get_id_hash())
+ if notes:
+ msg += '\n\n' + notes
old_log = patch.get_log()
if old_log:
old_log = patch.get_log()
if old_log:
stg new foo -m "Foo Patch" &&
echo foo > test && echo foo2 >> test &&
stg add test &&
stg new foo -m "Foo Patch" &&
echo foo > test && echo foo2 >> test &&
stg add test &&
+ stg refresh --annotate="foo notes"
test_expect_success \
'Check the "new" and "refresh" logs' \
'
test_expect_success \
'Check the "new" and "refresh" logs' \
'
- stg log foo | grep -q -e "^new" &&
- stg log foo | grep -q -e "^refresh" &&
- stg log | grep -q -e "^new" &&
- stg log | grep -q -e "^refresh"
+ stg log --full foo | grep -q -e "^new" &&
+ stg log --full foo | grep -q -e "^refresh" &&
+ stg log --full | grep -q -e "^new" &&
+ stg log --full | grep -q -e "^refresh"
+ '
+
+test_expect_success \
+ 'Check the log annotation' \
+ '
+ stg log foo | grep -q -e "\[refresh\] foo notes "
+ stg log bar | grep -q -e "\[refresh\] "
stg pop &&
echo foo > test2 && stg add test2 && stg refresh &&
stg push &&
stg pop &&
echo foo > test2 && stg add test2 && stg refresh &&
stg push &&
- stg log | grep -q -e "^push "
+ stg log --full | grep -q -e "^push "
stg pop &&
stg refresh -m "Foo2 Patch" &&
stg push &&
stg pop &&
stg refresh -m "Foo2 Patch" &&
stg push &&
- stg log | grep -q -e "^push(f) "
+ stg log --full | grep -q -e "^push(f) "
stg pop &&
echo foo2 > test && stg refresh &&
stg push &&
stg pop &&
echo foo2 > test && stg refresh &&
stg push &&
- stg log | grep -q -e "^push(m) "
+ stg log --full | grep -q -e "^push(m) "
stg pop &&
echo foo > test && stg refresh &&
! stg push &&
stg pop &&
echo foo > test && stg refresh &&
! stg push &&
- stg log | grep -q -e "^push(c) "
+ stg log --full | grep -q -e "^push(c) "
'
test_expect_success \
'Check the push "undo" log' \
'
stg push --undo &&
'
test_expect_success \
'Check the push "undo" log' \
'
stg push --undo &&
- stg log bar | grep -q -e "^undo "
+ stg log --full bar | grep -q -e "^undo "
'
test_expect_success \
'Check the refresh "undo" log' \
'
stg refresh --undo &&
'
test_expect_success \
'Check the refresh "undo" log' \
'
stg refresh --undo &&
- stg log | grep -q -e "^undo "
+ stg log --full | grep -q -e "^undo "