Don't allow to unrecord past the branch point
[vng.git] / commits / Commit.h
blobb42e918a594eca2ca46a8d0e39ee338bfbd14cb7
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef COMMIT_H
19 #define COMMIT_H
21 #include "../Vng.h"
23 #include <QString>
24 #include <QDateTime>
26 class Commit {
27 public:
28 /// default constructor creates an invalid commit object.
29 Commit();
30 Commit(const QString &treeism, const Commit &nextCommit = Commit());
31 Commit(const Commit &other);
32 ~Commit();
34 /// return an older commit
35 QList<Commit> previous();
36 /// return a commit made at a later time that has this one as its parent.
37 Commit next();
39 int previousCommitsCount() const;
41 QString author() const;
42 QString committer() const;
43 QString logMessage() const;
44 QString tree() const;
45 QString commitTreeIsm() const;
47 QDateTime commitTime() const;
49 /// Clear references to the previousCommits, if this commit is the last user of the parent commits it will clean up some memory.
50 void clearParents();
52 Commit &operator=(const Commit &other);
53 bool operator==(const Commit &other);
55 Vng::Acceptance acceptance() const;
56 void setAcceptance(Vng::Acceptance accepted);
58 bool isValid() const;
60 /**
61 * Return the first commit on this branch.
62 * If this is head commit on a branch (not master), this will search for
63 * the first commit that both this branch and another branch share.
65 Commit firstCommitInBranch();
67 private:
68 class Private;
69 Private * d;
72 #endif