1 from stgit
.argparse
import opt
, patch_range
2 from stgit
.commands
.common
import DirectoryHasRepository
, parse_patches
3 from stgit
.lib
import log
4 from stgit
.run
import Run
7 Copyright (C) 2006, Catalin Marinas <catalin.marinas@gmail.com>
8 Copyright (C) 2008, Karl Hasselström <kha@treskal.com>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License version 2 as
12 published by the Free Software Foundation.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, see http://www.gnu.org/licenses/.
23 help = 'Display or optionally clear the patch changelog'
25 usage
= ['[options] [--] [<patches>]']
27 List the history of the patch stack: the stack log. If one or more
28 patch names are given, limit the list to the log entries that touch
31 "stg undo" and "stg redo" let you step back and forth in the patch
32 stack. "stg reset" lets you go directly to any state.
34 Given the --clear option, the log history will be deleted.
35 This may be useful if the tree view has become too cluttered
38 args
= [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
43 args
=['stg_branches'],
44 short
='Use BRANCH instead of the default one',
50 short
='Show the refresh diffs',
56 short
='Limit the output to NUMBER commits',
62 short
='Show the full commit ids',
68 short
='Run gitk instead of printing',
73 short
='Clear the log history',
77 directory
= DirectoryHasRepository()
80 def show_log(state
, pathlim
, num
, full
, show_diff
):
82 if num
is not None and num
> 0:
83 cmd
.append('-%d' % num
)
87 cmd
.append('--pretty=tformat:%h %aD %s')
88 cmd
.extend([state
.sha1
, '--'])
93 def func(parser
, options
, args
):
95 if options
.diff
or options
.number
or options
.full
or options
.graphical
:
96 parser
.error('cannot combine --clear with other options')
98 parser
.error('cannot combine --clear with patch arguments')
100 if options
.graphical
:
101 for o
in ['diff', 'number', 'full']:
102 if getattr(options
, o
):
103 parser
.error('cannot combine --graphical and --%s' % o
)
105 stack
= directory
.repository
.get_stack(options
.branch
)
111 patches
= parse_patches(args
, list(stack
.patchorder
.all
))
112 state
= log
.get_stack_state(stack
.repository
, stack
.state_ref
)
113 pathlim
= ['patches/%s' % pn
for pn
in patches
]
115 if options
.graphical
:
116 cmd
= ['gitk', state
.simplified
.sha1
, '--'] + pathlim
117 # Discard the exit codes generated by SIGINT, SIGKILL, and SIGTERM.
118 Run(*cmd
).returns([0, -2, -9, -15]).run()
120 show_log(state
.simplified
, pathlim
, options
.number
, options
.full
, options
.diff
)