OSDN Git Service

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