Fixed issue #151: need "stash pop" function and clear HasAdminDir HasGitSVN HashSubmo...
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob17ce1ae543a4f2a9d4ba745801a68de7158ebee8
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"
64 #include "RefBrowseCommand.h"
65 #include "SVNDCommitCommand.h"
66 #include "SVNRebaseCommand.h"
67 #include "SyncCommand.h"
69 #if 0
73 #include "CheckoutCommand.h"
77 #include "CopyCommand.h"
78 #include "CrashCommand.h"
79 #include "CreatePatchCommand.h"
81 #include "DelUnversionedCommand.h"
88 #include "ImportCommand.h"
89 #include "LockCommand.h"
92 #include "MergeAllCommand.h"
93 #include "PasteCopyCommand.h"
94 #include "PasteMoveCommand.h"
96 #include "PropertiesCommand.h"
97 #include "RebuildIconCacheCommand.h"
98 #include "RelocateCommand.h"
99 #include "RemoveCommand.h"
101 #include "RepositoryBrowserCommand.h"
104 #include "RevertCommand.h"
105 #include "RevisiongraphCommand.h"
106 #include "RTFMCommand.h"
108 #include "ShowCompareCommand.h"
110 #include "UnIgnoreCommand.h"
111 #include "UnLockCommand.h"
112 #include "UpdateCheckCommand.h"
113 #include "UpdateCommand.h"
114 #include "UrlDiffCommand.h"
115 #endif
116 typedef enum
118 cmdAbout,
119 cmdAdd,
120 cmdBlame,
121 cmdBranch,
122 cmdCat,
123 cmdCheckout,
124 cmdCleanup,
125 cmdClone,
126 cmdCommit,
127 cmdConflictEditor,
128 cmdCopy,
129 cmdCrash,
130 cmdCreatePatch,
131 cmdDelUnversioned,
132 cmdDiff,
133 cmdDropCopy,
134 cmdDropCopyAdd,
135 cmdDropExport,
136 cmdDropMove,
137 cmdFetch,
138 cmdFormatPatch,
139 cmdExport,
140 cmdHelp,
141 cmdIgnore,
142 cmdImport,
143 cmdImportPatch,
144 cmdLock,
145 cmdLog,
146 cmdMerge,
147 cmdMergeAll,
148 cmdPasteCopy,
149 cmdPasteMove,
150 cmdPrevDiff,
151 cmdProperties,
152 cmdPull,
153 cmdPush,
154 cmdRTFM,
155 cmdRebuildIconCache,
156 cmdRelocate,
157 cmdRemove,
158 cmdRebase,
159 cmdRename,
160 cmdRepoBrowser,
161 cmdRepoCreate,
162 cmdRepoStatus,
163 cmdResolve,
164 cmdRevert,
165 cmdRevisionGraph,
166 cmdSendMail,
167 cmdSettings,
168 cmdShowCompare,
169 cmdSwitch,
170 cmdTag,
171 cmdUnIgnore,
172 cmdUnlock,
173 cmdUpdate,
174 cmdUpdateCheck,
175 cmdUrlDiff,
176 cmdStashSave,
177 cmdStashApply,
178 cmdStashPop,
179 cmdStashList,
180 cmdSubAdd,
181 cmdSubUpdate,
182 cmdSubSync,
183 cmdRefLog,
184 cmdRefBrowse,
185 cmdSVNDCommit,
186 cmdSVNRebase,
187 cmdSync,
189 } TGitCommand;
191 static const struct CommandInfo
193 TGitCommand command;
194 LPCTSTR pCommandName;
195 } commandInfo[] =
197 { cmdAbout, _T("about") },
198 { cmdAdd, _T("add") },
199 { cmdBlame, _T("blame") },
200 { cmdBranch, _T("branch") },
201 { cmdCat, _T("cat") },
202 { cmdCheckout, _T("checkout") },
203 { cmdCleanup, _T("cleanup") },
204 { cmdClone, _T("clone") },
205 { cmdCommit, _T("commit") },
206 { cmdConflictEditor, _T("conflicteditor") },
207 { cmdCopy, _T("copy") },
208 { cmdCrash, _T("crash") },
209 { cmdCreatePatch, _T("createpatch") },
210 { cmdDelUnversioned, _T("delunversioned") },
211 { cmdDiff, _T("diff") },
212 { cmdDropCopy, _T("dropcopy") },
213 { cmdDropCopyAdd, _T("dropcopyadd") },
214 { cmdDropExport, _T("dropexport") },
215 { cmdDropMove, _T("dropmove") },
216 { cmdFetch, _T("fetch") },
217 { cmdFormatPatch, _T("formatpatch") },
218 { cmdExport, _T("export") },
219 { cmdHelp, _T("help") },
220 { cmdIgnore, _T("ignore") },
221 { cmdImport, _T("import") },
222 { cmdImportPatch, _T("importpatch") },
223 { cmdLock, _T("lock") },
224 { cmdLog, _T("log") },
225 { cmdMerge, _T("merge") },
226 { cmdMergeAll, _T("mergeall") },
227 { cmdPasteCopy, _T("pastecopy") },
228 { cmdPasteMove, _T("pastemove") },
229 { cmdPrevDiff, _T("prevdiff") },
230 { cmdProperties, _T("properties") },
231 { cmdPull, _T("pull") },
232 { cmdPush, _T("push") },
233 { cmdRTFM, _T("rtfm") },
234 { cmdRebuildIconCache,_T("rebuildiconcache") },
235 { cmdRelocate, _T("relocate") },
236 { cmdRemove, _T("remove") },
237 { cmdRebase, _T("rebase") },
238 { cmdRename, _T("rename") },
239 { cmdRepoBrowser, _T("repobrowser") },
240 { cmdRepoCreate, _T("repocreate") },
241 { cmdRepoStatus, _T("repostatus") },
242 { cmdResolve, _T("resolve") },
243 { cmdRevert, _T("revert") },
244 { cmdRevisionGraph, _T("revisiongraph") },
245 { cmdSendMail, _T("sendmail") },
246 { cmdSettings, _T("settings") },
247 { cmdShowCompare, _T("showcompare") },
248 { cmdSwitch, _T("switch") },
249 { cmdTag, _T("tag") },
250 { cmdUnIgnore, _T("unignore") },
251 { cmdUnlock, _T("unlock") },
252 { cmdUpdate, _T("update") },
253 { cmdUpdateCheck, _T("updatecheck") },
254 { cmdUrlDiff, _T("urldiff") },
255 { cmdStashSave, _T("stashsave") },
256 { cmdStashApply, _T("stashapply") },
257 { cmdStashPop, _T("stashpop") },
258 { cmdStashList, _T("stashlist") },
259 { cmdSubAdd, _T("subadd") },
260 { cmdSubUpdate, _T("subupdate") },
261 { cmdSubSync, _T("subsync") },
262 { cmdRefLog, _T("reflog") },
263 { cmdRefBrowse, _T("refbrowse") },
264 { cmdSVNDCommit, _T("svndcommit") },
265 { cmdSVNRebase, _T("svnrebase") },
266 { cmdSync, _T("sync") },
270 Command * CommandServer::GetCommand(const CString& sCmd)
272 // Look up the command
273 TGitCommand command = cmdAbout; // Something harmless as a default
274 for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)
276 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
278 // We've found the command
279 command = commandInfo[nCommand].command;
280 // If this fires, you've let the enum get out of sync with the commandInfo array
281 ASSERT((int)command == nCommand);
282 break;
287 // CBrowseRefsDlg dialog
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 cmdStashPop:
365 return new StashPopCommand;
366 case cmdSubAdd:
367 return new SubmoduleAddCommand;
368 case cmdSubUpdate:
369 return new SubmoduleUpdateCommand;
370 case cmdRefLog:
371 return new RefLogCommand;
372 case cmdSubSync:
373 return new SubmoduleSyncCommand;
374 case cmdSendMail:
375 return new SendMailCommand;
376 case cmdCat:
377 return new CatCommand;
378 case cmdRefBrowse:
379 return new RefBrowseCommand;
380 case cmdSVNDCommit:
381 return new SVNDCommitCommand;
382 case cmdSVNRebase:
383 return new SVNRebaseCommand;
384 case cmdSync:
385 return new SyncCommand;
386 #if 0
389 case cmdCheckout:
390 return new CheckoutCommand;
394 case cmdCopy:
395 return new CopyCommand;
396 case cmdCrash:
397 return new CrashCommand;
398 case cmdCreatePatch:
399 return new CreatePatchCommand;
400 case cmdDelUnversioned:
401 return new DelUnversionedCommand;
405 case cmdImport:
406 return new ImportCommand;
407 case cmdLock:
408 return new LockCommand;
409 case cmdMergeAll:
410 return new MergeAllCommand;
411 case cmdPasteCopy:
412 return new PasteCopyCommand;
413 case cmdPasteMove:
414 return new PasteMoveCommand;
415 case cmdPrevDiff:
416 return new PrevDiffCommand;
417 case cmdProperties:
418 return new PropertiesCommand;
419 case cmdRTFM:
420 return new RTFMCommand;
421 case cmdRebuildIconCache:
422 return new RebuildIconCacheCommand;
423 case cmdRelocate:
424 return new RelocateCommand;
425 case cmdRepoBrowser:
426 return new RepositoryBrowserCommand;
427 case cmdRevisionGraph:
428 return new RevisionGraphCommand;
429 case cmdShowCompare:
430 return new ShowCompareCommand;
431 case cmdUnIgnore:
432 return new UnIgnoreCommand;
433 case cmdUnlock:
434 return new UnLockCommand;
435 case cmdUpdate:
436 return new UpdateCommand;
437 case cmdUpdateCheck:
438 return new UpdateCheckCommand;
439 case cmdUrlDiff:
440 return new UrlDiffCommand;
441 #endif
442 default:
443 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);
444 return new AboutCommand;