OSDN Git Service

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