From 1e3680e90e63b958dbb8583f4b40fb72adfc0bba Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Sat, 18 Oct 2008 11:12:38 +0200 Subject: [PATCH] First empy method call for AmendRecord --- src/VngCommandLine.cpp | 6 +++ src/commands/AmendRecord.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++ src/commands/AmendRecord.h | 35 ++++++++++++++++ src/src.pro | 2 + 4 files changed, 140 insertions(+) create mode 100644 src/commands/AmendRecord.cpp create mode 100644 src/commands/AmendRecord.h diff --git a/src/VngCommandLine.cpp b/src/VngCommandLine.cpp index 0b84779..7046758 100644 --- a/src/VngCommandLine.cpp +++ b/src/VngCommandLine.cpp @@ -22,6 +22,7 @@ // commands #include "commands/Add.h" +#include "commands/AmendRecord.h" #include "commands/Branches.h" #include "commands/Changes.h" #include "commands/Dist.h" @@ -91,6 +92,7 @@ int VngCommandLine::run() out << "--extended--help" << endl; if (QDir(config.repository().absolutePath() + "/.git").exists()) { out << "add" << endl; + out << "amend-record" << endl; out << "branches" << endl; out << "changes" << endl; out << "dist" << endl; @@ -113,6 +115,7 @@ int VngCommandLine::run() QStringList commands; // keep this list sorted in the sourcecode. In vim just select the lines and do a :'<,'>!sort commands << "add"; + commands << "amend-record"; commands << "branches"; commands << "changes"; commands << "dist"; @@ -165,6 +168,8 @@ int VngCommandLine::run() ac = new WhatsNew(); else if (m_command == "add") ac = new Add(); + else if (m_command == "amend-record") + ac = new AmendRecord(); else if (m_command == "branches") ac = new Branches(); else if (m_command == "changes" || m_command == "log") @@ -213,6 +218,7 @@ void VngCommandLine::printHelp() out << "Copying changes between the working copy and the repository:" << endl; out << " record Save changes in the working copy to the repository as a patch." << endl; out << " unrecord Remove recorded patches without changing the working copy." << endl; + out << " amend-record Replace a patch with a better version before it leaves your repository." << endl; out << "Copying patches between repositories with working copy update:" << endl; out << " push Copy and apply patches from this repository to another one." << endl; out << "Querying the repository:" << endl; diff --git a/src/commands/AmendRecord.cpp b/src/commands/AmendRecord.cpp new file mode 100644 index 0000000..453ba5f --- /dev/null +++ b/src/commands/AmendRecord.cpp @@ -0,0 +1,97 @@ +/* + * This file is part of the vng project + * Copyright (C) 2008 Thomas Zander + * Copyright (C) 2002-2004 David Roundy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see . + */ + +#include "AmendRecord.h" +#include "../CommandLineParser.h" + +static const CommandLineOption options[] = { + {"-a, --all", "answer yes to all patches"}, + {"-i, --interactive", "prompt user interactively"}, + {"-m, --patch-name PATCHNAME", "name of patch"}, + {"-A, --author EMAIL", "specify author id"}, + //{"--logfile FILE", "give patch name and comment in file"}, + //{"--delete-logfile", "delete the logfile when done"}, + //{"--no-test", "don't run the test script"}, + //{"--test", "run the test script"}, + //{"-l, --look-for-adds", "Also look for files that are potentially pending addition"}, + //{"--dont-look-for-adds", "Don't look for any files that could be added"}, + //{"--posthook COMMAND", "specify command to run after this vng command."}, + //{"--no-posthook", "Do not run posthook command."}, + //{"--prompt-posthook", "Prompt before running posthook. [DEFAULT]"}, + //{"--run-posthook", "Run posthook command without prompting."}, + CommandLineLastOption +}; + +AmendRecord::AmendRecord() + : AbstractCommand("Amend-Record") +{ + CommandLineParser::addOptionDefinitions(options); +} + +AbstractCommand::ReturnCodes AmendRecord::run() +{ + if (! checkInRepository()) + return NotInRepo; + moveToRoot(); + +/* + get which commit to amend "c1" using the cursor + + if c1 is the last made commit + unrecord commit + do a normal record, passing in the old content + done + + do a normal record, passing in a dummy comment. + get the sha1 of that commit, call it "tmp1" + + if there index is not clean or files have been added/removed + do a second record, passing in dummy content + get the sha1 of that commit, call it "tmp2" + + git checkout -b tmp_branch c1 + git chery-pick tmp1 + git reset HEAD^^ + + # do a "git commit -a -c c1" with low level commands ;) + git add all files + do a record with the comment from c1 + + # git rebase --onto tmp_branch c1 master + do cherry picks of all the commits following c1 till our previous HEAD + +*/ + + return Ok; +} + +QString AmendRecord::argumentDescription() const +{ + return ""; +} + +QString AmendRecord::commandDescription() const +{ + return "Amend-record is used to replace a patch with a newer version with additional\n" + "changes.\n" + "\n" + "WARNINGS: You should ONLY use amend-record on patches which only exist in a\n" + "single repository!\n"; + +} diff --git a/src/commands/AmendRecord.h b/src/commands/AmendRecord.h new file mode 100644 index 0000000..8c7d814 --- /dev/null +++ b/src/commands/AmendRecord.h @@ -0,0 +1,35 @@ +/* + * This file is part of the vng project + * Copyright (C) 2008 Thomas Zander + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see . + */ + +#ifndef AMENDRECORD_H +#define AMENDRECORD_H + +#include "AbstractCommand.h" + +class AmendRecord : public AbstractCommand +{ +public: + AmendRecord(); + +protected: + virtual QString argumentDescription() const; + virtual ReturnCodes run(); + virtual QString commandDescription() const; +}; + +#endif diff --git a/src/src.pro b/src/src.pro index d678a5e..60c70dc 100644 --- a/src/src.pro +++ b/src/src.pro @@ -19,6 +19,7 @@ SOURCES += \ Configuration.cpp \ VngCommandLine.cpp \ commands/Add.cpp \ + commands/AmendRecord.cpp \ commands/Branches.cpp \ commands/Changes.cpp \ commands/Dist.cpp \ @@ -54,6 +55,7 @@ HEADERS += \ Configuration.h \ VngCommandLine.h \ commands/Add.h \ + commands/AmendRecord.h \ commands/Branches.h \ commands/Changes.h \ commands/Dist.h \ -- 2.11.4.GIT