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/>.
32 * This class represents a single file in ChangeSet.
37 File(const File
&other
);
40 /// return if the file is (still) present on the filesystem.
43 void setFileName(const QByteArray
&filename
);
44 void setOldFileName(const QByteArray
&filename
);
45 QByteArray
fileName() const;
46 QByteArray
oldFileName() const;
48 void addHunk(const Hunk
&hunk
);
49 QList
<Hunk
> hunks() const;
51 void setProtection(const QString
&string
);
52 void setOldProtection(const QString
&string
);
53 QString
protection() const;
54 QString
oldProtection() const;
55 QFile::Permissions
permissions() const;
57 void setOldSha1(const QString
&string
);
58 void setSha1(const QString
&string
);
59 QString
oldSha1() const;
64 /// return the accumulated number of added lines in all the hunks
65 int linesAdded() const;
66 /// return the accumulated number of removed lines in all the hunks
67 int linesRemoved() const;
69 /// return true if this file has registered any changes.
70 bool hasChanged() const;
71 void setRenameAcceptance(Vng::Acceptance accepted
);
72 void setProtectionAcceptance(Vng::Acceptance accepted
);
73 Vng::Acceptance
renameAcceptance() const;
74 Vng::Acceptance
protectionAcceptance() const;
76 void setBinary(bool binary
);
77 bool isBinary() const;
79 void outputWhatsChanged(QTextStream
&out
, Configuration
&config
, bool printSummary
, bool unified
);
81 /// use the sha1s set to fetch the hunks.
82 void fetchHunks(bool againstHead
);
83 /// remove the diff(s) stored in memory for this file, diff related method calls will no longer work after this.
84 void cleanHunksData();
86 File
&operator=(const File
&other
);
87 bool operator==(const File
&other
) const;
88 bool operator!=(const File
&other
) const;
91 * Calling this will check with the repo database if the path is registered in the repo.
92 * @returns true if the current repo and current HEAD know this commit, false otherwise.
94 static bool fileKnownToGit(const QFileInfo
&path
);
95 /// overloaded method provided for your convenience.
96 static bool fileKnownToGit(const QString
&path
);