diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2012-10-28 22:03:44 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2012-10-29 14:59:42 +0100 |
commit | 5011ba940f23c1c78c49611fedfa9a5d189cff61 (patch) | |
tree | ac9dfd3180a6216f5cb0f4118cbeebe5850da9f9 /src/plugins/git/commitdata.cpp | |
parent | ab85e7342e7b51a10b6bf5ebc66c1a47c70f3fa6 (diff) | |
download | qt-creator-5011ba940f23c1c78c49611fedfa9a5d189cff61.tar.gz |
Git: Support merge status
Change-Id: If0338d066a2844a8bedf3e5ecf89979dc5c20385
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/git/commitdata.cpp')
-rw-r--r-- | src/plugins/git/commitdata.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/plugins/git/commitdata.cpp b/src/plugins/git/commitdata.cpp index 8c81dd4059..a68b166f63 100644 --- a/src/plugins/git/commitdata.cpp +++ b/src/plugins/git/commitdata.cpp @@ -119,26 +119,36 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file) return true; } - FileStates stagedState = stateFor(stateInfo.at(0)); - if (stagedState == UnknownFileState) + FileStates xState = stateFor(stateInfo.at(0)); + FileStates yState = stateFor(stateInfo.at(1)); + if (xState == UnknownFileState || yState == UnknownFileState) return false; - stagedState |= StagedFile; - if (stagedState != StagedFile) - files.append(qMakePair(stagedState, file)); - - FileStates state = stateFor(stateInfo.at(1)); - if (state == UnknownFileState) - return false; + bool isMerge = (xState == UnmergedFile || yState == UnmergedFile || + ((xState == yState) && (xState == AddedFile || xState == DeletedFile))); + if (isMerge) { + if (xState == yState) { + if (xState == UnmergedFile) + xState = ModifiedFile; + files.append(qMakePair(xState | UnmergedFile | UnmergedUs | UnmergedThem, file)); + } else if (xState == UnmergedFile) { + files.append(qMakePair(yState | UnmergedFile | UnmergedThem, file)); + } else { + files.append(qMakePair(xState | UnmergedFile | UnmergedUs, file)); + } + } else { + xState |= StagedFile; + if (xState != StagedFile) + files.append(qMakePair(xState, file)); - if (state != UntrackedFile) { - QString newFile = file; - if (stagedState & (RenamedFile | CopiedFile)) - newFile = file.mid(file.indexOf(QLatin1String(" -> ")) + 4); + if (yState != UntrackedFile) { + QString newFile = file; + if (xState & (RenamedFile | CopiedFile)) + newFile = file.mid(file.indexOf(QLatin1String(" -> ")) + 4); - files.append(qMakePair(state, newFile)); + files.append(qMakePair(yState, newFile)); + } } - return true; } @@ -199,8 +209,14 @@ QString CommitData::stateDisplayName(const FileStates &state) resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "renamed")); else if (state & CopiedFile) resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "copied")); - else if (state & UnmergedFile) - resultState.append(QCoreApplication::translate("Git::Internal::CommitData", "unmerged")); + if (state & UnmergedUs) { + if (state & UnmergedThem) + resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by both")); + else + resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by us")); + } else if (state & UnmergedThem) { + resultState.append(QCoreApplication::translate("Git::Internal::CommitData", " by them")); + } return resultState; } |