OSDN Git Service

Add Patch Import Command (git am)
authorFrank Li <lznuaa@gmail.com>
Thu, 25 Dec 2008 09:11:03 +0000 (17:11 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 25 Dec 2008 09:11:03 +0000 (17:11 +0800)
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/Commands/ImportPatchCommand.cpp [new file with mode: 0644]
src/TortoiseProc/Commands/ImportPatchCommand.h [new file with mode: 0644]
src/TortoiseProc/ImportPatchDlg.cpp [new file with mode: 0644]
src/TortoiseProc/ImportPatchDlg.h [new file with mode: 0644]
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user
src/TortoiseProc/resource.h

index 0ba5376..6b9d03b 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 162c62e..a9e6f34 100644 (file)
@@ -44,6 +44,8 @@
 #include "AddCommand.h"\r
 #include "IgnoreCommand.h"\r
 #include "FormatPatchCommand.h"\r
+#include "ImportPatchCommand.h"\r
+\r
 \r
 #if 0\r
 \r
@@ -121,6 +123,7 @@ typedef enum
        cmdHelp,\r
        cmdIgnore,\r
        cmdImport,\r
+       cmdImportPatch,\r
        cmdLock,\r
        cmdLog,\r
        cmdMerge,\r
@@ -185,6 +188,7 @@ static const struct CommandInfo
        {       cmdHelp,                        _T("help")                              },\r
        {       cmdIgnore,                      _T("ignore")                    },\r
        {       cmdImport,                      _T("import")                    },\r
+       {       cmdImportPatch,         _T("importpatch")               },\r
        {       cmdLock,                        _T("lock")                              },\r
        {       cmdLog,                         _T("log")                               },\r
        {       cmdMerge,                       _T("merge")                             },\r
@@ -284,6 +288,8 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new IgnoreCommand;\r
        case cmdFormatPatch:\r
                return new FormatPatchCommand;\r
+       case cmdImportPatch:\r
+               return new ImportPatchCommand;\r
 \r
 #if 0\r
 \r
diff --git a/src/TortoiseProc/Commands/ImportPatchCommand.cpp b/src/TortoiseProc/Commands/ImportPatchCommand.cpp
new file mode 100644 (file)
index 0000000..67b6570
--- /dev/null
@@ -0,0 +1,49 @@
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2007-2008 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#include "StdAfx.h"\r
+#include "ImportPatchCommand.h"\r
+\r
+#include "MessageBox.h"\r
+#include "ImportPatchDlg.h"\r
+#include "InputLogDlg.h"\r
+#include "Git.h"\r
+#include "DirFileEnum.h"\r
+#include "ShellUpdater.h"\r
+\r
+bool ImportPatchCommand::Execute()\r
+{\r
+       CImportPatchDlg dlg;\r
+//     dlg.m_bIsTag=TRUE;\r
+       CString cmd;\r
+       if(dlg.DoModal()==IDOK)\r
+       {\r
+               for(int i=0;i<dlg.m_PathList.GetCount();i++)\r
+               {                       \r
+                       cmd.Format(_T("git.exe am \"%s\""),dlg.m_PathList[i].GetGitPathString());\r
+                       CString output;\r
+                       if(g_Git.Run(cmd,&output))\r
+                       {\r
+                               CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK);\r
+                               return FALSE;\r
+                       }\r
+               }\r
+               return TRUE;\r
+       }\r
+       return FALSE;\r
+}\r
diff --git a/src/TortoiseProc/Commands/ImportPatchCommand.h b/src/TortoiseProc/Commands/ImportPatchCommand.h
new file mode 100644 (file)
index 0000000..7a6494e
--- /dev/null
@@ -0,0 +1,35 @@
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2007 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+#include "Command.h"\r
+\r
+/**\r
+ * \ingroup TortoiseProc\r
+ * Renames files and folders.\r
+ */\r
+class ImportPatchCommand : public Command\r
+{\r
+public:\r
+       /**\r
+        * Executes the command.\r
+        */\r
+       virtual bool                    Execute();\r
+};\r
+\r
+\r
diff --git a/src/TortoiseProc/ImportPatchDlg.cpp b/src/TortoiseProc/ImportPatchDlg.cpp
new file mode 100644 (file)
index 0000000..8503a3a
--- /dev/null
@@ -0,0 +1,157 @@
+// ImportPatchDlg.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "TortoiseProc.h"\r
+#include "ImportPatchDlg.h"\r
+\r
+\r
+// CImportPatchDlg dialog\r
+\r
+IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)\r
+\r
+CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)\r
+       : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)\r
+{\r
+\r
+}\r
+\r
+CImportPatchDlg::~CImportPatchDlg()\r
+{\r
+\r
+}\r
+\r
+void CImportPatchDlg::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       CDialog::DoDataExchange(pDX);\r
+       DDX_Control(pDX, IDC_LIST_PATCH,m_cList);\r
+}\r
+\r
+BOOL CImportPatchDlg::OnInitDialog()\r
+{\r
+       CResizableStandAloneDialog::OnInitDialog();\r
+\r
+       AddAnchor(IDC_LIST_PATCH, TOP_LEFT, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_BUTTON_ADD, TOP_RIGHT);\r
+       AddAnchor(IDC_BUTTON_UP, TOP_RIGHT);\r
+       AddAnchor(IDC_BUTTON_DOWN, TOP_RIGHT);\r
+       AddAnchor(IDC_BUTTON_REMOVE, TOP_RIGHT);\r
+\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+\r
+\r
+       return TRUE;\r
+}\r
+\r
+BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)\r
+       ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)\r
+       ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)\r
+       ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)\r
+       ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)\r
+       ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)\r
+       ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)\r
+END_MESSAGE_MAP()\r
+\r
+\r
+// CImportPatchDlg message handlers\r
+\r
+void CImportPatchDlg::OnLbnSelchangeListPatch()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       if(m_cList.GetSelectedCount() == 0)\r
+       {\r
+               this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);\r
+       }else\r
+       {\r
+               this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);\r
+\r
+       }\r
+\r
+}\r
+\r
+void CImportPatchDlg::OnBnClickedButtonAdd()\r
+{\r
+       \r
+       CFileDialog dlg(TRUE,NULL,\r
+                                       NULL,\r
+                                       OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,\r
+                                       _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));\r
+       if(dlg.DoModal()==IDOK)\r
+       {\r
+               POSITION pos;\r
+               pos=dlg.GetStartPosition();\r
+               while(pos)\r
+               {\r
+                       m_cList.InsertItem(0,dlg.GetNextPathName(pos));\r
+               }\r
+       }\r
+\r
+       // TODO: Add your control notification handler code here\r
+}\r
+\r
+void CImportPatchDlg::OnBnClickedButtonUp()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       POSITION pos;\r
+       pos=m_cList.GetFirstSelectedItemPosition();\r
+       while(pos)\r
+       {\r
+               int index=m_cList.GetNextSelectedItem(pos);\r
+               if(index>1)\r
+               {\r
+                       CString old=m_cList.GetItemText(index,0);\r
+                       m_cList.DeleteItem(index);\r
+\r
+                       m_cList.InsertItem(index-1,old);\r
+               }\r
+       }\r
+\r
+}\r
+\r
+void CImportPatchDlg::OnBnClickedButtonDown()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       POSITION pos;\r
+       pos=m_cList.GetFirstSelectedItemPosition();\r
+       while(pos)\r
+       {\r
+               int index=m_cList.GetNextSelectedItem(pos);\r
+               \r
+               CString old=m_cList.GetItemText(index,0);\r
+               m_cList.DeleteItem(index);\r
+\r
+               m_cList.InsertItem(index+1,old);\r
+               \r
+       }\r
+}\r
+\r
+void CImportPatchDlg::OnBnClickedButtonRemove()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       POSITION pos;\r
+       pos=m_cList.GetFirstSelectedItemPosition();\r
+       while(pos)\r
+       {\r
+               int index=m_cList.GetNextSelectedItem(pos);\r
+               m_cList.DeleteItem(index);\r
+               pos=m_cList.GetFirstSelectedItemPosition();\r
+       }\r
+}\r
+\r
+void CImportPatchDlg::OnBnClickedOk()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       int i;\r
+       for(int i=0;i<m_cList.GetItemCount();i++)\r
+       {\r
+               CTGitPath path;\r
+               path.SetFromWin(m_cList.GetItemText(i,0));\r
+               m_PathList.AddPath(path);\r
+       }\r
+       OnOK();\r
+}\r
diff --git a/src/TortoiseProc/ImportPatchDlg.h b/src/TortoiseProc/ImportPatchDlg.h
new file mode 100644 (file)
index 0000000..ceab47e
--- /dev/null
@@ -0,0 +1,33 @@
+#pragma once\r
+\r
+#include "StandAloneDlg.h"\r
+// CImportPatchDlg dialog\r
+#include "TGitPath.h"\r
+\r
+class CImportPatchDlg : public CResizableStandAloneDialog\r
+{\r
+       DECLARE_DYNAMIC(CImportPatchDlg)\r
+\r
+public:\r
+       CImportPatchDlg(CWnd* pParent = NULL);   // standard constructor\r
+       virtual ~CImportPatchDlg();\r
+\r
+// Dialog Data\r
+       enum { IDD = IDD_APPLY_PATCH_LIST };\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+       virtual BOOL OnInitDialog();\r
+\r
+       CListCtrl m_cList;\r
+       DECLARE_MESSAGE_MAP()\r
+public:\r
+       afx_msg void OnLbnSelchangeListPatch();\r
+       afx_msg void OnBnClickedButtonAdd();\r
+       afx_msg void OnBnClickedButtonUp();\r
+       afx_msg void OnBnClickedButtonDown();\r
+       afx_msg void OnBnClickedButtonRemove();\r
+       afx_msg void OnBnClickedOk();\r
+\r
+       CTGitPathList m_PathList;\r
+};\r
index a9e3f61..f24f034 100644 (file)
                                        RelativePath=".\Commands\FormatPatchCommand.h"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath=".\Commands\ImportPatchCommand.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\Commands\ImportPatchCommand.h"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                </Filter>\r
                <Filter\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\ImportPatchDlg.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\ImportPatchDlg.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\MergeDlg.cpp"\r
                                >\r
                        </File>\r
index c0d2327..054e486 100644 (file)
@@ -11,7 +11,7 @@
                        <DebugSettings\r
                                Command="$(TargetPath)"\r
                                WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
-                               CommandArguments="/command:formatpatch /path:&quot;D:\\Profiles\\b20596\\buildtest\\TortoiseGit&quot;"\r
+                               CommandArguments="/command:importpatch /path:&quot;D:\\Profiles\\b20596\\buildtest\\TortoiseGit&quot;"\r
                                Attach="false"\r
                                DebuggerType="3"\r
                                Remote="1"\r
index 6e8bb78..b5807ac 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ