Fix parsing 'last' in Changes to give an error when we don't pass a number
[vng.git] / src / patches / Commit.h
blob3299e1a70b11177fcfff956c90187bca49ef958e
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 CommitPrivate;
27 class ChangeSet;
28 class File;
30 class Commit
32 public:
33 /// default constructor creates an invalid commit object.
34 Commit();
35 Commit(const QString &treeism, const Commit &nextCommit = Commit());
36 Commit(const Commit &other);
37 ~Commit();
39 /// return an older commit
40 QList<Commit> previous();
41 /// return a commit made at a later time that has this one as its parent.
42 Commit next();
44 int previousCommitsCount() const;
46 QString author() const;
47 QString committer() const;
48 QByteArray logMessage() const;
49 /// The tree structure sha1, which is part of the commit.
50 QString tree() const;
51 /// the param passed to the constructor. This can be something like "HEAD"
52 QString commitTreeIsm() const;
54 /// similar to the previos but this will always return a sha1 whereas
55 // the commitTreeIsm can return a ref.
56 QString commitTreeIsmSha1() const;
59 QDateTime commitTime() const;
60 QDateTime authorTime() const;
62 /// available only when the diff provided it.
63 ChangeSet changeSet() const;
65 /// Clear references to the previousCommits, if this commit is the last user of the parent commits it will clean up some memory.
66 void clearParents();
68 Commit &operator=(const Commit &other);
69 bool operator==(const Commit &other);
71 Vng::Acceptance acceptance() const;
72 void setAcceptance(Vng::Acceptance accepted);
74 bool isValid() const;
76 /**
77 * Return the first commit on this branch.
78 * If this is head commit on a branch (not master), this will search for
79 * the first commit that both this branch and another branch share.
81 Commit firstCommitInBranch();
83 static Commit createFromStream(QIODevice *device);
84 /// lists all files in the whole repo at the given commit time.
85 static QList<File> allFiles(const QString &commitTreeIsm = "HEAD");
87 protected:
88 Commit(CommitPrivate *priv);
89 void fillFromTreeIsm(const QString &treeIsm);
90 CommitPrivate * d;
92 private:
93 static Commit createFromStream(QIODevice *device, CommitPrivate *priv);
96 #endif