added basic version of repository browser
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blobe490db1c6443d25731e2abb0346eeab3dbd32926
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "StdAfx.h"
21 #include "Command.h"
23 #include "AboutCommand.h"
24 #include "CommitCommand.h"
25 #include "LogCommand.h"
27 #include "CreateRepositoryCommand.h"
28 #include "CloneCommand.h"
29 #include "PrevDiffCommand.h"
30 #include "DiffCommand.h"
32 #include "RenameCommand.h"
33 #include "RepoStatusCommand.h"
35 #include "RevertCommand.h"
36 #include "RemoveCommand.h"
37 #include "PullCommand.h"
38 #include "FetchCommand.h"
39 #include "PushCommand.h"
40 #include "BranchCommand.h"
41 #include "TagCommand.h"
42 #include "MergeCommand.h"
43 #include "SwitchCommand.h"
44 #include "ExportCommand.h"
45 #include "AddCommand.h"
46 #include "IgnoreCommand.h"
47 #include "FormatPatchCommand.h"
48 #include "ImportPatchCommand.h"
49 #include "BlameCommand.h"
50 #include "SettingsCommand.h"
51 #include "ConflictEditorCommand.h"
52 #include "CleanupCommand.h"
53 #include "RebaseCommand.h"
54 #include "ResolveCommand.h"
55 #include "DropMoveCommand.h"
56 #include "DropCopyAddCommand.h"
57 #include "DropCopyCommand.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"
64 #include "RefBrowseCommand.h"
65 #include "SVNDCommitCommand.h"
66 #include "SVNRebaseCommand.h"
67 #include "SVNFetchCommand.h"
68 #include "SyncCommand.h"
69 #include "RequestPullCommand.h"
70 #include "UpdateCheckCommand.h"
71 #include "PasteCopyCommand.h"
72 #include "PasteMoveCommand.h"
73 #include "SVNIgnoreCommand.h"
74 #include "BisectCommand.h"
75 #include "RepositoryBrowserCommand.h"
77 #if 0
80 #include "CopyCommand.h"
81 #include "CrashCommand.h"
87 #include "PropertiesCommand.h"
88 #include "RebuildIconCacheCommand.h"
89 #include "RemoveCommand.h"
93 #include "RevertCommand.h"
94 #include "RTFMCommand.h"
96 #include "ShowCompareCommand.h"
98 #include "UnIgnoreCommand.h"
100 #endif
101 typedef enum
103 cmdAbout,
104 cmdAdd,
105 cmdBlame,
106 cmdBranch,
107 cmdCat,
108 cmdCleanup,
109 cmdClone,
110 cmdCommit,
111 cmdConflictEditor,
112 cmdCopy,
113 cmdCrash,
114 cmdDiff,
115 cmdDropCopy,
116 cmdDropCopyAdd,
117 cmdDropMove,
118 cmdFetch,
119 cmdFormatPatch,
120 cmdExport,
121 cmdHelp,
122 cmdIgnore,
123 cmdImportPatch,
124 cmdLog,
125 cmdMerge,
126 cmdPasteCopy,
127 cmdPasteMove,
128 cmdPrevDiff,
129 cmdProperties,
130 cmdPull,
131 cmdPush,
132 cmdRTFM,
133 cmdRebuildIconCache,
134 cmdRemove,
135 cmdRebase,
136 cmdRename,
137 cmdRepoCreate,
138 cmdRepoStatus,
139 cmdResolve,
140 cmdRevert,
141 cmdSendMail,
142 cmdSettings,
143 cmdShowCompare,
144 cmdSwitch,
145 cmdTag,
146 cmdUnIgnore,
147 cmdUpdateCheck,
148 cmdStashSave,
149 cmdStashApply,
150 cmdStashPop,
151 cmdStashList,
152 cmdSubAdd,
153 cmdSubUpdate,
154 cmdSubSync,
155 cmdRefLog,
156 cmdRefBrowse,
157 cmdSVNDCommit,
158 cmdSVNRebase,
159 cmdSVNFetch,
160 cmdSVNIgnore,
161 cmdSync,
162 cmdRequestPull,
163 cmdBisect,
164 cmdRepoBrowser,
165 } TGitCommand;
167 static const struct CommandInfo
169 TGitCommand command;
170 LPCTSTR pCommandName;
171 } commandInfo[] =
173 { cmdAbout, _T("about") },
174 { cmdAdd, _T("add") },
175 { cmdBlame, _T("blame") },
176 { cmdBranch, _T("branch") },
177 { cmdCat, _T("cat") },
178 { cmdCleanup, _T("cleanup") },
179 { cmdClone, _T("clone") },
180 { cmdCommit, _T("commit") },
181 { cmdConflictEditor, _T("conflicteditor") },
182 { cmdCopy, _T("copy") },
183 { cmdCrash, _T("crash") },
184 { cmdDiff, _T("diff") },
185 { cmdDropCopy, _T("dropcopy") },
186 { cmdDropCopyAdd, _T("dropcopyadd") },
187 { cmdDropMove, _T("dropmove") },
188 { cmdFetch, _T("fetch") },
189 { cmdFormatPatch, _T("formatpatch") },
190 { cmdExport, _T("export") },
191 { cmdHelp, _T("help") },
192 { cmdIgnore, _T("ignore") },
193 { cmdImportPatch, _T("importpatch") },
194 { cmdLog, _T("log") },
195 { cmdMerge, _T("merge") },
196 { cmdPasteCopy, _T("pastecopy") },
197 { cmdPasteMove, _T("pastemove") },
198 { cmdPrevDiff, _T("prevdiff") },
199 { cmdProperties, _T("properties") },
200 { cmdPull, _T("pull") },
201 { cmdPush, _T("push") },
202 { cmdRTFM, _T("rtfm") },
203 { cmdRebuildIconCache,_T("rebuildiconcache") },
204 { cmdRemove, _T("remove") },
205 { cmdRebase, _T("rebase") },
206 { cmdRename, _T("rename") },
207 { cmdRepoCreate, _T("repocreate") },
208 { cmdRepoStatus, _T("repostatus") },
209 { cmdResolve, _T("resolve") },
210 { cmdRevert, _T("revert") },
211 { cmdSendMail, _T("sendmail") },
212 { cmdSettings, _T("settings") },
213 { cmdShowCompare, _T("showcompare") },
214 { cmdSwitch, _T("switch") },
215 { cmdTag, _T("tag") },
216 { cmdUnIgnore, _T("unignore") },
217 { cmdUpdateCheck, _T("updatecheck") },
218 { cmdStashSave, _T("stashsave") },
219 { cmdStashApply, _T("stashapply") },
220 { cmdStashPop, _T("stashpop") },
221 { cmdStashList, _T("stashlist") },
222 { cmdSubAdd, _T("subadd") },
223 { cmdSubUpdate, _T("subupdate") },
224 { cmdSubSync, _T("subsync") },
225 { cmdRefLog, _T("reflog") },
226 { cmdRefBrowse, _T("refbrowse") },
227 { cmdSVNDCommit, _T("svndcommit") },
228 { cmdSVNRebase, _T("svnrebase") },
229 { cmdSVNFetch, _T("svnfetch") },
230 { cmdSVNIgnore, _T("svnignore") },
231 { cmdSync, _T("sync") },
232 { cmdRequestPull, _T("requestpull") },
233 { cmdBisect, _T("bisect") },
234 { cmdRepoBrowser, _T("repobrowser") },
238 Command * CommandServer::GetCommand(const CString& sCmd)
240 // Look up the command
241 TGitCommand command = cmdAbout; // Something harmless as a default
242 for (int nCommand = 0; nCommand < _countof(commandInfo); nCommand++)
244 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
246 // We've found the command
247 command = commandInfo[nCommand].command;
248 // If this fires, you've let the enum get out of sync with the commandInfo array
249 ASSERT((int)command == nCommand);
250 break;
254 // CBrowseRefsDlg dialog
255 switch (command)
257 case cmdAbout:
258 return new AboutCommand;
259 case cmdCommit:
260 return new CommitCommand;
261 case cmdLog:
262 return new LogCommand;
263 case cmdRepoCreate:
264 return new CreateRepositoryCommand;
265 case cmdClone:
266 return new CloneCommand;
267 case cmdPrevDiff:
268 return new PrevDiffCommand;
269 case cmdDiff:
270 return new DiffCommand;
271 case cmdRename:
272 return new RenameCommand;
273 case cmdRepoStatus:
274 return new RepoStatusCommand;
275 case cmdRemove:
276 return new RemoveCommand;
277 case cmdRevert:
278 return new RevertCommand;
279 case cmdPull:
280 return new PullCommand;
281 case cmdFetch:
282 return new FetchCommand;
283 case cmdPush:
284 return new PushCommand;
285 case cmdBranch:
286 return new BranchCommand;
287 case cmdTag:
288 return new TagCommand;
289 case cmdMerge:
290 return new MergeCommand;
291 case cmdSwitch:
292 return new SwitchCommand;
293 case cmdExport:
294 return new ExportCommand;
295 case cmdAdd:
296 return new AddCommand;
297 case cmdIgnore:
298 return new IgnoreCommand;
299 case cmdFormatPatch:
300 return new FormatPatchCommand;
301 case cmdImportPatch:
302 return new ImportPatchCommand;
303 case cmdBlame:
304 return new BlameCommand;
305 case cmdSettings:
306 return new SettingsCommand;
307 case cmdConflictEditor:
308 return new ConflictEditorCommand;
309 case cmdCleanup:
310 return new CleanupCommand;
311 case cmdRebase:
312 return new RebaseCommand;
313 case cmdResolve:
314 return new ResolveCommand;
315 case cmdDropMove:
316 return new DropMoveCommand;
317 case cmdDropCopy:
318 return new DropCopyCommand;
319 case cmdDropCopyAdd:
320 return new DropCopyAddCommand;
321 case cmdHelp:
322 return new HelpCommand;
323 case cmdStashSave:
324 return new StashSaveCommand;
325 case cmdStashApply:
326 return new StashApplyCommand;
327 case cmdStashPop:
328 return new StashPopCommand;
329 case cmdSubAdd:
330 return new SubmoduleAddCommand;
331 case cmdSubUpdate:
332 return new SubmoduleUpdateCommand;
333 case cmdRefLog:
334 return new RefLogCommand;
335 case cmdSubSync:
336 return new SubmoduleSyncCommand;
337 case cmdSendMail:
338 return new SendMailCommand;
339 case cmdCat:
340 return new CatCommand;
341 case cmdRefBrowse:
342 return new RefBrowseCommand;
343 case cmdSVNDCommit:
344 return new SVNDCommitCommand;
345 case cmdSVNRebase:
346 return new SVNRebaseCommand;
347 case cmdSVNFetch:
348 return new SVNFetchCommand;
349 case cmdSync:
350 return new SyncCommand;
351 case cmdRequestPull:
352 return new RequestPullCommand;
353 case cmdUpdateCheck:
354 return new UpdateCheckCommand;
355 case cmdPasteCopy:
356 return new PasteCopyCommand;
357 case cmdPasteMove:
358 return new PasteMoveCommand;
359 case cmdSVNIgnore:
360 return new SVNIgnoreCommand;
361 case cmdBisect:
362 return new BisectCommand;
363 case cmdRepoBrowser:
364 return new RepositoryBrowserCommand;
366 #if 0
370 case cmdCopy:
371 return new CopyCommand;
372 case cmdCrash:
373 return new CrashCommand;
377 case cmdPrevDiff:
378 return new PrevDiffCommand;
379 case cmdProperties:
380 return new PropertiesCommand;
381 case cmdRTFM:
382 return new RTFMCommand;
383 case cmdRebuildIconCache:
384 return new RebuildIconCacheCommand;
385 case cmdShowCompare:
386 return new ShowCompareCommand;
387 case cmdUnIgnore:
388 return new UnIgnoreCommand;
389 #endif
390 default:
391 CMessageBox::Show(hWndExplorer, _T("Command not implemented"), _T("TortoiseGit"), MB_ICONERROR);
392 return new AboutCommand;