OSDN Git Service

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