OSDN Git Service

Diff file list dialog click log is okay
authorFrank Li <lznuaa@gmail.com>
Sat, 23 Jan 2010 11:53:15 +0000 (19:53 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 23 Jan 2010 11:53:15 +0000 (19:53 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/FileDiffDlg.cpp
src/TortoiseProc/FileDiffDlg.h

index 7a0ac48..c9c8fed 100644 (file)
@@ -32,6 +32,8 @@
 #include ".\filediffdlg.h"\r
 #include "gitdiff.h"\r
 #include "CommonResource.h"\r
+#include "BrowseRefsDlg.h"\r
+#include "LogDlg.h"\r
 \r
 #define ID_COMPARE 1\r
 #define ID_BLAME 2\r
@@ -1068,33 +1070,56 @@ bool CFileDiffDlg::SortCompare(const CTGitPath*& Data1, const CTGitPath*& Data2)
 \r
 void CFileDiffDlg::OnBnClickedRev1btn()\r
 {\r
-#if 0\r
-       if (m_bThreadRunning)\r
-               return; // do nothing as long as the thread is still running\r
+       \r
+       ClickRevButton(&this->m_cRev1Btn,&this->m_rev1, &this->m_ctrRev1Edit);\r
 \r
-       // show a dialog where the user can enter a revision\r
-       CRevisionDlg dlg(this);\r
-       dlg.AllowWCRevs(false);\r
-       *((GitRev*)&dlg) = m_rev1;\r
+}\r
 \r
-       if (dlg.DoModal() == IDOK)\r
+void CFileDiffDlg::ClickRevButton(CMenuButton *button, GitRev *rev, CEdit *edit)\r
+{\r
+       int entry=button->GetCurrentEntry();\r
+       if(entry == 0) /* Browse Refence*/\r
        {\r
-               m_rev1 = dlg;\r
-               m_cRev1Btn.SetWindowText(m_rev1.ToString());\r
-               m_cFileList.DeleteAllItems();\r
-               // start a new thread to re-fetch the diff\r
-               InterlockedExchange(&m_bThreadRunning, TRUE);\r
-               if (AfxBeginThread(DiffThreadEntry, this)==NULL)\r
                {\r
-                       InterlockedExchange(&m_bThreadRunning, FALSE);\r
-                       CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
+                       CString str = CBrowseRefsDlg::PickRef();\r
+                       if(str.IsEmpty())\r
+                               return;\r
+                       \r
+                       if(FillRevFromString(rev,str))\r
+                               return;\r
+\r
+                       edit->SetWindowText(str);\r
                }\r
        }\r
-#endif\r
+\r
+       if(entry == 1) /*Log*/\r
+       {\r
+               CLogDlg dlg;\r
+               dlg.SetSelect(true);\r
+               if(dlg.DoModal() == IDOK)\r
+               {\r
+                       if( dlg.GetSelectedHash().IsEmpty() )\r
+                               return;\r
+\r
+                       if(FillRevFromString(rev,dlg.GetSelectedHash()))\r
+                               return;\r
+\r
+                       edit->SetWindowText(dlg.GetSelectedHash());\r
+\r
+               }else\r
+                       return;\r
+       }\r
+\r
+       if(entry == 2) /*RefLog*/\r
+       {\r
+       }\r
+\r
+       SetURLLabels();\r
 }\r
 \r
 void CFileDiffDlg::OnBnClickedRev2btn()\r
 {\r
+       ClickRevButton(&this->m_cRev2Btn,&this->m_rev2, &this->m_ctrRev2Edit);\r
 #if 0\r
        if (m_bThreadRunning)\r
                return; // do nothing as long as the thread is still running\r
index 1ceaca1..4ef30ac 100644 (file)
@@ -100,6 +100,23 @@ protected:
        void                            SetURLLabels();\r
        void                            Filter(CString sFilterText);\r
        void                            CopySelectionToClipboard();\r
+       \r
+       void                            ClickRevButton(CMenuButton *button,GitRev *rev, CEdit *edit);\r
+\r
+       int                                     FillRevFromString(GitRev *rev, CString str)\r
+       {\r
+               GitRev gitrev;\r
+               if(gitrev.GetCommit(str))\r
+               {\r
+                       CString msg;\r
+                       msg.Format(_T("Reference %s is wrong"),str);\r
+                       CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return -1;\r
+               }\r
+               *rev=gitrev;\r
+               return 0;\r
+       }\r
+\r
 private:\r
        static UINT                     DiffThreadEntry(LPVOID pVoid);\r
        UINT                            DiffThread();\r