OSDN Git Service

Fixed Issue #135: Taskbar text says "TortoiseSVN"
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / IgnoreCommand.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 "IgnoreCommand.h"\r
21 \r
22 #include "MessageBox.h"\r
23 #include "PathUtils.h"\r
24 #include "AppUtils.h"\r
25 //#include "SVNProperties.h"\r
26 \r
27 bool IgnoreCommand::Execute()\r
28 {\r
29         bool bmask=false;\r
30         \r
31         if(parser.HasKey(_T("onlymask")))\r
32         {\r
33                 bmask=true;\r
34         }\r
35 \r
36         if(CAppUtils::IgnoreFile(pathList,bmask))\r
37                 return false;\r
38 \r
39         return true;\r
40 #if 0\r
41         CString filelist;\r
42         BOOL err = FALSE;\r
43         for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
44         {\r
45                 CString name = CPathUtils::PathPatternEscape(pathList[nPath].GetFileOrDirectoryName());\r
46                 if (parser.HasKey(_T("onlymask")))\r
47                 {\r
48                         name = _T("*")+pathList[nPath].GetFileExtension();\r
49                 }\r
50                 filelist += name + _T("\n");\r
51                 CTSVNPath parentfolder = pathList[nPath].GetContainingDirectory();\r
52                 SVNProperties props(parentfolder, SVNRev::REV_WC, false);\r
53                 CStringA value;\r
54                 for (int i=0; i<props.GetCount(); i++)\r
55                 {\r
56                         CString propname(props.GetItemName(i).c_str());\r
57                         if (propname.CompareNoCase(_T("svn:ignore"))==0)\r
58                         {\r
59                                 //treat values as normal text even if they're not\r
60                                 value = (char *)props.GetItemValue(i).c_str();\r
61                         }\r
62                 }\r
63                 if (value.IsEmpty())\r
64                         value = name;\r
65                 else\r
66                 {\r
67                         // make sure we don't have duplicate entries\r
68                         std::set<CStringA> ignoreItems;\r
69                         ignoreItems.insert(CUnicodeUtils::GetUTF8(name));\r
70                         CStringA token;\r
71                         int curPos = 0;\r
72                         token= value.Tokenize("\n",curPos);\r
73                         while (token != _T(""))\r
74                         {\r
75                                 token.Trim();\r
76                                 ignoreItems.insert(token);\r
77                                 token = value.Tokenize("\n", curPos);\r
78                         };\r
79                         value.Empty();\r
80                         for (std::set<CStringA>::iterator it = ignoreItems.begin(); it != ignoreItems.end(); ++it)\r
81                         {\r
82                                 value += *it;\r
83                                 value += "\n";\r
84                         }\r
85                 }\r
86                 if (!props.Add(_T("svn:ignore"), (LPCSTR)value))\r
87                 {\r
88                         CString temp;\r
89                         temp.Format(IDS_ERR_FAILEDIGNOREPROPERTY, (LPCTSTR)name);\r
90                         temp += _T("\n");\r
91                         temp += props.GetLastErrorMsg().c_str();\r
92                         CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);\r
93                         err = TRUE;\r
94                         break;\r
95                 }\r
96         }\r
97         if (err == FALSE)\r
98         {\r
99                 CString temp;\r
100                 temp.Format(IDS_PROC_IGNORESUCCESS, (LPCTSTR)filelist);\r
101                 CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONINFORMATION);\r
102                 return true;\r
103         }\r
104 #endif\r
105 }