Merge remote-tracking branch 'origin/4.2'

Change-Id: Ia98031eb87f1859c3736faa0cdd8b655e8a50689
This commit is contained in:
Orgad Shaneh
2016-11-14 11:15:40 +02:00
175 changed files with 2145 additions and 1563 deletions

View File

@@ -94,6 +94,8 @@ static FileStates stateFor(const QChar &c)
return CopiedFile;
case 'U':
return UnmergedFile;
case 'T':
return TypeChangedFile;
case '?':
return UntrackedFile;
default:
@@ -195,27 +197,29 @@ QString CommitData::stateDisplayName(const FileStates &state)
{
QString resultState;
if (state == UntrackedFile)
return QCoreApplication::translate("Git::Internal::CommitData", "untracked");
return tr("untracked");
if (state & StagedFile)
resultState = QCoreApplication::translate("Git::Internal::CommitData", "staged + ");
resultState = tr("staged + ");
if (state & ModifiedFile)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "modified"));
resultState.append(tr("modified"));
else if (state & AddedFile)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "added"));
resultState.append(tr("added"));
else if (state & DeletedFile)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "deleted"));
resultState.append(tr("deleted"));
else if (state & RenamedFile)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "renamed"));
resultState.append(tr("renamed"));
else if (state & CopiedFile)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "copied"));
resultState.append(tr("copied"));
else if (state & TypeChangedFile)
resultState.append(tr("typechange"));
if (state & UnmergedUs) {
if (state & UnmergedThem)
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by both"));
resultState.append(tr(" by both"));
else
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by us"));
resultState.append(tr(" by us"));
} else if (state & UnmergedThem) {
resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by them"));
resultState.append(tr(" by them"));
}
return resultState;
}

View File

@@ -27,6 +27,7 @@
#include "gitsettings.h" // CommitType
#include <QCoreApplication>
#include <QStringList>
#include <QPair>
@@ -71,6 +72,7 @@ enum FileState {
RenamedFile = 0x10,
CopiedFile = 0x20,
UnmergedFile = 0x40,
TypeChangedFile = 0x80,
UnmergedUs = 0x100,
UnmergedThem = 0x200,
@@ -82,6 +84,8 @@ Q_DECLARE_FLAGS(FileStates, FileState)
class CommitData
{
Q_DECLARE_TR_FUNCTIONS(Git::Internal::CommitData)
public:
CommitData(CommitType type = SimpleCommit);
// A pair of state string/file name ('modified', 'file.cpp').

View File

@@ -2477,7 +2477,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
filesToAdd.append(file);
if ((state & StagedFile) && !checked) {
if (state & (ModifiedFile | AddedFile | DeletedFile)) {
if (state & (ModifiedFile | AddedFile | DeletedFile | TypeChangedFile)) {
filesToReset.append(file);
} else if (state & (RenamedFile | CopiedFile)) {
const QString newFile = file.mid(file.indexOf(renameSeparator) + renameSeparator.count());
@@ -2487,7 +2487,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
QTC_ASSERT(false, continue); // There should not be unmerged files when committing!
}
if (state == ModifiedFile && checked) {
if ((state == ModifiedFile || state == TypeChangedFile) && checked) {
filesToReset.removeAll(file);
filesToAdd.append(file);
} else if (state == AddedFile && checked) {
@@ -2703,7 +2703,8 @@ void GitClient::synchronousAbortCommand(const QString &workingDir, const QString
}
const SynchronousProcessResponse resp = vcsFullySynchronousExec(
workingDir, { abortCommand, "--abort" }, VcsCommand::ExpectRepoChanges);
workingDir, { abortCommand, "--abort" },
VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage);
VcsOutputWindow::append(resp.stdOut());
}

View File

@@ -112,6 +112,15 @@ public:
+ text.mid(matchEnd + resetColor.size());
}
single.matchingLine = text;
if (m_parameters.flags & FindRegularExpression) {
const QRegularExpression::PatternOptions patternOptions =
(m_parameters.flags & QTextDocument::FindCaseSensitively)
? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption;
QRegularExpression regexp(m_parameters.text, patternOptions);
QRegularExpressionMatch regexpMatch = regexp.match(line);
single.regexpCapturedTexts = regexpMatch.capturedTexts();
}
foreach (auto match, matches) {
single.matchStart = match.first;
single.matchLength = match.second;

View File

@@ -1396,6 +1396,10 @@ void GitPlugin::testStatusParsing_data()
QTest::newRow(" M") << FileStates(ModifiedFile) << FileStates(UnknownFileState);
QTest::newRow(" D") << FileStates(DeletedFile) << FileStates(UnknownFileState);
QTest::newRow(" T") << FileStates(TypeChangedFile) << FileStates(UnknownFileState);
QTest::newRow("T ") << (TypeChangedFile | StagedFile) << FileStates(UnknownFileState);
QTest::newRow("TM") << (TypeChangedFile | StagedFile) << FileStates(ModifiedFile);
QTest::newRow("MT") << (ModifiedFile | StagedFile) << FileStates(TypeChangedFile);
QTest::newRow("M ") << (ModifiedFile | StagedFile) << FileStates(UnknownFileState);
QTest::newRow("MM") << (ModifiedFile | StagedFile) << FileStates(ModifiedFile);
QTest::newRow("MD") << (ModifiedFile | StagedFile) << FileStates(DeletedFile);

View File

@@ -146,7 +146,7 @@ void GitSubmitEditor::setCommitData(const CommitData &d)
return SubmitFileModel::FileUnmerged;
if (state.testFlag(AddedFile) || state.testFlag(UntrackedFile))
return SubmitFileModel::FileAdded;
if (state.testFlag(ModifiedFile))
if (state.testFlag(ModifiedFile) || state.testFlag(TypeChangedFile))
return SubmitFileModel::FileModified;
if (state.testFlag(DeletedFile))
return SubmitFileModel::FileDeleted;

View File

@@ -157,6 +157,7 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
arguments << (commit.isEmpty() ? "HEAD" : commit);
if (!(flags & IncludeRemotes))
arguments << "--not" << "--remotes";
arguments << "--";
QString output;
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
return false;

View File

@@ -200,26 +200,39 @@ void MergeTool::prompt(const QString &title, const QString &question)
void MergeTool::readData()
{
bool waitForFurtherInput = false;
while (m_process->bytesAvailable()) {
QByteArray line = m_process->canReadLine() ? m_process->readLine() : m_process->readAllStandardOutput();
const bool hasLine = m_process->canReadLine();
const QByteArray line = hasLine ? m_process->readLine() : m_process->readAllStandardOutput();
VcsOutputWindow::append(QString::fromLocal8Bit(line));
m_line += line;
// {Normal|Deleted|Submodule|Symbolic link} merge conflict for 'foo.cpp'
int index = line.indexOf(" merge conflict for ");
const int index = m_line.indexOf(" merge conflict for ");
if (index != -1) {
m_mergeType = mergeType(line.left(index));
int quote = line.indexOf('\'');
m_fileName = QString::fromLocal8Bit(line.mid(quote + 1, line.lastIndexOf('\'') - quote - 1));
} else if (line.startsWith(" {local}")) {
m_localState = parseStatus(line, m_localInfo);
} else if (line.startsWith(" {remote}")) {
m_remoteState = parseStatus(line, m_remoteInfo);
m_mergeType = mergeType(m_line.left(index));
int quote = m_line.indexOf('\'');
m_fileName = QString::fromLocal8Bit(m_line.mid(quote + 1, m_line.lastIndexOf('\'') - quote - 1));
} else if (m_line.startsWith(" {local}")) {
waitForFurtherInput = !hasLine;
if (waitForFurtherInput)
continue;
m_localState = parseStatus(m_line, m_localInfo);
m_line.clear();
} else if (m_line.startsWith(" {remote}")) {
waitForFurtherInput = !hasLine;
if (waitForFurtherInput)
continue;
m_remoteState = parseStatus(m_line, m_remoteInfo);
m_line.clear();
chooseAction();
} else if (line.startsWith("Was the merge successful")) {
} else if (m_line.startsWith("Was the merge successful")) {
prompt(tr("Unchanged File"), tr("Was the merge successful?"));
} else if (line.startsWith("Continue merging")) {
} else if (m_line.startsWith("Continue merging")) {
prompt(tr("Continue Merging"), tr("Continue merging other unresolved paths?"));
}
}
if (!waitForFurtherInput)
m_line.clear();
}
void MergeTool::done()

View File

@@ -82,6 +82,7 @@ private:
QString m_localInfo;
FileState m_remoteState = UnknownState;
QString m_remoteInfo;
QByteArray m_line;
bool m_merging = false;
};