From 8a192882ff79e10d5979f76d709227823587112a Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sun, 22 Jun 2014 21:58:06 +0200 Subject: [PATCH] Fixed issue #2170: Please add interface to "git svn log -v" Signed-off-by: Sven Strickroth --- Languages/Tortoise.pot | 4 ++++ src/Changelog.txt | 1 + src/Resources/LoglistCommonResource.h | 1 + src/Resources/TortoiseLoglistCommon.rc2 | 1 + src/TortoiseProc/GitLogListBase.cpp | 40 +++++++++++++++++++++++++++++++++ src/TortoiseProc/GitLogListBase.h | 2 ++ 6 files changed, 49 insertions(+) diff --git a/Languages/Tortoise.pot b/Languages/Tortoise.pot index 710a03e0f..332d08f79 100644 --- a/Languages/Tortoise.pot +++ b/Languages/Tortoise.pot @@ -7712,6 +7712,10 @@ msgstr "" msgid "SVN Rebase" msgstr "" +#. Resource IDs: (1256) +msgid "SVN Rev" +msgstr "" + #. Resource IDs: (65535) msgid "Sa&feCrLf:" msgstr "" diff --git a/src/Changelog.txt b/src/Changelog.txt index 0ecfb5f9f..0ce0e9311 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -4,6 +4,7 @@ Released: unreleased == Features == * Updated shipped libgit2 to version 0.21 * Fixed issue #1605: Add TortoiseGit start and pre commit hooks + * Fixed issue #2170: Please add interface to "git svn log -v" == Bug Fixes == * Fixed issue #2216: Add fails with message: libgit2: "failed to parse 'warn' as boolean" diff --git a/src/Resources/LoglistCommonResource.h b/src/Resources/LoglistCommonResource.h index d060f18ea..a1c9d736b 100644 --- a/src/Resources/LoglistCommonResource.h +++ b/src/Resources/LoglistCommonResource.h @@ -114,6 +114,7 @@ #define IDC_EDIT_FILTER 20091 #define IDS_DELETE_BRANCHTAG_SHORT 20092 #define IDC_CHECK_REGEX 20093 +#define IDS_LOG_SVNREV 20094 #define IDD_FIND 20100 #define IDS_CHERRY_PICK_VERSIONS 20101 diff --git a/src/Resources/TortoiseLoglistCommon.rc2 b/src/Resources/TortoiseLoglistCommon.rc2 index 4830137a2..b8b7f36dc 100644 --- a/src/Resources/TortoiseLoglistCommon.rc2 +++ b/src/Resources/TortoiseLoglistCommon.rc2 @@ -24,6 +24,7 @@ BEGIN IDS_LOG_EMAIL "Email" IDS_LOG_DATE "Date" IDS_LOG_BUGIDS "Bug-ID" + IDS_LOG_SVNREV "SVN Rev" IDS_LOG_ID "ID" IDS_LOG_HASH "SHA-1" IDS_LOG_POPUP_COMPARE "Compare with &working tree" diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index bc871351f..016a6d8c9 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -379,6 +379,7 @@ void CGitLogListBase::InsertGitColumn() IDS_LOG_COMMIT_EMAIL, IDS_LOG_COMMIT_DATE, IDS_LOG_BUGIDS, + IDS_LOG_SVNREV, }; static int with[] = @@ -396,6 +397,7 @@ void CGitLogListBase::InsertGitColumn() ICONITEMBORDER+16*4, ICONITEMBORDER+16*4, ICONITEMBORDER+16*4, + ICONITEMBORDER+16*4, }; m_dwDefaultColumns = GIT_LOG_GRAPH|GIT_LOG_ACTIONS|GIT_LOG_MESSAGE|GIT_LOG_AUTHOR|GIT_LOG_DATE; @@ -428,6 +430,10 @@ void CGitLogListBase::InsertGitColumn() { hideColumns |= GIT_LOGLIST_BUG; } + if (CTGitPath(g_Git.m_CurrentDir).HasGitSVNDir()) + m_dwDefaultColumns |= GIT_LOGLIST_SVNREV; + else + hideColumns |= GIT_LOGLIST_SVNREV; SetRedraw(false); m_ColumnManager.SetNames(normal, _countof(normal)); @@ -1500,6 +1506,36 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) *pResult = CDRF_DODEFAULT; } +CString FindSVNRev(const CString& msg) +{ + try + { + const std::tr1::wsregex_iterator end; + std::wstring s = msg; + for (std::tr1::wsregex_iterator it(s.begin(), s.end(), std::tr1::wregex(_T("^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\\s([a-f\\d\\-]+)$"))); it != end; ++it) + { + const std::tr1::wsmatch match = *it; + if (match.size() == 4) + { + ATLTRACE(_T("matched rev: %s\n"), std::wstring(match[2]).c_str()); + return std::wstring(match[2]).c_str(); + } + } + for (std::tr1::wsregex_iterator it(s.begin(), s.end(), std::tr1::wregex(_T("^\\s*git-svn-id:\\s(\\d+)\\@([a-f\\d\\-]+"))); it != end; ++it) + { + const std::tr1::wsmatch match = *it; + if (match.size() == 3) + { + ATLTRACE(_T("matched rev: %s\n"), std::wstring(match[1]).c_str()); + return std::wstring(match[1]).c_str(); + } + } + } + catch (std::exception) {} + + return _T(""); +} + // CGitLogListBase message handlers void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) @@ -1600,6 +1636,10 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) if(pLogEntry) lstrcpyn(pItem->pszText, (LPCTSTR)this->m_ProjectProperties.FindBugID(pLogEntry->GetSubject() + _T("\r\n\r\n") + pLogEntry->GetBody()), pItem->cchTextMax); break; + case this->LOGLIST_SVNREV: //SVN revision + if (pLogEntry) + lstrcpyn(pItem->pszText, (LPCTSTR)FindSVNRev(pLogEntry->GetSubject() + _T("\r\n\r\n") + pLogEntry->GetBody()), pItem->cchTextMax); + break; default: ASSERT(false); diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 56dbf7048..c0c7b7735 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -187,6 +187,7 @@ public: LOGLIST_COMMIT_EMAIL, LOGLIST_COMMIT_DATE, LOGLIST_BUG, + LOGLIST_SVNREV, LOGLIST_MESSAGE_MAX=300, LOGLIST_MESSAGE_MIN=200, @@ -203,6 +204,7 @@ public: GIT_LOG_COMMIT_EMAIL= 1<< LOGLIST_COMMIT_EMAIL, GIT_LOG_COMMIT_DATE = 1<< LOGLIST_COMMIT_DATE, GIT_LOGLIST_BUG = 1<< LOGLIST_BUG, + GIT_LOGLIST_SVNREV = 1<< LOGLIST_SVNREV, }; enum -- 2.11.4.GIT