OSDN Git Service

Add Shell Notification at add, cleanup and remove and rename, CommitDlg.cpp
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / AddCommand.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "StdAfx.h"\r
20 #include "AddCommand.h"\r
21 \r
22 #include "AddDlg.h"\r
23 #include "SVNProgressDlg.h"\r
24 #include "ShellUpdater.h"\r
25 #include "messagebox.h"\r
26 \r
27 bool AddCommand::Execute()\r
28 {\r
29         bool bRet = false;\r
30         if (parser.HasKey(_T("noui")))\r
31         {\r
32 #if 0\r
33                 SVN svn;\r
34                 ProjectProperties props;\r
35                 props.ReadPropsPathList(pathList);\r
36                 bRet = !!svn.Add(pathList, &props, svn_depth_empty, FALSE, FALSE, TRUE);\r
37                 CShellUpdater::Instance().AddPathsForUpdate(pathList);\r
38 #endif\r
39         }\r
40         else\r
41         {\r
42 #if 0\r
43                 if (pathList.AreAllPathsFiles())\r
44                 {\r
45                         SVN svn;\r
46                         ProjectProperties props;\r
47                         props.ReadPropsPathList(pathList);\r
48                         bRet = !!svn.Add(pathList, &props, svn_depth_empty, FALSE, FALSE, TRUE);\r
49                         CShellUpdater::Instance().AddPathsForUpdate(pathList);\r
50                 }\r
51                 else\r
52                 {\r
53 #endif\r
54                         CAddDlg dlg;\r
55                         dlg.m_pathList = pathList;\r
56                         if (dlg.DoModal() == IDOK)\r
57                         {\r
58 #if 0\r
59                                 CString cmd,out;\r
60                                 int success=0;\r
61                                 for(int i=0;i<dlg.m_pathList.GetCount();i++)\r
62                                 {\r
63                                         cmd.Format(_T("git.exe add \"%s\""),dlg.m_pathList[i].GetGitPathString());\r
64                                         if(g_Git.Run(cmd,&out,CP_OEMCP))\r
65                                         {\r
66                                                 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
67                                         }\r
68                                         success++;\r
69                                 }\r
70                                 CString message;\r
71                                 message.Format(_T("%d file added"),success);\r
72                                 CMessageBox::Show(NULL,message,_T("TortoiseGit"),MB_OK);\r
73                                 return TRUE;\r
74 #endif\r
75 \r
76                                 if (dlg.m_pathList.GetCount() == 0)\r
77                                         return FALSE;\r
78                                 CGitProgressDlg progDlg;\r
79                                 theApp.m_pMainWnd = &progDlg;\r
80                                 progDlg.SetCommand(CGitProgressDlg::GitProgress_Add);\r
81                                 if (parser.HasVal(_T("closeonend")))\r
82                                         progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
83                                 progDlg.SetPathList(dlg.m_pathList);\r
84                                 //ProjectProperties props;\r
85                                 //props.ReadPropsPathList(dlg.m_pathList);\r
86                                 //progDlg.SetProjectProperties(props);\r
87                                 progDlg.SetItemCount(dlg.m_pathList.GetCount());\r
88                                 progDlg.DoModal();\r
89 \r
90                                 CShellUpdater::Instance().AddPathsForUpdate(dlg.m_pathList);\r
91 \r
92                                 bRet = !progDlg.DidErrorsOccur();\r
93 \r
94                         }\r
95         //      }\r
96         }\r
97         CShellUpdater::Instance().Flush();\r
98         return bRet;\r
99 }\r