OSDN Git Service

22bf3a22ff558701d98ead4a33ef43644e49943b
[tortoisegit/TortoiseGitJp.git] / src / 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 \r
26 #include "CreateRepositoryCommand.h"\r
27 #include "CloneCommand.h"\r
28 #include "PrevDiffCommand.h"\r
29 #include "DiffCommand.h"\r
30 \r
31 #include "RenameCommand.h"\r
32 #include "RepoStatusCommand.h"\r
33 \r
34 #include "RevertCommand.h"\r
35 #include "RemoveCommand.h"\r
36 #include "PullCommand.h"\r
37 #include "FetchCommand.h"\r
38 #include "PushCommand.h"\r
39 #include "BranchCommand.h"\r
40 #include "TagCommand.h"\r
41 #include "MergeCommand.h"\r
42 #include "SwitchCommand.h"\r
43 #include "ExportCommand.h"\r
44 #include "AddCommand.h"\r
45 #include "IgnoreCommand.h"\r
46 #include "FormatPatchCommand.h"\r
47 #include "ImportPatchCommand.h"\r
48 #include "BlameCommand.h"\r
49 #include "SettingsCommand.h"\r
50 #include "ConflictEditorCommand.h"\r
51 #include "CleanupCommand.h"\r
52 #include "RebaseCommand.h"\r
53 #include "ResolveCommand.h"\r
54 #include "DropMoveCommand.h"\r
55 #include "DropCopyAddCommand.h"\r
56 #include "DropCopyCommand.h"\r
57 #include "DropExportCommand.h"\r
58 #include "HelpCommand.h"\r
59 #include "StashCommand.h"\r
60 #include "SubmoduleCommand.h"\r
61 #include "ReflogCommand.h"\r
62 #include "SendMailCommand.h"\r
63 #include "CatCommand.h"\r
64 #include "RefBrowseCommand.h"\r
65 #include "SVNDCommitCommand.h"\r
66 #include "SVNRebaseCommand.h"\r
67 \r
68 #if 0\r
69 \r
70 \r
71 \r
72 #include "CheckoutCommand.h"\r
73 \r
74 \r
75 \r
76 #include "CopyCommand.h"\r
77 #include "CrashCommand.h"\r
78 #include "CreatePatchCommand.h"\r
79 \r
80 #include "DelUnversionedCommand.h"\r
81 \r
82 \r
83 \r
84 \r
85 \r
86 \r
87 #include "ImportCommand.h"\r
88 #include "LockCommand.h"\r
89 \r
90 \r
91 #include "MergeAllCommand.h"\r
92 #include "PasteCopyCommand.h"\r
93 #include "PasteMoveCommand.h"\r
94 \r
95 #include "PropertiesCommand.h"\r
96 #include "RebuildIconCacheCommand.h"\r
97 #include "RelocateCommand.h"\r
98 #include "RemoveCommand.h"\r
99 \r
100 #include "RepositoryBrowserCommand.h"\r
101 \r
102 \r
103 #include "RevertCommand.h"\r
104 #include "RevisiongraphCommand.h"\r
105 #include "RTFMCommand.h"\r
106 \r
107 #include "ShowCompareCommand.h"\r
108 \r
109 #include "UnIgnoreCommand.h"\r
110 #include "UnLockCommand.h"\r
111 #include "UpdateCheckCommand.h"\r
112 #include "UpdateCommand.h"\r
113 #include "UrlDiffCommand.h"\r
114 #endif\r
115 typedef enum\r
116 {\r
117         cmdAbout,\r
118         cmdAdd,\r
119         cmdBlame,\r
120         cmdBranch,\r
121         cmdCat,\r
122         cmdCheckout,\r
123         cmdCleanup,\r
124         cmdClone,\r
125         cmdCommit,\r
126         cmdConflictEditor,\r
127         cmdCopy,\r
128         cmdCrash,\r
129         cmdCreatePatch,\r
130         cmdDelUnversioned,\r
131         cmdDiff,\r
132         cmdDropCopy,\r
133         cmdDropCopyAdd,\r
134         cmdDropExport,\r
135         cmdDropMove,\r
136         cmdFetch,\r
137         cmdFormatPatch,\r
138         cmdExport,\r
139         cmdHelp,\r
140         cmdIgnore,\r
141         cmdImport,\r
142         cmdImportPatch,\r
143         cmdLock,\r
144         cmdLog,\r
145         cmdMerge,\r
146         cmdMergeAll,\r
147         cmdPasteCopy,\r
148         cmdPasteMove,\r
149         cmdPrevDiff,\r
150         cmdProperties,\r
151         cmdPull,\r
152         cmdPush,\r
153         cmdRTFM,\r
154         cmdRebuildIconCache,\r
155         cmdRelocate,\r
156         cmdRemove,\r
157         cmdRebase,\r
158         cmdRename,\r
159         cmdRepoBrowser,\r
160         cmdRepoCreate,\r
161         cmdRepoStatus,\r
162         cmdResolve,\r
163         cmdRevert,\r
164         cmdRevisionGraph,\r
165         cmdSendMail,\r
166         cmdSettings,\r
167         cmdShowCompare,\r
168         cmdSwitch,\r
169         cmdTag,\r
170         cmdUnIgnore,\r
171         cmdUnlock,\r
172         cmdUpdate,\r
173         cmdUpdateCheck,\r
174         cmdUrlDiff,     \r
175         cmdStashSave,   \r
176         cmdStashApply,\r
177         cmdStashList,\r
178         cmdSubAdd,              \r
179         cmdSubUpdate,\r
180         cmdSubSync,\r
181         cmdRefLog,\r
182         cmdRefBrowse,\r
183         cmdSVNDCommit,\r
184         cmdSVNRebase,\r
185         \r
186 } TGitCommand;\r
187 \r
188 static const struct CommandInfo\r
189 {\r
190         TGitCommand command;\r
191         LPCTSTR pCommandName;\r
192 } commandInfo[] = \r
193 {\r
194         {       cmdAbout,                       _T("about")                             },\r
195         {       cmdAdd,                         _T("add")                               },\r
196         {       cmdBlame,                       _T("blame")                             },\r
197         {       cmdBranch,                      _T("branch")                    },\r
198         {       cmdCat,                         _T("cat")                               },\r
199         {       cmdCheckout,            _T("checkout")                  },\r
200         {       cmdCleanup,                     _T("cleanup")                   },\r
201         {       cmdClone,                       _T("clone")                             },\r
202         {       cmdCommit,                      _T("commit")                    },\r
203         {       cmdConflictEditor,      _T("conflicteditor")    },\r
204         {       cmdCopy,                        _T("copy")                              },\r
205         {       cmdCrash,                       _T("crash")                             },\r
206         {       cmdCreatePatch,         _T("createpatch")               },\r
207         {       cmdDelUnversioned,      _T("delunversioned")    },\r
208         {       cmdDiff,                        _T("diff")                              },\r
209         {       cmdDropCopy,            _T("dropcopy")                  },\r
210         {       cmdDropCopyAdd,         _T("dropcopyadd")               },\r
211         {       cmdDropExport,          _T("dropexport")                },\r
212         {       cmdDropMove,            _T("dropmove")                  },\r
213         {       cmdFetch,                       _T("fetch")                             },\r
214         {       cmdFormatPatch,         _T("formatpatch")               },\r
215         {       cmdExport,                      _T("export")                    },\r
216         {       cmdHelp,                        _T("help")                              },\r
217         {       cmdIgnore,                      _T("ignore")                    },\r
218         {       cmdImport,                      _T("import")                    },\r
219         {       cmdImportPatch,         _T("importpatch")               },\r
220         {       cmdLock,                        _T("lock")                              },\r
221         {       cmdLog,                         _T("log")                               },\r
222         {       cmdMerge,                       _T("merge")                             },\r
223         {       cmdMergeAll,            _T("mergeall")                  },\r
224         {       cmdPasteCopy,           _T("pastecopy")                 },\r
225         {       cmdPasteMove,           _T("pastemove")                 },\r
226         {       cmdPrevDiff,            _T("prevdiff")                  },\r
227         {       cmdProperties,          _T("properties")                },\r
228         {       cmdPull,                        _T("pull")                              },\r
229         {       cmdPush,                        _T("push")                              },\r
230         {       cmdRTFM,                        _T("rtfm")                              },\r
231         {       cmdRebuildIconCache,_T("rebuildiconcache")      },\r
232         {       cmdRelocate,            _T("relocate")                  },\r
233         {       cmdRemove,                      _T("remove")                    },\r
234         {       cmdRebase,                      _T("rebase")                    },\r
235         {       cmdRename,                      _T("rename")                    },\r
236         {       cmdRepoBrowser,         _T("repobrowser")               },\r
237         {       cmdRepoCreate,          _T("repocreate")                },\r
238         {       cmdRepoStatus,          _T("repostatus")                },\r
239         {       cmdResolve,                     _T("resolve")                   },\r
240         {       cmdRevert,                      _T("revert")                    },\r
241         {       cmdRevisionGraph,       _T("revisiongraph")             },\r
242         {       cmdSendMail,            _T("sendmail")                  },\r
243         {       cmdSettings,            _T("settings")                  },\r
244         {       cmdShowCompare,         _T("showcompare")               },\r
245         {       cmdSwitch,                      _T("switch")                    },\r
246         {       cmdTag,                         _T("tag")                               },\r
247         {       cmdUnIgnore,            _T("unignore")                  },\r
248         {       cmdUnlock,                      _T("unlock")                    },\r
249         {       cmdUpdate,                      _T("update")                    },\r
250         {       cmdUpdateCheck,         _T("updatecheck")               },\r
251         {       cmdUrlDiff,                     _T("urldiff")                   },\r
252         {       cmdStashSave,           _T("stashsave")                 },\r
253         {       cmdStashApply,          _T("stashapply")                },\r
254         {       cmdStashList,           _T("stashlist")                 },\r
255         {       cmdSubAdd,                      _T("subadd")                    },\r
256         {       cmdSubUpdate,           _T("subupdate")                 },\r
257         {       cmdSubSync,                     _T("subsync")                   },\r
258         {       cmdRefLog,                      _T("reflog")                    },\r
259         {       cmdRefBrowse,           _T("refbrowse")                 },\r
260         {       cmdSVNDCommit,          _T("svndcommit")                },\r
261         {       cmdSVNRebase,           _T("svnrebase")                 },\r
262 };\r
263 \r
264 \r
265 Command * CommandServer::GetCommand(const CString& sCmd)\r
266 {\r
267         // Look up the command\r
268         TGitCommand command = cmdAbout;         // Something harmless as a default\r
269         for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)\r
270         {\r
271                 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)\r
272                 {\r
273                         // We've found the command\r
274                         command = commandInfo[nCommand].command;\r
275                         // If this fires, you've let the enum get out of sync with the commandInfo array\r
276                         ASSERT((int)command == nCommand);\r
277                         break;\r
278                 }\r
279         }\r
280 \r
281                 \r
282         // CBrowseRefsDlg dialog\r
283 \r
284 \r
285         switch (command)\r
286         {\r
287         case cmdAbout:\r
288                 return new AboutCommand;        \r
289         case cmdCommit:\r
290                 return new CommitCommand;\r
291         case cmdLog:\r
292                 return new LogCommand;\r
293         case cmdRepoCreate:\r
294                 return new CreateRepositoryCommand;\r
295         case cmdClone:\r
296                 return new CloneCommand;\r
297         case cmdPrevDiff:\r
298                 return new PrevDiffCommand;\r
299         case cmdDiff:\r
300                 return new DiffCommand;\r
301         case cmdRename:\r
302                 return new RenameCommand;\r
303         case cmdRepoStatus:\r
304                 return new RepoStatusCommand;\r
305         case cmdRemove:\r
306                 return new RemoveCommand;\r
307         case cmdRevert:\r
308                 return new RevertCommand;\r
309         case cmdPull:\r
310                 return new PullCommand;\r
311         case cmdFetch:\r
312                 return new FetchCommand;\r
313         case cmdPush:\r
314                 return new PushCommand;\r
315         case cmdBranch:\r
316                 return new BranchCommand;\r
317         case cmdTag:\r
318                 return new TagCommand;\r
319         case cmdMerge:\r
320                 return new MergeCommand;\r
321         case cmdSwitch:\r
322                 return new SwitchCommand;\r
323         case cmdExport:\r
324                 return new ExportCommand;\r
325         case cmdAdd:\r
326                 return new AddCommand;\r
327         case cmdIgnore:\r
328                 return new IgnoreCommand;\r
329         case cmdFormatPatch:\r
330                 return new FormatPatchCommand;\r
331         case cmdImportPatch:\r
332                 return new ImportPatchCommand;\r
333         case cmdBlame:\r
334                 return new BlameCommand;\r
335         case cmdSettings:\r
336                 return new SettingsCommand;\r
337         case cmdConflictEditor:\r
338                 return new ConflictEditorCommand;\r
339         case cmdCleanup:\r
340                 return new CleanupCommand;\r
341         case cmdRebase:\r
342                 return new RebaseCommand;\r
343         case cmdResolve:\r
344                 return new ResolveCommand;\r
345         case cmdDropMove:\r
346                 return new DropMoveCommand;\r
347 //      case cmdDropCopy:\r
348 //              return new DropCopyCommand;\r
349 //      case cmdDropCopyAdd:\r
350 //              return new DropCopyAddCommand;\r
351 //      case cmdDropExport:\r
352 //              return new DropExportCommand;\r
353         case cmdHelp:\r
354                 return new HelpCommand;\r
355         case cmdStashSave:\r
356                 return new StashSaveCommand;\r
357         case cmdStashApply:\r
358                 return new StashApplyCommand;\r
359         case cmdSubAdd:\r
360                 return new SubmoduleAddCommand;\r
361         case cmdSubUpdate:\r
362                 return new SubmoduleUpdateCommand;\r
363         case cmdRefLog:\r
364                 return new RefLogCommand;\r
365         case cmdSubSync:\r
366                 return new SubmoduleSyncCommand;\r
367         case cmdSendMail:\r
368                 return new SendMailCommand;\r
369         case cmdCat:\r
370                 return new CatCommand;\r
371         case cmdRefBrowse:\r
372                 return new RefBrowseCommand;\r
373         case cmdSVNDCommit:\r
374                 return new SVNDCommitCommand;\r
375         case cmdSVNRebase:\r
376                 return new SVNRebaseCommand;\r
377 #if 0\r
378 \r
379         \r
380         case cmdCheckout:\r
381                 return new CheckoutCommand;\r
382 \r
383 \r
384         \r
385         case cmdCopy:\r
386                 return new CopyCommand;\r
387         case cmdCrash:\r
388                 return new CrashCommand;\r
389         case cmdCreatePatch:\r
390                 return new CreatePatchCommand;\r
391         case cmdDelUnversioned:\r
392                 return new DelUnversionedCommand;\r
393 \r
394 \r
395 \r
396         case cmdImport:\r
397                 return new ImportCommand;\r
398         case cmdLock:\r
399                 return new LockCommand;\r
400         case cmdMergeAll:\r
401                 return new MergeAllCommand;\r
402         case cmdPasteCopy:\r
403                 return new PasteCopyCommand;\r
404         case cmdPasteMove:\r
405                 return new PasteMoveCommand;\r
406         case cmdPrevDiff:\r
407                 return new PrevDiffCommand;\r
408         case cmdProperties:\r
409                 return new PropertiesCommand;\r
410         case cmdRTFM:\r
411                 return new RTFMCommand;\r
412         case cmdRebuildIconCache:\r
413                 return new RebuildIconCacheCommand;\r
414         case cmdRelocate:\r
415                 return new RelocateCommand;\r
416         case cmdRepoBrowser:\r
417                 return new RepositoryBrowserCommand;\r
418         case cmdRevisionGraph:\r
419                 return new RevisionGraphCommand;\r
420         case cmdShowCompare:\r
421                 return new ShowCompareCommand;\r
422         case cmdUnIgnore:\r
423                 return new UnIgnoreCommand;\r
424         case cmdUnlock:\r
425                 return new UnLockCommand;\r
426         case cmdUpdate:\r
427                 return new UpdateCommand;\r
428         case cmdUpdateCheck:\r
429                 return new UpdateCheckCommand;\r
430         case cmdUrlDiff:\r
431                 return new UrlDiffCommand;\r
432 #endif\r
433         default:\r
434                 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);\r
435                 return new AboutCommand;\r
436         }\r
437 }\r