OSDN Git Service

Add Switch Checkout Dialog
authorFrank Li <lznuaa@gmail.com>
Wed, 24 Dec 2008 10:08:24 +0000 (18:08 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 24 Dec 2008 10:08:24 +0000 (18:08 +0800)
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/Commands/SwitchCommand.cpp
src/TortoiseProc/GitSwitch.cpp [deleted file]
src/TortoiseProc/GitSwitch.h [deleted file]
src/TortoiseProc/GitSwitchDlg.cpp [new file with mode: 0644]
src/TortoiseProc/GitSwitchDlg.h [new file with mode: 0644]
src/TortoiseProc/HistoryDlg.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user
src/TortoiseProc/resource.h

index eb37ff4..8d5ab4d 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index a1736fd..1ccf18a 100644 (file)
@@ -39,6 +39,7 @@
 #include "BranchCommand.h"\r
 #include "TagCommand.h"\r
 #include "MergeCommand.h"\r
+#include "SwitchCommand.h"\r
 \r
 #if 0\r
 #include "AddCommand.h"\r
@@ -82,7 +83,7 @@
 #include "RTFMCommand.h"\r
 #include "SettingsCommand.h"\r
 #include "ShowCompareCommand.h"\r
-#include "SwitchCommand.h"\r
+\r
 #include "UnIgnoreCommand.h"\r
 #include "UnLockCommand.h"\r
 #include "UpdateCheckCommand.h"\r
@@ -267,6 +268,8 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new TagCommand;\r
        case cmdMerge:\r
                return new MergeCommand;\r
+       case cmdSwitch:\r
+               return new SwitchCommand;\r
 #if 0\r
        case cmdAdd:\r
                return new AddCommand;\r
@@ -344,8 +347,7 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new SettingsCommand;\r
        case cmdShowCompare:\r
                return new ShowCompareCommand;\r
-       case cmdSwitch:\r
-               return new SwitchCommand;\r
+\r
        case cmdUnIgnore:\r
                return new UnIgnoreCommand;\r
        case cmdUnlock:\r
index f39b1aa..299b53e 100644 (file)
 #include "StdAfx.h"\r
 #include "SwitchCommand.h"\r
 \r
-#include "SwitchDlg.h"\r
-//#include "SVNProgressDlg.h"\r
+#include "GitSwitchDlg.h"\r
+#include "ProgressDlg.h"\r
 #include "MessageBox.h"\r
 \r
 bool SwitchCommand::Execute()\r
 {\r
-       CSwitchDlg dlg;\r
-       dlg.m_path = cmdLinePath.GetWinPathString();\r
-\r
+       CGitSwitchDlg dlg;\r
+       \r
        if (dlg.DoModal() == IDOK)\r
        {\r
-#if 0\r
-               CSVNProgressDlg progDlg;\r
-               theApp.m_pMainWnd = &progDlg;\r
-               progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Switch);\r
-               if (parser.HasVal(_T("closeonend")))\r
-                       progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
-               progDlg.SetPathList(CTSVNPathList(cmdLinePath));\r
-               progDlg.SetUrl(dlg.m_URL);\r
-               progDlg.SetRevision(dlg.Revision);\r
-               progDlg.DoModal();\r
-               return !progDlg.DidErrorsOccur();\r
-#endif;\r
-               return true;\r
+               CString cmd;\r
+               CString track;\r
+               CString base;\r
+               CString force;\r
+               CString branch;\r
+\r
+               if(dlg.m_bBranch)\r
+                       branch.Format(_T("-b %s"),dlg.m_NewBranch);\r
+               if(dlg.m_bForce)\r
+                       force=_T("-f");\r
+               if(dlg.m_bTrack)\r
+                       track=_T("--track");\r
+\r
+               cmd.Format(_T("git.exe checkout %s %s %s %s"),\r
+                        force,\r
+                        track,\r
+                        branch,\r
+                        dlg.m_Base);\r
+\r
+               CProgressDlg progress;\r
+               progress.m_GitCmd=cmd;\r
+               if(progress.DoModal()==IDOK)\r
+                       return TRUE;\r
+\r
        }\r
        return false;\r
 }\r
diff --git a/src/TortoiseProc/GitSwitch.cpp b/src/TortoiseProc/GitSwitch.cpp
deleted file mode 100644 (file)
index f45cdf8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// GitSwitch.cpp : implementation file\r
-//\r
-\r
-#include "stdafx.h"\r
-#include "TortoiseProc.h"\r
-#include "GitSwitch.h"\r
-\r
-\r
-// CGitSwitch dialog\r
-\r
-IMPLEMENT_DYNAMIC(CGitSwitch, CDialog)\r
-\r
-CGitSwitch::CGitSwitch(CWnd* pParent /*=NULL*/)\r
-       : CDialog(CGitSwitch::IDD, pParent)\r
-{\r
-\r
-}\r
-\r
-CGitSwitch::~CGitSwitch()\r
-{\r
-}\r
-\r
-void CGitSwitch::DoDataExchange(CDataExchange* pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(CGitSwitch, CDialog)\r
-END_MESSAGE_MAP()\r
-\r
-\r
-// CGitSwitch message handlers\r
diff --git a/src/TortoiseProc/GitSwitch.h b/src/TortoiseProc/GitSwitch.h
deleted file mode 100644 (file)
index 0d1499c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once\r
-\r
-\r
-// CGitSwitch dialog\r
-\r
-class CGitSwitch : public CDialog\r
-{\r
-       DECLARE_DYNAMIC(CGitSwitch)\r
-\r
-public:\r
-       CGitSwitch(CWnd* pParent = NULL);   // standard constructor\r
-       virtual ~CGitSwitch();\r
-\r
-// Dialog Data\r
-       enum { IDD = IDD_GITSWITCH };\r
-\r
-protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
-\r
-       DECLARE_MESSAGE_MAP()\r
-};\r
diff --git a/src/TortoiseProc/GitSwitchDlg.cpp b/src/TortoiseProc/GitSwitchDlg.cpp
new file mode 100644 (file)
index 0000000..770bc41
--- /dev/null
@@ -0,0 +1,185 @@
+// GitSwitch.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "TortoiseProc.h"\r
+#include "GitSwitchDlg.h"\r
+\r
+#include "Git.h"\r
+#include "Messagebox.h"\r
+\r
+// CGitSwitchDlg dialog\r
+\r
+IMPLEMENT_DYNAMIC(CGitSwitchDlg, CResizableStandAloneDialog)\r
+\r
+CGitSwitchDlg::CGitSwitchDlg(CWnd* pParent /*=NULL*/)\r
+       : CResizableStandAloneDialog(CGitSwitchDlg::IDD, pParent)\r
+{\r
+       m_bBranch=FALSE;\r
+}\r
+\r
+CGitSwitchDlg::~CGitSwitchDlg()\r
+{\r
+}\r
+\r
+void CGitSwitchDlg::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       CDialog::DoDataExchange(pDX);\r
+       DDX_Control(pDX, IDC_COMBOBOXEX_BRANCH, this->m_Branch);\r
+       DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, this->m_Tags);\r
+       DDX_Control(pDX, IDC_COMBOBOXEX_VERSION, this->m_Version);\r
+                               \r
+       DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);\r
+       DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);\r
+       DDX_Check(pDX,IDC_CHECK_BRANCH,this->m_bBranch);\r
+\r
+       DDX_Text(pDX,IDC_EDIT_BRANCH,this->m_NewBranch);\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CGitSwitchDlg, CResizableStandAloneDialog)\r
+       ON_BN_CLICKED(IDC_RADIO_BRANCH, &CGitSwitchDlg::OnBnClickedRadio)\r
+       ON_BN_CLICKED(IDC_RADIO_TAGS, &CGitSwitchDlg::OnBnClickedRadio)\r
+       ON_BN_CLICKED(IDC_RADIO_VERSION, &CGitSwitchDlg::OnBnClickedRadio)\r
+       ON_BN_CLICKED(IDC_CHECK_BRANCH, &CGitSwitchDlg::OnBnClickedCheckBranch)\r
+       ON_BN_CLICKED(IDOK, &CGitSwitchDlg::OnBnClickedOk)\r
+       ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CGitSwitchDlg::OnCbnSelchangeComboboxexBranch)\r
+END_MESSAGE_MAP()\r
+\r
+BOOL CGitSwitchDlg::OnInitDialog()\r
+{\r
+       CResizableStandAloneDialog::OnInitDialog();\r
+\r
+       AddAnchor(IDC_COMBOBOXEX_BRANCH, TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT);\r
+\r
+       AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);\r
+\r
+       AddAnchor(IDC_EDIT_BRANCH, TOP_LEFT, TOP_RIGHT);\r
+\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+\r
+\r
+       AddAnchor(IDC_BUTTON_SHOW,TOP_RIGHT);\r
+       \r
+\r
+\r
+       CheckRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION,IDC_RADIO_BRANCH);\r
+\r
+       CStringList list;\r
+       g_Git.GetTagList(list);\r
+       m_Tags.AddString(list);\r
+\r
+       list.RemoveAll();\r
+       int current;\r
+       g_Git.GetBranchList(list,&current,CGit::BRANCH_ALL);\r
+       m_Branch.AddString(list);\r
+       m_Branch.SetCurSel(current);\r
+\r
+       m_Version.LoadHistory(_T("Software\\TortoiseGit\\History\\VersionHash"), _T("hash"));\r
+       m_Version.SetCurSel(0);\r
+\r
+       OnBnClickedRadio();\r
+       OnBnClickedCheckBranch();\r
+       this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
+\r
+       return TRUE;\r
+\r
+\r
+}\r
+// CCreateBranchTagDlg message handlers\r
+\r
+void CGitSwitchDlg::OnBnClickedRadio()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       this->m_Branch.EnableWindow(FALSE);\r
+       this->m_Tags.EnableWindow(FALSE);\r
+       this->m_Version.EnableWindow(FALSE);\r
+       int radio=GetCheckedRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION);\r
+       \r
+       switch (radio)\r
+       {\r
+       case IDC_RADIO_BRANCH:\r
+               this->m_Branch.EnableWindow(TRUE);\r
+               break;\r
+       case IDC_RADIO_TAGS:\r
+               this->m_Tags.EnableWindow(TRUE);                \r
+               break;\r
+       case IDC_RADIO_VERSION:\r
+               this->m_Version.EnableWindow(TRUE);\r
+               break;\r
+       }\r
+       OnCbnSelchangeComboboxexBranch();\r
+       OnBnClickedCheckBranch();\r
+       \r
+\r
+}\r
+\r
+void CGitSwitchDlg::OnBnClickedOk()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       this->UpdateData(TRUE);\r
+       \r
+       int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);\r
+       switch (radio)\r
+       {\r
+       case IDC_RADIO_BRANCH:\r
+               this->m_Base=m_Branch.GetString();\r
+               break;\r
+       case IDC_RADIO_TAGS:\r
+               this->m_Base=m_Tags.GetString();\r
+               this->m_bTrack=FALSE;\r
+               break;\r
+       case IDC_RADIO_VERSION:\r
+               this->m_Base=m_Version.GetString();\r
+               this->m_bTrack=FALSE;\r
+               break;\r
+       }\r
+       if(m_bBranch)\r
+       {\r
+               if(this->m_NewBranch.Trim().IsEmpty())\r
+               {\r
+                       CMessageBox::Show(NULL,_T("Branch can't empty"),_T("TortoiseGit"),MB_OK);\r
+                       return;\r
+               }\r
+       }\r
+       this->m_Version.SaveHistory();\r
+\r
+       OnOK();\r
+}\r
+void CGitSwitchDlg::OnBnClickedCheckBranch()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       this->UpdateData(TRUE);\r
+       \r
+       int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);\r
+       if(radio==IDC_RADIO_TAGS || radio==IDC_RADIO_VERSION)\r
+       {\r
+               this->m_bBranch=TRUE;\r
+               this->UpdateData(FALSE);\r
+               if(radio==IDC_RADIO_TAGS)\r
+                       GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(CString(_T("Branch_"))+m_Tags.GetString());\r
+               if(radio==IDC_RADIO_VERSION)\r
+                       GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(CString(_T("Branch_"))+m_Version.GetString());\r
+\r
+       }else\r
+       {\r
+               this->m_bBranch=FALSE;\r
+               this->UpdateData(FALSE);\r
+       }\r
+\r
+       this->GetDlgItem(IDC_EDIT_BRANCH)->EnableWindow(this->m_bBranch);\r
+}\r
+\r
+void CGitSwitchDlg::OnCbnSelchangeComboboxexBranch()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);\r
+       if(this->m_Branch.GetString().Left(6)==_T("origin") && radio==IDC_RADIO_BRANCH )\r
+               this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);\r
+       else\r
+               this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
+}\r
diff --git a/src/TortoiseProc/GitSwitchDlg.h b/src/TortoiseProc/GitSwitchDlg.h
new file mode 100644 (file)
index 0000000..7a7925c
--- /dev/null
@@ -0,0 +1,39 @@
+#pragma once\r
+\r
+#include "StandAloneDlg.h"\r
+#include "HistoryCombo.h"\r
+\r
+// CGitSwitchDlg dialog\r
+\r
+class CGitSwitchDlg : public CResizableStandAloneDialog\r
+{\r
+       DECLARE_DYNAMIC(CGitSwitchDlg)\r
+\r
+public:\r
+       CGitSwitchDlg(CWnd* pParent = NULL);   // standard constructor\r
+       virtual ~CGitSwitchDlg();\r
+\r
+// Dialog Data\r
+       enum { IDD = IDD_GITSWITCH };\r
+\r
+       BOOL m_bForce;\r
+       BOOL m_bTrack;\r
+       BOOL m_bBranch;\r
+       CString m_NewBranch;\r
+       CString m_Base;\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+       virtual BOOL OnInitDialog();\r
+       void OnBnClickedRadio();\r
+       void OnBnClickedOk();\r
+\r
+       CHistoryCombo m_Branch;\r
+       CHistoryCombo m_Tags;\r
+       CHistoryCombo m_Version;\r
+\r
+       DECLARE_MESSAGE_MAP()\r
+public:\r
+       afx_msg void OnBnClickedCheckBranch();\r
+       afx_msg void OnCbnSelchangeComboboxexBranch();\r
+};\r
index db77217..12f3b3a 100644 (file)
@@ -20,6 +20,7 @@
 #include "StandAloneDlg.h"\r
 #include "RegHistory.h"\r
 \r
+#include "HistoryCombo.h"\r
 /**\r
  * \ingroup TortoiseProc\r
  * Dialog showing the log message history.\r
@@ -38,6 +39,9 @@ public:
        // Dialog Data\r
        enum { IDD = IDD_HISTORYDLG };\r
 \r
+       CString m_Version;\r
+       CString m_Title;\r
+\r
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        virtual BOOL OnInitDialog();\r
@@ -50,4 +54,5 @@ private:
        CListBox                m_List;\r
        CString                 m_SelectedText;\r
        CRegHistory*    m_history;\r
+       CHistoryCombo   m_VersionCombo;\r
 };\r
index bebef84..ac19555 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\GitSwitch.cpp"\r
+                               RelativePath=".\GitSwitchDlg.cpp"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\GitSwitch.h"\r
+                               RelativePath=".\GitSwitchDlg.h"\r
                                >\r
                        </File>\r
                        <File\r
index fe10b38..77fc5ca 100644 (file)
@@ -11,7 +11,7 @@
                        <DebugSettings\r
                                Command="$(TargetPath)"\r
                                WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
-                               CommandArguments="/command:merge /path:&quot;D:\\Profiles\\b20596\\buildtest\\TortoiseGit&quot;"\r
+                               CommandArguments="/command:switch /path:&quot;D:\\Profiles\\b20596\\buildtest\\TortoiseGit&quot;"\r
                                Attach="false"\r
                                DebuggerType="3"\r
                                Remote="1"\r
index 089cd60..039b2c9 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ