Don't allow to unrecord past the branch point
[vng.git] / Initialize.cpp
blobd9f38f150a7563cbb45ee000465674775dbb83c4
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
4 * Copyright (C) 2003-2005 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/>.
19 #include "Initialize.h"
21 #include "Vng.h"
22 #include "GitRunner.h"
23 #include "Logger.h"
25 // #include <QDebug>
27 Initialize::Initialize()
28 :AbstractCommand("initialize")
32 QString Initialize::argumentDescription() const
34 return QString();
37 QString Initialize::commandDescription() const
39 return "Generally you will only call initialize once for each project you work on,\n"
40 "and calling it is just about the first thing you do. Just make sure\n"
41 "you are in the main directory of the project, and initialize will set up all\n"
42 "the directories and files darcs needs in order to start keeping track of\n"
43 "revisions for your project.\n";
46 AbstractCommand::ReturnCodes Initialize::run()
48 QProcess git;
49 QStringList arguments;
50 arguments << "init" << "--quiet";
51 GitRunner runner(git, arguments);
52 runner.start(GitRunner::WaitForStandardError);
54 char buf[1024];
55 qint64 lineSize = Vng::readLine(&git, buf, sizeof(buf));
56 git.waitForFinished();
57 if (git.exitCode() != 0) {
58 Logger::error() << "Failed to initialize the repo. Do you have writing rights in the current directory?\n";
59 Logger::info() << "initialize tries to create a directory '.git` in the current directory\n";
60 if (lineSize > 0)
61 Logger::debug() << "Git said; " << buf;
62 return WriteError;
64 return Ok;