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.
38 File(const File
&other
);
41 /// return if the file is (still) present on the filesystem.
44 void setFileName(const QByteArray
&filename
);
45 void setOldFileName(const QByteArray
&filename
);
46 QByteArray
fileName() const;
47 QByteArray
oldFileName() const;
49 void addHunk(const Hunk
&hunk
);
50 QList
<Hunk
> hunks() const;
52 void setProtection(const QString
&string
);
53 void setOldProtection(const QString
&string
);
54 QString
protection() const;
55 QString
oldProtection() const;
56 QFile::Permissions
permissions() const;
58 void setOldSha1(const QString
&string
);
59 void setSha1(const QString
&string
);
60 QString
oldSha1() const;
65 /// return the accumulated number of added lines in all the hunks
66 int linesAdded() const;
67 /// return the accumulated number of removed lines in all the hunks
68 int linesRemoved() const;
70 /// return true if this file has registered any changes.
71 bool hasChanged() const;
72 void setRenameAcceptance(Vng::Acceptance accepted
);
73 void setProtectionAcceptance(Vng::Acceptance accepted
);
74 void setBinaryChangeAcceptance(Vng::Acceptance accepted
);
75 Vng::Acceptance
renameAcceptance() const;
76 Vng::Acceptance
protectionAcceptance() const;
77 Vng::Acceptance
binaryChangeAcceptance() const;
79 * This method will iterate over all the hunks and subhunks to return the combined acceptance of the changes for this file.
81 Vng::Acceptance
changesAcceptance();
83 void setBinary(bool binary
);
84 bool isBinary() const;
86 void outputWhatsChanged(QTextStream
&out
, Configuration
&config
, bool printSummary
, bool unified
);
88 /// use the sha1s set to fetch the hunks.
89 void fetchHunks(bool againstHead
);
90 /// remove the diff(s) stored in memory for this file, diff related method calls will no longer work after this.
91 void cleanHunksData();
93 File
&operator=(const File
&other
);
94 bool operator==(const File
&other
) const;
95 bool operator!=(const File
&other
) const;
98 * Calling this will check with the repo database if the path is registered in the repo.
99 * @returns true if the current repo and current HEAD know this commit, false otherwise.
101 static bool fileKnownToGit(const QFileInfo
&path
);
102 /// overloaded method provided for your convenience.
103 static bool fileKnownToGit(const QString
&path
);
106 * In git output non-latin1 characters are encoded like \nnn but in accepting arguments git expects normal output.
107 * So we need to convert sometimes.
109 static QByteArray
escapeGitFilename(const QByteArray
&fileName
);