Initial version of BrowseRefsDlg
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob62d0ceffc94cad0c3e419d1f8c73f7f1110d39d3
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "Command.h"
22 #include "AboutCommand.h"
23 #include "CommitCommand.h"
24 #include "LogCommand.h"
26 #include "CreateRepositoryCommand.h"
27 #include "CloneCommand.h"
28 #include "PrevDiffCommand.h"
29 #include "DiffCommand.h"
31 #include "RenameCommand.h"
32 #include "RepoStatusCommand.h"
34 #include "RevertCommand.h"
35 #include "RemoveCommand.h"
36 #include "PullCommand.h"
37 #include "FetchCommand.h"
38 #include "PushCommand.h"
39 #include "BranchCommand.h"
40 #include "TagCommand.h"
41 #include "MergeCommand.h"
42 #include "SwitchCommand.h"
43 #include "ExportCommand.h"
44 #include "AddCommand.h"
45 #include "IgnoreCommand.h"
46 #include "FormatPatchCommand.h"
47 #include "ImportPatchCommand.h"
48 #include "BlameCommand.h"
49 #include "SettingsCommand.h"
50 #include "ConflictEditorCommand.h"
51 #include "CleanupCommand.h"
52 #include "RebaseCommand.h"
53 #include "ResolveCommand.h"
54 #include "DropMoveCommand.h"
55 #include "DropCopyAddCommand.h"
56 #include "DropCopyCommand.h"
57 #include "DropExportCommand.h"
58 #include "HelpCommand.h"
59 #include "StashCommand.h"
60 #include "SubmoduleCommand.h"
61 #include "ReflogCommand.h"
62 #include "SendMailCommand.h"
63 #include "CatCommand.h"
65 #include "BrowseRefsDlg.h"
67 #if 0
71 #include "CheckoutCommand.h"
75 #include "CopyCommand.h"
76 #include "CrashCommand.h"
77 #include "CreatePatchCommand.h"
79 #include "DelUnversionedCommand.h"
86 #include "ImportCommand.h"
87 #include "LockCommand.h"
90 #include "MergeAllCommand.h"
91 #include "PasteCopyCommand.h"
92 #include "PasteMoveCommand.h"
94 #include "PropertiesCommand.h"
95 #include "RebuildIconCacheCommand.h"
96 #include "RelocateCommand.h"
97 #include "RemoveCommand.h"
99 #include "RepositoryBrowserCommand.h"
102 #include "RevertCommand.h"
103 #include "RevisiongraphCommand.h"
104 #include "RTFMCommand.h"
106 #include "ShowCompareCommand.h"
108 #include "UnIgnoreCommand.h"
109 #include "UnLockCommand.h"
110 #include "UpdateCheckCommand.h"
111 #include "UpdateCommand.h"
112 #include "UrlDiffCommand.h"
113 #endif
114 typedef enum
116 cmdAbout,
117 cmdAdd,
118 cmdBlame,
119 cmdBranch,
120 cmdCat,
121 cmdCheckout,
122 cmdCleanup,
123 cmdClone,
124 cmdCommit,
125 cmdConflictEditor,
126 cmdCopy,
127 cmdCrash,
128 cmdCreatePatch,
129 cmdDelUnversioned,
130 cmdDiff,
131 cmdDropCopy,
132 cmdDropCopyAdd,
133 cmdDropExport,
134 cmdDropMove,
135 cmdFetch,
136 cmdFormatPatch,
137 cmdExport,
138 cmdHelp,
139 cmdIgnore,
140 cmdImport,
141 cmdImportPatch,
142 cmdLock,
143 cmdLog,
144 cmdMerge,
145 cmdMergeAll,
146 cmdPasteCopy,
147 cmdPasteMove,
148 cmdPrevDiff,
149 cmdProperties,
150 cmdPull,
151 cmdPush,
152 cmdRTFM,
153 cmdRebuildIconCache,
154 cmdRelocate,
155 cmdRemove,
156 cmdRebase,
157 cmdRename,
158 cmdRepoBrowser,
159 cmdRepoCreate,
160 cmdRepoStatus,
161 cmdResolve,
162 cmdRevert,
163 cmdRevisionGraph,
164 cmdSendMail,
165 cmdSettings,
166 cmdShowCompare,
167 cmdSwitch,
168 cmdTag,
169 cmdUnIgnore,
170 cmdUnlock,
171 cmdUpdate,
172 cmdUpdateCheck,
173 cmdUrlDiff,
174 cmdStashSave,
175 cmdStashApply,
176 cmdStashList,
177 cmdSubAdd,
178 cmdSubUpdate,
179 cmdSubSync,
180 cmdRefLog,
182 } TGitCommand;
184 static const struct CommandInfo
186 TGitCommand command;
187 LPCTSTR pCommandName;
188 } commandInfo[] =
190 { cmdAbout, _T("about") },
191 { cmdAdd, _T("add") },
192 { cmdBlame, _T("blame") },
193 { cmdBranch, _T("branch") },
194 { cmdCat, _T("cat") },
195 { cmdCheckout, _T("checkout") },
196 { cmdCleanup, _T("cleanup") },
197 { cmdClone, _T("clone") },
198 { cmdCommit, _T("commit") },
199 { cmdConflictEditor, _T("conflicteditor") },
200 { cmdCopy, _T("copy") },
201 { cmdCrash, _T("crash") },
202 { cmdCreatePatch, _T("createpatch") },
203 { cmdDelUnversioned, _T("delunversioned") },
204 { cmdDiff, _T("diff") },
205 { cmdDropCopy, _T("dropcopy") },
206 { cmdDropCopyAdd, _T("dropcopyadd") },
207 { cmdDropExport, _T("dropexport") },
208 { cmdDropMove, _T("dropmove") },
209 { cmdFetch, _T("fetch") },
210 { cmdFormatPatch, _T("formatpatch") },
211 { cmdExport, _T("export") },
212 { cmdHelp, _T("help") },
213 { cmdIgnore, _T("ignore") },
214 { cmdImport, _T("import") },
215 { cmdImportPatch, _T("importpatch") },
216 { cmdLock, _T("lock") },
217 { cmdLog, _T("log") },
218 { cmdMerge, _T("merge") },
219 { cmdMergeAll, _T("mergeall") },
220 { cmdPasteCopy, _T("pastecopy") },
221 { cmdPasteMove, _T("pastemove") },
222 { cmdPrevDiff, _T("prevdiff") },
223 { cmdProperties, _T("properties") },
224 { cmdPull, _T("pull") },
225 { cmdPush, _T("push") },
226 { cmdRTFM, _T("rtfm") },
227 { cmdRebuildIconCache,_T("rebuildiconcache") },
228 { cmdRelocate, _T("relocate") },
229 { cmdRemove, _T("remove") },
230 { cmdRebase, _T("rebase") },
231 { cmdRename, _T("rename") },
232 { cmdRepoBrowser, _T("repobrowser") },
233 { cmdRepoCreate, _T("repocreate") },
234 { cmdRepoStatus, _T("repostatus") },
235 { cmdResolve, _T("resolve") },
236 { cmdRevert, _T("revert") },
237 { cmdRevisionGraph, _T("revisiongraph") },
238 { cmdSendMail, _T("sendmail") },
239 { cmdSettings, _T("settings") },
240 { cmdShowCompare, _T("showcompare") },
241 { cmdSwitch, _T("switch") },
242 { cmdTag, _T("tag") },
243 { cmdUnIgnore, _T("unignore") },
244 { cmdUnlock, _T("unlock") },
245 { cmdUpdate, _T("update") },
246 { cmdUpdateCheck, _T("updatecheck") },
247 { cmdUrlDiff, _T("urldiff") },
248 { cmdStashSave, _T("stashsave") },
249 { cmdStashApply, _T("stashapply") },
250 { cmdStashList, _T("stashlist") },
251 { cmdSubAdd, _T("subadd") },
252 { cmdSubUpdate, _T("subupdate") },
253 { cmdSubSync, _T("subsync") },
254 { cmdRefLog, _T("reflog") }
260 Command * CommandServer::GetCommand(const CString& sCmd)
262 // Look up the command
263 TGitCommand command = cmdAbout; // Something harmless as a default
264 for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)
266 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
268 // We've found the command
269 command = commandInfo[nCommand].command;
270 // If this fires, you've let the enum get out of sync with the commandInfo array
271 ASSERT((int)command == nCommand);
272 break;
277 // CBrowseRefsDlg dialog
278 #if 1
279 class TestCommand : public Command
281 virtual bool Execute()
283 CBrowseRefsDlg().DoModal();
284 return true;
287 return new TestCommand;
288 #endif
290 switch (command)
292 case cmdAbout:
293 return new AboutCommand;
294 case cmdCommit:
295 return new CommitCommand;
296 case cmdLog:
297 return new LogCommand;
298 case cmdRepoCreate:
299 return new CreateRepositoryCommand;
300 case cmdClone:
301 return new CloneCommand;
302 case cmdPrevDiff:
303 return new PrevDiffCommand;
304 case cmdDiff:
305 return new DiffCommand;
306 case cmdRename:
307 return new RenameCommand;
308 case cmdRepoStatus:
309 return new RepoStatusCommand;
310 case cmdRemove:
311 return new RemoveCommand;
312 case cmdRevert:
313 return new RevertCommand;
314 case cmdPull:
315 return new PullCommand;
316 case cmdFetch:
317 return new FetchCommand;
318 case cmdPush:
319 return new PushCommand;
320 case cmdBranch:
321 return new BranchCommand;
322 case cmdTag:
323 return new TagCommand;
324 case cmdMerge:
325 return new MergeCommand;
326 case cmdSwitch:
327 return new SwitchCommand;
328 case cmdExport:
329 return new ExportCommand;
330 case cmdAdd:
331 return new AddCommand;
332 case cmdIgnore:
333 return new IgnoreCommand;
334 case cmdFormatPatch:
335 return new FormatPatchCommand;
336 case cmdImportPatch:
337 return new ImportPatchCommand;
338 case cmdBlame:
339 return new BlameCommand;
340 case cmdSettings:
341 return new SettingsCommand;
342 case cmdConflictEditor:
343 return new ConflictEditorCommand;
344 case cmdCleanup:
345 return new CleanupCommand;
346 case cmdRebase:
347 return new RebaseCommand;
348 case cmdResolve:
349 return new ResolveCommand;
350 case cmdDropMove:
351 return new DropMoveCommand;
352 // case cmdDropCopy:
353 // return new DropCopyCommand;
354 // case cmdDropCopyAdd:
355 // return new DropCopyAddCommand;
356 // case cmdDropExport:
357 // return new DropExportCommand;
358 case cmdHelp:
359 return new HelpCommand;
360 case cmdStashSave:
361 return new StashSaveCommand;
362 case cmdStashApply:
363 return new StashApplyCommand;
364 case cmdSubAdd:
365 return new SubmoduleAddCommand;
366 case cmdSubUpdate:
367 return new SubmoduleUpdateCommand;
368 case cmdRefLog:
369 return new RefLogCommand;
370 case cmdSubSync:
371 return new SubmoduleSyncCommand;
372 case cmdSendMail:
373 return new SendMailCommand;
374 case cmdCat:
375 return new CatCommand;
376 #if 0
379 case cmdCheckout:
380 return new CheckoutCommand;
384 case cmdCopy:
385 return new CopyCommand;
386 case cmdCrash:
387 return new CrashCommand;
388 case cmdCreatePatch:
389 return new CreatePatchCommand;
390 case cmdDelUnversioned:
391 return new DelUnversionedCommand;
395 case cmdImport:
396 return new ImportCommand;
397 case cmdLock:
398 return new LockCommand;
399 case cmdMergeAll:
400 return new MergeAllCommand;
401 case cmdPasteCopy:
402 return new PasteCopyCommand;
403 case cmdPasteMove:
404 return new PasteMoveCommand;
405 case cmdPrevDiff:
406 return new PrevDiffCommand;
407 case cmdProperties:
408 return new PropertiesCommand;
409 case cmdRTFM:
410 return new RTFMCommand;
411 case cmdRebuildIconCache:
412 return new RebuildIconCacheCommand;
413 case cmdRelocate:
414 return new RelocateCommand;
415 case cmdRepoBrowser:
416 return new RepositoryBrowserCommand;
417 case cmdRevisionGraph:
418 return new RevisionGraphCommand;
419 case cmdShowCompare:
420 return new ShowCompareCommand;
421 case cmdUnIgnore:
422 return new UnIgnoreCommand;
423 case cmdUnlock:
424 return new UnLockCommand;
425 case cmdUpdate:
426 return new UpdateCommand;
427 case cmdUpdateCheck:
428 return new UpdateCheckCommand;
429 case cmdUrlDiff:
430 return new UrlDiffCommand;
431 #endif
432 default:
433 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);
434 return new AboutCommand;