OSDN Git Service

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