# # # patch "NEWS" # from [d0d9dc22a0cc10e3691e75cb0a77e805fa33b182] # to [55f2814952c241492ed01ea46416b34fd1100cf2] # # patch "src/model/GetFile.cpp" # from [71eb299484ec7ad15dea21b6f5604a947b58778b] # to [542df815ec28abfce7ab1e47c466414070ffe7c7] # # patch "src/model/GetFile.h" # from [0c796e32b16d6fb12567629e72940f551cba74f5] # to [f185acd189190ef2d6d519a8f5adbfd727a3093d] # # patch "src/view/dialogs/FileDiff.cpp" # from [1f8c9243580e4617bf3a9887cbb0ec0cbc78a225] # to [b5178b6755daa3f433adbc942034889cb266aebe] # ============================================================ --- NEWS d0d9dc22a0cc10e3691e75cb0a77e805fa33b182 +++ NEWS 55f2814952c241492ed01ea46416b34fd1100cf2 @@ -35,6 +35,8 @@ "missing \n" after the type of the line, the detailed diff dialog you get this information in a tooltip when hovering over the particular line. This needs a monotone installation >= 0.40 + - improved: in file diff dialogs the correct line numbers for the old / new + file is shown - bugfix: a running mtn instance for a workspace is now properly re-used if needed for a database-only task - bugfix: fixed a crash which occured when an internal thread was deleted ============================================================ --- src/model/GetFile.cpp 71eb299484ec7ad15dea21b6f5604a947b58778b +++ src/model/GetFile.cpp 542df815ec28abfce7ab1e47c466414070ffe7c7 @@ -82,7 +82,7 @@ void GetFile::processTaskResult(const Mo for (int i=0, s=lines.size() - 1; ileftStart; + int rightLineCount = hunk->rightStart; + for (int j=0, t=hunk->lines.size(); jlines.at(j); @@ -112,22 +115,28 @@ void GetFile::applyDiff(Diff * diff) switch (line->state) { case DiffLine::Unchanged: + fileContents.value(lineStart - 1)->leftLineCount = leftLineCount; + fileContents.value(lineStart - 1)->rightLineCount = rightLineCount; + leftLineCount++; + rightLineCount++; break; case DiffLine::UnchangedMissingNewline: case DiffLine::Removed: case DiffLine::RemovedMissingNewline: - I(lineStart - 1 >= 0); fileContents.value(lineStart - 1)->state = line->state; + fileContents.value(lineStart - 1)->leftLineCount = leftLineCount; + fileContents.value(lineStart - 1)->rightLineCount = 0; + leftLineCount++; break; case DiffLine::Added: case DiffLine::AddedMissingNewline: - I(lineStart - 1 >= 0); fileContents.insert( lineStart - 1, - new ContentLine(line->content, line->state) + new ContentLine(line->content, line->state, 0, rightLineCount) ); + rightLineCount++; addedLines++; break; @@ -135,6 +144,11 @@ void GetFile::applyDiff(Diff * diff) } lineStart++; } + + for (int i=lineStart-1; irightLineCount = rightLineCount++; + } } reset(); @@ -219,7 +233,7 @@ int GetFile::columnCount(const QModelInd int GetFile::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 2; + return 3; } QVariant GetFile::data(const QModelIndex & index, int role) const @@ -238,8 +252,11 @@ QVariant GetFile::data(const QModelIndex { switch (index.column()) { - case 0: return QVariant(row + 1); - case 1: return QVariant(line->content); + case 0: return QVariant(line->leftLineCount == 0 ? + "-" : QString::number(line->leftLineCount)); + case 1: return QVariant(line->rightLineCount == 0 ? + "-" : QString::number(line->rightLineCount)); + case 2: return QVariant(line->content); default: I(false); } } @@ -251,7 +268,7 @@ QVariant GetFile::data(const QModelIndex case DiffLine::Added: case DiffLine::AddedMissingNewline: return QVariant(QBrush(Qt::green)); - case DiffLine::Removed: + case DiffLine::Removed: case DiffLine::RemovedMissingNewline: return QVariant(QBrush(Qt::red)); default: return QVariant(); @@ -271,7 +288,7 @@ QVariant GetFile::data(const QModelIndex } } else - if (role == Qt::FontRole && index.column() == 1) + if (role == Qt::FontRole && index.column() > 1) { QFont font; font.setStyleHint(QFont::Courier); @@ -279,7 +296,7 @@ QVariant GetFile::data(const QModelIndex return QVariant(font); } else - if (role == Qt::TextAlignmentRole && index.column() == 0) + if (role == Qt::TextAlignmentRole && index.column() < 2) { return QVariant(Qt::AlignRight); } @@ -300,8 +317,9 @@ QVariant GetFile::headerData(int section { switch (section) { - case 0: return QVariant(tr("Line")); - case 1: return QVariant(tr("Content")); + case 0: return QVariant(tr("Left Line No")); + case 1: return QVariant(tr("Right Line No")); + case 2: return QVariant(tr("Content")); } } ============================================================ --- src/model/GetFile.h 0c796e32b16d6fb12567629e72940f551cba74f5 +++ src/model/GetFile.h f185acd189190ef2d6d519a8f5adbfd727a3093d @@ -30,8 +30,11 @@ struct ContentLine { struct ContentLine { QString content; DiffLine::State state; + int leftLineCount; + int rightLineCount; ContentLine() {} - ContentLine(QString c, DiffLine::State s) : content(c), state(s) {} + ContentLine(QString c, DiffLine::State s, int left, int right) + : content(c), state(s), leftLineCount(left), rightLineCount(right) {} }; typedef QVector Content; ============================================================ --- src/view/dialogs/FileDiff.cpp 1f8c9243580e4617bf3a9887cbb0ec0cbc78a225 +++ src/view/dialogs/FileDiff.cpp b5178b6755daa3f433adbc942034889cb266aebe @@ -28,8 +28,11 @@ FileDiff::FileDiff(QWidget * parent) : D setupUi(this); Dialog::init(); - // make the line number col a little smaller - diffView->header()->resizeSection(0, 40); + // setup correct header widths + diffView->header()->setDefaultSectionSize(40); + diffView->header()->setResizeMode(0, QHeaderView::Interactive); + diffView->header()->setResizeMode(1, QHeaderView::Interactive); + diffView->header()->setResizeMode(2, QHeaderView::ResizeToContents); connect( firstRevision, SIGNAL(toggled(bool)), @@ -195,11 +198,23 @@ void FileDiff::versionToggled() void FileDiff::versionToggled() { if (firstRevision->isChecked()) + { fileProxyModel->setFileVersion(GetFileProxyModel::Left); - if (secondRevision->isChecked()) + diffView->header()->showSection(0); + diffView->header()->hideSection(1); + } + else if (secondRevision->isChecked()) + { fileProxyModel->setFileVersion(GetFileProxyModel::Right); - if (bothRevisions->isChecked()) + diffView->header()->showSection(1); + diffView->header()->hideSection(0); + } + else if (bothRevisions->isChecked()) + { fileProxyModel->setFileVersion(GetFileProxyModel::Both); + diffView->header()->showSection(0); + diffView->header()->showSection(1); + } diffStatusView->update(); }