2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
4 * Copyright (C) 2002-2004 David Roundy
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "hunks/ChangeSet.h"
22 #include "CommandLineParser.h"
24 #include <QTextStream>
26 static const CommandLineOption options
[] = {
27 {"-s, --summary", "summarize changes"},
28 {"--no-summary", "don't summarize changes"},
29 {"-u, --unified", "output patch in a format similar to diff -u"},
31 //{"--ignore-times", "don't trust the file modification times"},
32 //{"-l, --look-for-adds", "In addition to modifications, look for files that are not boring, and thus are potentially pending addition"},
33 //{"--dont-look-for-adds", "Don't look for any files or directories that could be added, and don't add them automatically"},
34 //{"--boring", "don't skip boring files"},
39 : AbstractCommand("whatsnew")
41 CommandLineParser::addOptionDefinitions(options
);
42 CommandLineParser::setArgumentDefinition("whatsnew [FILE or DIRECTORY]" );
45 AbstractCommand::ReturnCodes
WhatsNew::run()
47 if (! checkInRepository())
51 CommandLineParser
*args
= CommandLineParser::instance();
52 const bool printSummary
= m_config
.contains("summary") && !args
->contains("no-summary") || args
->contains("summary");
53 const bool unified
= m_config
.contains("unified") || args
->contains("unified");
57 changeSet
.fillFromCurrentChanges(rebasedArguments());
59 QTextStream
&out
= Logger::standardOut();
60 if (changeSet
.count() == 0) {
61 out
<< "No Changes!" << endl
;
64 if (!printSummary
&& !unified
) {
65 m_config
.colorize(out
);
68 foreach(File file
, changeSet
.files()) {
69 file
.outputWhatsChanged(out
, m_config
, printSummary
, unified
);
72 if (!printSummary
&& !unified
) {
73 m_config
.colorize(out
);
75 m_config
.normalColor(out
);
78 return AbstractCommand::Ok
;
81 QString
WhatsNew::argumentDescription() const
83 return QString("[FILE or DIRECTORY]");
86 QString
WhatsNew::commandDescription() const
88 return "whatsnew gives you a view of what changes you've made in your working\n"
89 "copy that haven't yet been recorded. The changes are displayed in\n"
90 "vng patch format.\n";