OSDN Git Service

Build TortoiseProc Success
[tortoisegit/TortoiseGitJp.git] / TortoiseProc / Commands / Command.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 "Command.h"\r
21 \r
22 #include "AboutCommand.h"\r
23 #if 0\r
24 #include "AddCommand.h"\r
25 #include "BlameCommand.h"\r
26 #include "CatCommand.h"\r
27 #include "CheckoutCommand.h"\r
28 #include "CleanupCommand.h"\r
29 #include "CommitCommand.h"\r
30 #include "ConflictEditorCommand.h"\r
31 #include "CopyCommand.h"\r
32 #include "CrashCommand.h"\r
33 #include "CreatePatchCommand.h"\r
34 #include "CreateRepositoryCommand.h"\r
35 #include "DelUnversionedCommand.h"\r
36 #include "DiffCommand.h"\r
37 #include "DropCopyAddCommand.h"\r
38 #include "DropCopyCommand.h"\r
39 #include "DropExportCommand.h"\r
40 #include "DropMoveCommand.h"\r
41 #include "ExportCommand.h"\r
42 #include "HelpCommand.h"\r
43 #include "IgnoreCommand.h"\r
44 #include "ImportCommand.h"\r
45 #include "LockCommand.h"\r
46 #include "LogCommand.h"\r
47 #include "MergeCommand.h"\r
48 #include "MergeAllCommand.h"\r
49 #include "PasteCopyCommand.h"\r
50 #include "PasteMoveCommand.h"\r
51 #include "PrevDiffCommand.h"\r
52 #include "PropertiesCommand.h"\r
53 #include "RebuildIconCacheCommand.h"\r
54 #include "RelocateCommand.h"\r
55 #include "RemoveCommand.h"\r
56 #include "RenameCommand.h"\r
57 #include "RepositoryBrowserCommand.h"\r
58 #include "RepoStatusCommand.h"\r
59 #include "ResolveCommand.h"\r
60 #include "RevertCommand.h"\r
61 #include "RevisiongraphCommand.h"\r
62 #include "RTFMCommand.h"\r
63 #include "SettingsCommand.h"\r
64 #include "ShowCompareCommand.h"\r
65 #include "SwitchCommand.h"\r
66 #include "UnIgnoreCommand.h"\r
67 #include "UnLockCommand.h"\r
68 #include "UpdateCheckCommand.h"\r
69 #include "UpdateCommand.h"\r
70 #include "UrlDiffCommand.h"\r
71 #endif\r
72 typedef enum\r
73 {\r
74         cmdAbout,\r
75         cmdAdd,\r
76         cmdBlame,\r
77         cmdCat,\r
78         cmdCheckout,\r
79         cmdCleanup,\r
80         cmdCommit,\r
81         cmdConflictEditor,\r
82         cmdCopy,\r
83         cmdCrash,\r
84         cmdCreatePatch,\r
85         cmdDelUnversioned,\r
86         cmdDiff,\r
87         cmdDropCopy,\r
88         cmdDropCopyAdd,\r
89         cmdDropExport,\r
90         cmdDropMove,\r
91         cmdExport,\r
92         cmdHelp,\r
93         cmdIgnore,\r
94         cmdImport,\r
95         cmdLock,\r
96         cmdLog,\r
97         cmdMerge,\r
98         cmdMergeAll,\r
99         cmdPasteCopy,\r
100         cmdPasteMove,\r
101         cmdPrevDiff,\r
102         cmdProperties,\r
103         cmdRTFM,\r
104         cmdRebuildIconCache,\r
105         cmdRelocate,\r
106         cmdRemove,\r
107         cmdRename,\r
108         cmdRepoBrowser,\r
109         cmdRepoCreate,\r
110         cmdRepoStatus,\r
111         cmdResolve,\r
112         cmdRevert,\r
113         cmdRevisionGraph,\r
114         cmdSettings,\r
115         cmdShowCompare,\r
116         cmdSwitch,\r
117         cmdUnIgnore,\r
118         cmdUnlock,\r
119         cmdUpdate,\r
120         cmdUpdateCheck,\r
121         cmdUrlDiff,\r
122 } TGitCommand;\r
123 \r
124 static const struct CommandInfo\r
125 {\r
126         TGitCommand command;\r
127         LPCTSTR pCommandName;\r
128 } commandInfo[] = \r
129 {\r
130         {       cmdAbout,                       _T("about")                             },\r
131         {       cmdAdd,                         _T("add")                               },\r
132         {       cmdBlame,                       _T("blame")                             },\r
133         {       cmdCat,                         _T("cat")                               },\r
134         {       cmdCheckout,            _T("checkout")                  },\r
135         {       cmdCleanup,                     _T("cleanup")                   },\r
136         {       cmdCommit,                      _T("commit")                    },\r
137         {       cmdConflictEditor,      _T("conflicteditor")    },\r
138         {       cmdCopy,                        _T("copy")                              },\r
139         {       cmdCrash,                       _T("crash")                             },\r
140         {       cmdCreatePatch,         _T("createpatch")               },\r
141         {       cmdDelUnversioned,      _T("delunversioned")    },\r
142         {       cmdDiff,                        _T("diff")                              },\r
143         {       cmdDropCopy,            _T("dropcopy")                  },\r
144         {       cmdDropCopyAdd,         _T("dropcopyadd")               },\r
145         {       cmdDropExport,          _T("dropexport")                },\r
146         {       cmdDropMove,            _T("dropmove")                  },\r
147         {       cmdExport,                      _T("export")                    },\r
148         {       cmdHelp,                        _T("help")                              },\r
149         {       cmdIgnore,                      _T("ignore")                    },\r
150         {       cmdImport,                      _T("import")                    },\r
151         {       cmdLock,                        _T("lock")                              },\r
152         {       cmdLog,                         _T("log")                               },\r
153         {       cmdMerge,                       _T("merge")                             },\r
154         {       cmdMergeAll,            _T("mergeall")                  },\r
155         {       cmdPasteCopy,           _T("pastecopy")                 },\r
156         {       cmdPasteMove,           _T("pastemove")                 },\r
157         {       cmdPrevDiff,            _T("prevdiff")                  },\r
158         {       cmdProperties,          _T("properties")                },\r
159         {       cmdRTFM,                        _T("rtfm")                              },\r
160         {       cmdRebuildIconCache,_T("rebuildiconcache")      },\r
161         {       cmdRelocate,            _T("relocate")                  },\r
162         {       cmdRemove,                      _T("remove")                    },\r
163         {       cmdRename,                      _T("rename")                    },\r
164         {       cmdRepoBrowser,         _T("repobrowser")               },\r
165         {       cmdRepoCreate,          _T("repocreate")                },\r
166         {       cmdRepoStatus,          _T("repostatus")                },\r
167         {       cmdResolve,                     _T("resolve")                   },\r
168         {       cmdRevert,                      _T("revert")                    },\r
169         {       cmdRevisionGraph,       _T("revisiongraph")             },\r
170         {       cmdSettings,            _T("settings")                  },\r
171         {       cmdShowCompare,         _T("showcompare")               },\r
172         {       cmdSwitch,                      _T("switch")                    },\r
173         {       cmdUnIgnore,            _T("unignore")                  },\r
174         {       cmdUnlock,                      _T("unlock")                    },\r
175         {       cmdUpdate,                      _T("update")                    },\r
176         {       cmdUpdateCheck,         _T("updatecheck")               },\r
177         {       cmdUrlDiff,                     _T("urldiff")                   },\r
178 };\r
179 \r
180 \r
181 \r
182 \r
183 Command * CommandServer::GetCommand(const CString& sCmd)\r
184 {\r
185         // Look up the command\r
186         TGitCommand command = cmdAbout;         // Something harmless as a default\r
187         for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)\r
188         {\r
189                 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)\r
190                 {\r
191                         // We've found the command\r
192                         command = commandInfo[nCommand].command;\r
193                         // If this fires, you've let the enum get out of sync with the commandInfo array\r
194                         ASSERT((int)command == nCommand);\r
195                         break;\r
196                 }\r
197         }\r
198 \r
199 \r
200 \r
201         switch (command)\r
202         {\r
203         case cmdAbout:\r
204                 return new AboutCommand;\r
205 #if 0\r
206         case cmdAdd:\r
207                 return new AddCommand;\r
208         case cmdBlame:\r
209                 return new BlameCommand;\r
210         case cmdCat:\r
211                 return new CatCommand;\r
212         case cmdCheckout:\r
213                 return new CheckoutCommand;\r
214         case cmdCleanup:\r
215                 return new CleanupCommand;\r
216         case cmdCommit:\r
217                 return new CommitCommand;\r
218         case cmdConflictEditor:\r
219                 return new ConflictEditorCommand;\r
220         case cmdCopy:\r
221                 return new CopyCommand;\r
222         case cmdCrash:\r
223                 return new CrashCommand;\r
224         case cmdCreatePatch:\r
225                 return new CreatePatchCommand;\r
226         case cmdDelUnversioned:\r
227                 return new DelUnversionedCommand;\r
228         case cmdDiff:\r
229                 return new DiffCommand;\r
230         case cmdDropCopy:\r
231                 return new DropCopyCommand;\r
232         case cmdDropCopyAdd:\r
233                 return new DropCopyAddCommand;\r
234         case cmdDropExport:\r
235                 return new DropExportCommand;\r
236         case cmdDropMove:\r
237                 return new DropMoveCommand;\r
238         case cmdExport:\r
239                 return new ExportCommand;\r
240         case cmdHelp:\r
241                 return new HelpCommand;\r
242         case cmdIgnore:\r
243                 return new IgnoreCommand;\r
244         case cmdImport:\r
245                 return new ImportCommand;\r
246         case cmdLock:\r
247                 return new LockCommand;\r
248         case cmdLog:\r
249                 return new LogCommand;\r
250         case cmdMerge:\r
251                 return new MergeCommand;\r
252         case cmdMergeAll:\r
253                 return new MergeAllCommand;\r
254         case cmdPasteCopy:\r
255                 return new PasteCopyCommand;\r
256         case cmdPasteMove:\r
257                 return new PasteMoveCommand;\r
258         case cmdPrevDiff:\r
259                 return new PrevDiffCommand;\r
260         case cmdProperties:\r
261                 return new PropertiesCommand;\r
262         case cmdRTFM:\r
263                 return new RTFMCommand;\r
264         case cmdRebuildIconCache:\r
265                 return new RebuildIconCacheCommand;\r
266         case cmdRelocate:\r
267                 return new RelocateCommand;\r
268         case cmdRemove:\r
269                 return new RemoveCommand;\r
270         case cmdRename:\r
271                 return new RenameCommand;\r
272         case cmdRepoBrowser:\r
273                 return new RepositoryBrowserCommand;\r
274         case cmdRepoCreate:\r
275                 return new CreateRepositoryCommand;\r
276         case cmdRepoStatus:\r
277                 return new RepoStatusCommand;\r
278         case cmdResolve:\r
279                 return new ResolveCommand;\r
280         case cmdRevert:\r
281                 return new RevertCommand;\r
282         case cmdRevisionGraph:\r
283                 return new RevisionGraphCommand;\r
284         case cmdSettings:\r
285                 return new SettingsCommand;\r
286         case cmdShowCompare:\r
287                 return new ShowCompareCommand;\r
288         case cmdSwitch:\r
289                 return new SwitchCommand;\r
290         case cmdUnIgnore:\r
291                 return new UnIgnoreCommand;\r
292         case cmdUnlock:\r
293                 return new UnLockCommand;\r
294         case cmdUpdate:\r
295                 return new UpdateCommand;\r
296         case cmdUpdateCheck:\r
297                 return new UpdateCheckCommand;\r
298         case cmdUrlDiff:\r
299                 return new UrlDiffCommand;\r
300 #endif\r
301         default:\r
302                 return new AboutCommand;\r
303         }\r
304 }\r