From 5c0400cba4cad2298ed17d38de1d5a685935a259 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 2 Jan 2012 08:17:46 +0100 Subject: [PATCH] Fixed issue #999: Added "Diff submodule" dialog Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/Resources/TortoiseProcENG.rc | 28 +++++++++++ src/TortoiseProc/GitDiff.cpp | 35 +++++--------- src/TortoiseProc/SubmoduleDiffDlg.cpp | 90 +++++++++++++++++++++++++++++++++++ src/TortoiseProc/SubmoduleDiffDlg.h | 48 +++++++++++++++++++ src/TortoiseProc/TortoiseProc.vcproj | 8 ++++ src/TortoiseProc/resource.h | 9 +++- 7 files changed, 195 insertions(+), 24 deletions(-) create mode 100644 src/TortoiseProc/SubmoduleDiffDlg.cpp create mode 100644 src/TortoiseProc/SubmoduleDiffDlg.h diff --git a/src/Changelog.txt b/src/Changelog.txt index d39c11fe9..e1813086b 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -4,6 +4,7 @@ * Fixed issue #880: Allow sync / fetch / push on bare repository * Fixed issue #818: SafeCRLF = warn should be available * Fixed issue #855: moved up Git page in settings dialog + * Fixed issue #999: Added "Diff submodule" dialog == Bug Fix == * Updated shipped PuTTY binaries to version 0.62 diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index d18ecdb5e..b4ee2db81 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -1562,6 +1562,24 @@ BEGIN PUSHBUTTON "Help",IDHELP,210,76,50,14 END +IDD_DIFFSUBMODULE DIALOGEX 0, 0, 301, 121 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Submodule Diff" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Submodule",IDC_SUBMODULEDIFFTITLE,7,7,287,8 + GROUPBOX "From",IDC_FROMGROUP,7,20,288,45 + LTEXT "Revision:",IDC_STATIC,15,32,33,8 + EDITTEXT IDC_FROMHASH,52,32,234,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Subject:",IDC_STATIC,15,49,33,8 + EDITTEXT IDC_FROMSUBJECT,52,49,234,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + GROUPBOX "To",IDC_TOGROUP,7,69,288,45 + LTEXT "Revision:",IDC_STATIC,15,82,33,8 + EDITTEXT IDC_TOHASH,52,82,234,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Subject:",IDC_STATIC,15,96,33,8 + EDITTEXT IDC_TOSUBJECT,52,96,234,12,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER +END + ///////////////////////////////////////////////////////////////////////////// // @@ -2301,6 +2319,16 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 90 END + + IDD_DIFFSUBMODULE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 294 + VERTGUIDE, 52 + VERTGUIDE, 286 + TOPMARGIN, 7 + BOTTOMMARGIN, 114 + END END #endif // APSTUDIO_INVOKED diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 1f7f94e83..1399eff1a 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2008 - TortoiseSVN -// Copyright (C) 2008-2011 - TortoiseGit +// Copyright (C) 2008-2012 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -24,6 +24,7 @@ #include "resource.h" #include "MessageBox.h" #include "FileDiffDlg.h" +#include "SubmoduleDiffDlg.h" CGitDiff::CGitDiff(void) { @@ -56,7 +57,6 @@ int CGitDiff::SubmoduleDiffNull(CTGitPath *pPath, git_revnum_t &/*rev1*/) CString oldsub ; CString newsub; CString newhash; - CString workingcopy; CString cmd; cmd.Format(_T("git.exe ls-tree HEAD -- \"%s\""), pPath->GetGitPathString()); @@ -82,15 +82,10 @@ int CGitDiff::SubmoduleDiffNull(CTGitPath *pPath, git_revnum_t &/*rev1*/) cmd.Format(_T("git.exe log -n1 --pretty=format:\"%%s\" %s"),newhash); subgit.Run(cmd,&newsub,encode); - CString msg; - msg.Format(_T("Submodule %s Change\r\n\r\nFrom: %s\r\n\t%s\r\n\r\nTo%s: %s\r\n\t\t%s"), - pPath->GetWinPath(), - oldhash, - oldsub , - workingcopy, - newhash, - newsub); - CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK); + CSubmoduleDiffDlg submoduleDiffDlg; + submoduleDiffDlg.SetDiff(pPath->GetWinPath(), false, oldhash, oldsub, newhash, newsub); + submoduleDiffDlg.DoModal(); + return 0; } @@ -160,8 +155,7 @@ int CGitDiff::SubmoduleDiff(CTGitPath * pPath,CTGitPath * /*pPath2*/, git_revnum CString oldhash; CString newhash; CString cmd; - CString workingcopy; - + bool isWorkingCopy = false; if( rev2 == GIT_REV_ZERO || rev1 == GIT_REV_ZERO ) { oldhash = GIT_REV_ZERO; @@ -173,7 +167,7 @@ int CGitDiff::SubmoduleDiff(CTGitPath * pPath,CTGitPath * /*pPath2*/, git_revnum if( rev1 != GIT_REV_ZERO ) rev = rev1; - workingcopy = _T(" (Work Copy)"); + isWorkingCopy = true; cmd.Format(_T("git.exe diff %s -- \"%s\""), rev,pPath->GetGitPathString()); @@ -242,15 +236,10 @@ int CGitDiff::SubmoduleDiff(CTGitPath * pPath,CTGitPath * /*pPath2*/, git_revnum subgit.Run(cmd,&newsub,encode); } } - CString msg; - msg.Format(_T("Submodule %s Change\r\n\r\nFrom: %s\r\n\t%s\r\n\r\nTo%s: %s\r\n\t\t%s"), - pPath->GetWinPath(), - oldhash, - oldsub , - workingcopy, - newhash, - newsub); - CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK); + + CSubmoduleDiffDlg submoduleDiffDlg; + submoduleDiffDlg.SetDiff(pPath->GetWinPath(), isWorkingCopy, oldhash, oldsub, newhash, newsub); + submoduleDiffDlg.DoModal(); return 0; } diff --git a/src/TortoiseProc/SubmoduleDiffDlg.cpp b/src/TortoiseProc/SubmoduleDiffDlg.cpp new file mode 100644 index 000000000..81ee22c02 --- /dev/null +++ b/src/TortoiseProc/SubmoduleDiffDlg.cpp @@ -0,0 +1,90 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2012 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#include "stdafx.h" +#include "TortoiseProc.h" +#include "AppUtils.h" +#include "SubmoduleDiffDlg.h" + +IMPLEMENT_DYNAMIC(CSubmoduleDiffDlg, CHorizontalResizableStandAloneDialog) +CSubmoduleDiffDlg::CSubmoduleDiffDlg(CWnd* pParent /*=NULL*/) + : CHorizontalResizableStandAloneDialog(CSubmoduleDiffDlg::IDD, pParent) +{ +} + +CSubmoduleDiffDlg::~CSubmoduleDiffDlg() +{ +} + +void CSubmoduleDiffDlg::DoDataExchange(CDataExchange* pDX) +{ + CHorizontalResizableStandAloneDialog::DoDataExchange(pDX); + DDX_Text(pDX, IDC_FROMHASH, m_sFromHash); + DDX_Text(pDX, IDC_FROMSUBJECT, m_sFromSubject); + DDX_Text(pDX, IDC_TOHASH, m_sToHash); + DDX_Text(pDX, IDC_TOSUBJECT, m_sToSubject); +} + +BEGIN_MESSAGE_MAP(CSubmoduleDiffDlg, CHorizontalResizableStandAloneDialog) +END_MESSAGE_MAP() + +BOOL CSubmoduleDiffDlg::OnInitDialog() +{ + CHorizontalResizableStandAloneDialog::OnInitDialog(); + + CString sWindowTitle; + GetWindowText(sWindowTitle); + CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); + + AddAnchor(IDC_FROMGROUP, TOP_LEFT, TOP_RIGHT); + AddAnchor(IDC_TOGROUP, TOP_LEFT, TOP_RIGHT); + + AddAnchor(IDC_FROMHASH, TOP_LEFT, TOP_RIGHT); + AddAnchor(IDC_FROMSUBJECT, TOP_LEFT, TOP_RIGHT); + AddAnchor(IDC_TOHASH, TOP_LEFT, TOP_RIGHT); + AddAnchor(IDC_TOSUBJECT, TOP_LEFT, TOP_RIGHT); + + EnableSaveRestore(_T("SubmoduleDiffDlg")); + + if (m_bFromIsWorkingCopy) + { + CString fromGroup; + GetDlgItem(IDC_FROMGROUP)->GetWindowText(fromGroup); + fromGroup += _T(" (Working Copy)"); + GetDlgItem(IDC_FROMGROUP)->SetWindowText(fromGroup); + } + + CString title = _T("Submodule \"") + m_sPath + _T("\""); + GetDlgItem(IDC_SUBMODULEDIFFTITLE)->SetWindowText(title); + + UpdateData(FALSE); + + return FALSE; +} + +void CSubmoduleDiffDlg::SetDiff(CString path, bool fromIsWorkingCopy, CString fromHash, CString fromSubject, CString toHash, CString toSubject) +{ + m_bFromIsWorkingCopy = fromIsWorkingCopy; + + m_sPath = path; + + m_sFromHash = fromHash; + m_sFromSubject = fromSubject; + m_sToHash = toHash; + m_sToSubject = toSubject; +} diff --git a/src/TortoiseProc/SubmoduleDiffDlg.h b/src/TortoiseProc/SubmoduleDiffDlg.h new file mode 100644 index 000000000..2144c9f19 --- /dev/null +++ b/src/TortoiseProc/SubmoduleDiffDlg.h @@ -0,0 +1,48 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2012 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#pragma once +#include "HorizontalResizableStandAloneDialog.h" +#include "resource.h" + +class CSubmoduleDiffDlg : public CHorizontalResizableStandAloneDialog +{ + DECLARE_DYNAMIC(CSubmoduleDiffDlg) + +public: + CSubmoduleDiffDlg(CWnd* pParent = NULL); + virtual ~CSubmoduleDiffDlg(); + + enum { IDD = IDD_DIFFSUBMODULE }; + + void SetDiff(CString path, bool fromIsWorkingCopy, CString fromHash, CString fromSubject, CString toHash, CString toSubject); + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnInitDialog(); + + DECLARE_MESSAGE_MAP() + + bool m_bFromIsWorkingCopy; + CString m_sPath; + + CString m_sFromHash; + CString m_sFromSubject; + CString m_sToHash; + CString m_sToSubject; +}; diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index 0658db831..69a8c7fd9 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -2185,6 +2185,14 @@ RelativePath=".\ResetDlg.h" > + + + +