forked from qt-creator/qt-creator
Subversion: Do not treat all numbers in log/annotate as revisions
Be more picky about what we consider to be a revision. Task-number: QTCREATORBUG-11845 Change-Id: If6dc68a564376df7dd26a0e996c74f7ebcc29177 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -46,8 +46,8 @@ using namespace Subversion;
|
|||||||
using namespace Subversion::Internal;
|
using namespace Subversion::Internal;
|
||||||
|
|
||||||
SubversionEditorWidget::SubversionEditorWidget() :
|
SubversionEditorWidget::SubversionEditorWidget() :
|
||||||
m_changeNumberPattern(QLatin1String("^\\d+$")),
|
m_changeNumberPattern(QLatin1String("^\\s*(?<area>(?<rev>\\d+))\\s+.*$")),
|
||||||
m_revisionNumberPattern(QLatin1String("^r\\d+$"))
|
m_revisionNumberPattern(QLatin1String("\\b(?<area>(r|[rR]evision )(?<rev>\\d+))\\b"))
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
|
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
|
||||||
QTC_ASSERT(m_revisionNumberPattern.isValid(), return);
|
QTC_ASSERT(m_revisionNumberPattern.isValid(), return);
|
||||||
@@ -93,17 +93,33 @@ QString SubversionEditorWidget::changeUnderCursor(const QTextCursor &c) const
|
|||||||
{
|
{
|
||||||
QTextCursor cursor = c;
|
QTextCursor cursor = c;
|
||||||
// Any number is regarded as change number.
|
// Any number is regarded as change number.
|
||||||
cursor.select(QTextCursor::WordUnderCursor);
|
cursor.select(QTextCursor::LineUnderCursor);
|
||||||
if (!cursor.hasSelection())
|
if (!cursor.hasSelection())
|
||||||
return QString();
|
return QString();
|
||||||
QString change = cursor.selectedText();
|
QString change = cursor.selectedText();
|
||||||
// Annotation output has number, log output has revision numbers
|
const int pos = c.position() - cursor.selectionStart() + 1;
|
||||||
// as r1, r2...
|
// Annotation output has number, log output has revision numbers,
|
||||||
if (m_changeNumberPattern.exactMatch(change))
|
// both at the start of the line.
|
||||||
return change;
|
auto matchIter = m_changeNumberPattern.globalMatch(change);
|
||||||
if (m_revisionNumberPattern.exactMatch(change)) {
|
if (!matchIter.hasNext())
|
||||||
change.remove(0, 1);
|
matchIter = m_revisionNumberPattern.globalMatch(change);
|
||||||
return change;
|
|
||||||
|
// We may have several matches of our regexp and we way have
|
||||||
|
// several () in the regexp
|
||||||
|
const QString areaName = QLatin1String("area");
|
||||||
|
while (matchIter.hasNext()) {
|
||||||
|
auto match = matchIter.next();
|
||||||
|
const QString rev = match.captured(QLatin1String("rev"));
|
||||||
|
if (rev.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const QString area = match.captured(areaName);
|
||||||
|
QTC_ASSERT(area.contains(rev), continue);
|
||||||
|
|
||||||
|
const int start = match.capturedStart(areaName);
|
||||||
|
const int end = match.capturedEnd(areaName);
|
||||||
|
if (pos > start && pos <= end)
|
||||||
|
return rev;
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace Subversion {
|
namespace Subversion {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -51,8 +51,8 @@ private:
|
|||||||
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
|
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
|
||||||
QStringList annotationPreviousVersions(const QString &) const;
|
QStringList annotationPreviousVersions(const QString &) const;
|
||||||
|
|
||||||
mutable QRegExp m_changeNumberPattern;
|
QRegularExpression m_changeNumberPattern;
|
||||||
mutable QRegExp m_revisionNumberPattern;
|
QRegularExpression m_revisionNumberPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user