From: Johan 't Hart Date: Sun, 14 Jun 2009 12:42:37 +0000 (+0200) Subject: BrowseRefsDlg: Add ability to diff two commits X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=commitdiff_plain;h=de2b783d39ae37fb0b4298779532de24c4e0d460 BrowseRefsDlg: Add ability to diff two commits --- diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index dcea82c..aadb3b4 100644 Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ diff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp index 278853b..c0701e2 100644 --- a/src/TortoiseProc/BrowseRefsDlg.cpp +++ b/src/TortoiseProc/BrowseRefsDlg.cpp @@ -12,6 +12,7 @@ #include "MessageBox.h" #include "RefLogDlg.h" #include "IconMenu.h" +#include "FileDiffDlg.h" void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending) { @@ -160,11 +161,11 @@ CShadowTree* CShadowTree::FindLeaf(CString partialRefName) typedef std::map MAP_STRING_STRING; -CString CBrowseRefsDlg::GetSelectedRef(bool onlyIfLeaf) +CString CBrowseRefsDlg::GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel) { POSITION pos=m_ListRefLeafs.GetFirstSelectedItemPosition(); //List ctrl selection? - if(pos) + if(pos && (pickFirstSelIfMultiSel || m_ListRefLeafs.GetSelectedCount() == 1)) { //A leaf is selected CShadowTree* pTree=(CShadowTree*)m_ListRefLeafs.GetItemData( @@ -200,7 +201,7 @@ void CBrowseRefsDlg::Refresh(CString selectRef) } else { - selectRef = GetSelectedRef(false); + selectRef = GetSelectedRef(false, true); } m_RefTreeCtrl.DeleteAllItems(); @@ -578,6 +579,12 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh // if(pTree==NULL) // return; } + else if(selectedLeafs.size() == 2) + { + bAddSeparator = true; + + popupMenu.AppendMenuIcon(eCmd_Diff, L"Diff These Commits", IDI_DIFF); + } if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); @@ -654,6 +661,16 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh Refresh(); } break; + case eCmd_Diff: + { + CFileDiffDlg dlg; + dlg.SetDiff( + NULL, + selectedLeafs[0]->m_csRefHash, + selectedLeafs[1]->m_csRefHash); + dlg.DoModal(); + } + break; } } @@ -753,7 +770,7 @@ void CBrowseRefsDlg::OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResul void CBrowseRefsDlg::OnDestroy() { - m_pickedRef = GetSelectedRef(true); + m_pickedRef = GetSelectedRef(true, false); CResizableStandAloneDialog::OnDestroy(); } diff --git a/src/TortoiseProc/BrowseRefsDlg.h b/src/TortoiseProc/BrowseRefsDlg.h index bf3fafb..f379dd6 100644 --- a/src/TortoiseProc/BrowseRefsDlg.h +++ b/src/TortoiseProc/BrowseRefsDlg.h @@ -67,7 +67,8 @@ public: eCmd_DeleteBranch, eCmd_DeleteRemoteBranch, eCmd_DeleteTag, - eCmd_ShowReflog + eCmd_ShowReflog, + eCmd_Diff }; enum eCol @@ -89,7 +90,7 @@ public: afx_msg void OnBnClickedOk(); virtual BOOL OnInitDialog(); - CString GetSelectedRef(bool onlyIfLeaf); + CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false); void Refresh(CString selectRef = CString()); diff --git a/src/TortoiseProc/FileDiffDlg.h b/src/TortoiseProc/FileDiffDlg.h index e94a8b5..74496ab 100644 --- a/src/TortoiseProc/FileDiffDlg.h +++ b/src/TortoiseProc/FileDiffDlg.h @@ -28,6 +28,7 @@ #include "XPImageButton.h" #include "FilterEdit.h" #include "Tooltip.h" +#include "ProgressDlg.h" #define IDT_FILTER 101