X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/97310762059f05961ddac8d6a2e7be1ceeb6f349..cd25e03d30c7b3a3a0babf039446d626dbb5607b:/stgit/commands/patches.py diff --git a/stgit/commands/patches.py b/stgit/commands/patches.py new file mode 100644 index 0000000..c0f2ba8 --- /dev/null +++ b/stgit/commands/patches.py @@ -0,0 +1,69 @@ +__copyright__ = """ +Copyright (C) 2005, Catalin Marinas + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import sys, os +from optparse import OptionParser, make_option + +from stgit.commands.common import * +from stgit.utils import * +from stgit import stack, git + + +help = 'show the patches modifying a file' +usage = """%prog [options] [...] + +Show the applied patches modifying the given files. The '--diff' +option also lists the patch log and the diff for the given files.""" + +options = [make_option('-d', '--diff', + help = 'show the diff for the given files', + action = 'store_true')] + + +def func(parser, options, args): + """Show the patches modifying a file + """ + if len(args) < 1: + parser.error('incorrect number of arguments') + + applied = crt_series.get_applied() + if not applied: + raise CmdException, 'No patches applied' + + revs = git.modifying_revs(args, git_id('base')) + revs.reverse() + + # build the patch/revision mapping + rev_patch = dict() + for name in applied: + patch = crt_series.get_patch(name) + rev_patch[patch.get_top()] = patch + + # print the patch names + for rev in revs: + if rev in rev_patch: + patch = rev_patch[rev] + if options.diff: + print '-------------------------------------------------------------------------------' + print patch.get_name() + print '-------------------------------------------------------------------------------' + print patch.get_description(), + print '---' + print + print git.diff(args, patch.get_bottom(), patch.get_top()) + else: + print patch.get_name()