OSDN Git Service

Fixed issue #155: Fix SVN Rebase sets upstream as remotes/trunk
[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         cmdStashPop,\r
179         cmdStashList,\r
180         cmdSubAdd,              \r
181         cmdSubUpdate,\r
182         cmdSubSync,\r
183         cmdRefLog,\r
184         cmdRefBrowse,\r
185         cmdSVNDCommit,\r
186         cmdSVNRebase,\r
187         cmdSync,\r
188         \r
189 } TGitCommand;\r
190 \r
191 static const struct CommandInfo\r
192 {\r
193         TGitCommand command;\r
194         LPCTSTR pCommandName;\r
195 } commandInfo[] = \r
196 {\r
197         {       cmdAbout,                       _T("about")                             },\r
198         {       cmdAdd,                         _T("add")                               },\r
199         {       cmdBlame,                       _T("blame")                             },\r
200         {       cmdBranch,                      _T("branch")                    },\r
201         {       cmdCat,                         _T("cat")                               },\r
202         {       cmdCheckout,            _T("checkout")                  },\r
203         {       cmdCleanup,                     _T("cleanup")                   },\r
204         {       cmdClone,                       _T("clone")                             },\r
205         {       cmdCommit,                      _T("commit")                    },\r
206         {       cmdConflictEditor,      _T("conflicteditor")    },\r
207         {       cmdCopy,                        _T("copy")                              },\r
208         {       cmdCrash,                       _T("crash")                             },\r
209         {       cmdCreatePatch,         _T("createpatch")               },\r
210         {       cmdDelUnversioned,      _T("delunversioned")    },\r
211         {       cmdDiff,                        _T("diff")                              },\r
212         {       cmdDropCopy,            _T("dropcopy")                  },\r
213         {       cmdDropCopyAdd,         _T("dropcopyadd")               },\r
214         {       cmdDropExport,          _T("dropexport")                },\r
215         {       cmdDropMove,            _T("dropmove")                  },\r
216         {       cmdFetch,                       _T("fetch")                             },\r
217         {       cmdFormatPatch,         _T("formatpatch")               },\r
218         {       cmdExport,                      _T("export")                    },\r
219         {       cmdHelp,                        _T("help")                              },\r
220         {       cmdIgnore,                      _T("ignore")                    },\r
221         {       cmdImport,                      _T("import")                    },\r
222         {       cmdImportPatch,         _T("importpatch")               },\r
223         {       cmdLock,                        _T("lock")                              },\r
224         {       cmdLog,                         _T("log")                               },\r
225         {       cmdMerge,                       _T("merge")                             },\r
226         {       cmdMergeAll,            _T("mergeall")                  },\r
227         {       cmdPasteCopy,           _T("pastecopy")                 },\r
228         {       cmdPasteMove,           _T("pastemove")                 },\r
229         {       cmdPrevDiff,            _T("prevdiff")                  },\r
230         {       cmdProperties,          _T("properties")                },\r
231         {       cmdPull,                        _T("pull")                              },\r
232         {       cmdPush,                        _T("push")                              },\r
233         {       cmdRTFM,                        _T("rtfm")                              },\r
234         {       cmdRebuildIconCache,_T("rebuildiconcache")      },\r
235         {       cmdRelocate,            _T("relocate")                  },\r
236         {       cmdRemove,                      _T("remove")                    },\r
237         {       cmdRebase,                      _T("rebase")                    },\r
238         {       cmdRename,                      _T("rename")                    },\r
239         {       cmdRepoBrowser,         _T("repobrowser")               },\r
240         {       cmdRepoCreate,          _T("repocreate")                },\r
241         {       cmdRepoStatus,          _T("repostatus")                },\r
242         {       cmdResolve,                     _T("resolve")                   },\r
243         {       cmdRevert,                      _T("revert")                    },\r
244         {       cmdRevisionGraph,       _T("revisiongraph")             },\r
245         {       cmdSendMail,            _T("sendmail")                  },\r
246         {       cmdSettings,            _T("settings")                  },\r
247         {       cmdShowCompare,         _T("showcompare")               },\r
248         {       cmdSwitch,                      _T("switch")                    },\r
249         {       cmdTag,                         _T("tag")                               },\r
250         {       cmdUnIgnore,            _T("unignore")                  },\r
251         {       cmdUnlock,                      _T("unlock")                    },\r
252         {       cmdUpdate,                      _T("update")                    },\r
253         {       cmdUpdateCheck,         _T("updatecheck")               },\r
254         {       cmdUrlDiff,                     _T("urldiff")                   },\r
255         {       cmdStashSave,           _T("stashsave")                 },\r
256         {       cmdStashApply,          _T("stashapply")                },\r
257         {       cmdStashPop,            _T("stashpop")                  },\r
258         {       cmdStashList,           _T("stashlist")                 },\r
259         {       cmdSubAdd,                      _T("subadd")                    },\r
260         {       cmdSubUpdate,           _T("subupdate")                 },\r
261         {       cmdSubSync,                     _T("subsync")                   },\r
262         {       cmdRefLog,                      _T("reflog")                    },\r
263         {       cmdRefBrowse,           _T("refbrowse")                 },\r
264         {       cmdSVNDCommit,          _T("svndcommit")                },\r
265         {       cmdSVNRebase,           _T("svnrebase")                 },\r
266         {       cmdSync,                        _T("sync")                              },\r
267 };\r
268 \r
269 \r
270 Command * CommandServer::GetCommand(const CString& sCmd)\r
271 {\r
272         // Look up the command\r
273         TGitCommand command = cmdAbout;         // Something harmless as a default\r
274         for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)\r
275         {\r
276                 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)\r
277                 {\r
278                         // We've found the command\r
279                         command = commandInfo[nCommand].command;\r
280                         // If this fires, you've let the enum get out of sync with the commandInfo array\r
281                         ASSERT((int)command == nCommand);\r
282                         break;\r
283                 }\r
284         }\r
285 \r
286                 \r
287         // CBrowseRefsDlg dialog\r
288 \r
289 \r
290         switch (command)\r
291         {\r
292         case cmdAbout:\r
293                 return new AboutCommand;        \r
294         case cmdCommit:\r
295                 return new CommitCommand;\r
296         case cmdLog:\r
297                 return new LogCommand;\r
298         case cmdRepoCreate:\r
299                 return new CreateRepositoryCommand;\r
300         case cmdClone:\r
301                 return new CloneCommand;\r
302         case cmdPrevDiff:\r
303                 return new PrevDiffCommand;\r
304         case cmdDiff:\r
305                 return new DiffCommand;\r
306         case cmdRename:\r
307                 return new RenameCommand;\r
308         case cmdRepoStatus:\r
309                 return new RepoStatusCommand;\r
310         case cmdRemove:\r
311                 return new RemoveCommand;\r
312         case cmdRevert:\r
313                 return new RevertCommand;\r
314         case cmdPull:\r
315                 return new PullCommand;\r
316         case cmdFetch:\r
317                 return new FetchCommand;\r
318         case cmdPush:\r
319                 return new PushCommand;\r
320         case cmdBranch:\r
321                 return new BranchCommand;\r
322         case cmdTag:\r
323                 return new TagCommand;\r
324         case cmdMerge:\r
325                 return new MergeCommand;\r
326         case cmdSwitch:\r
327                 return new SwitchCommand;\r
328         case cmdExport:\r
329                 return new ExportCommand;\r
330         case cmdAdd:\r
331                 return new AddCommand;\r
332         case cmdIgnore:\r
333                 return new IgnoreCommand;\r
334         case cmdFormatPatch:\r
335                 return new FormatPatchCommand;\r
336         case cmdImportPatch:\r
337                 return new ImportPatchCommand;\r
338         case cmdBlame:\r
339                 return new BlameCommand;\r
340         case cmdSettings:\r
341                 return new SettingsCommand;\r
342         case cmdConflictEditor:\r
343                 return new ConflictEditorCommand;\r
344         case cmdCleanup:\r
345                 return new CleanupCommand;\r
346         case cmdRebase:\r
347                 return new RebaseCommand;\r
348         case cmdResolve:\r
349                 return new ResolveCommand;\r
350         case cmdDropMove:\r
351                 return new DropMoveCommand;\r
352 //      case cmdDropCopy:\r
353 //              return new DropCopyCommand;\r
354 //      case cmdDropCopyAdd:\r
355 //              return new DropCopyAddCommand;\r
356 //      case cmdDropExport:\r
357 //              return new DropExportCommand;\r
358         case cmdHelp:\r
359                 return new HelpCommand;\r
360         case cmdStashSave:\r
361                 return new StashSaveCommand;\r
362         case cmdStashApply:\r
363                 return new StashApplyCommand;\r
364         case cmdStashPop:\r
365                 return new StashPopCommand;\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 cmdRefBrowse:\r
379                 return new RefBrowseCommand;\r
380         case cmdSVNDCommit:\r
381                 return new SVNDCommitCommand;\r
382         case cmdSVNRebase:\r
383                 return new SVNRebaseCommand;\r
384         case cmdSync:\r
385                 return new SyncCommand;\r
386 #if 0\r
387 \r
388         \r
389         case cmdCheckout:\r
390                 return new CheckoutCommand;\r
391 \r
392 \r
393         \r
394         case cmdCopy:\r
395                 return new CopyCommand;\r
396         case cmdCrash:\r
397                 return new CrashCommand;\r
398         case cmdCreatePatch:\r
399                 return new CreatePatchCommand;\r
400         case cmdDelUnversioned:\r
401                 return new DelUnversionedCommand;\r
402 \r
403 \r
404 \r
405         case cmdImport:\r
406                 return new ImportCommand;\r
407         case cmdLock:\r
408                 return new LockCommand;\r
409         case cmdMergeAll:\r
410                 return new MergeAllCommand;\r
411         case cmdPasteCopy:\r
412                 return new PasteCopyCommand;\r
413         case cmdPasteMove:\r
414                 return new PasteMoveCommand;\r
415         case cmdPrevDiff:\r
416                 return new PrevDiffCommand;\r
417         case cmdProperties:\r
418                 return new PropertiesCommand;\r
419         case cmdRTFM:\r
420                 return new RTFMCommand;\r
421         case cmdRebuildIconCache:\r
422                 return new RebuildIconCacheCommand;\r
423         case cmdRelocate:\r
424                 return new RelocateCommand;\r
425         case cmdRepoBrowser:\r
426                 return new RepositoryBrowserCommand;\r
427         case cmdRevisionGraph:\r
428                 return new RevisionGraphCommand;\r
429         case cmdShowCompare:\r
430                 return new ShowCompareCommand;\r
431         case cmdUnIgnore:\r
432                 return new UnIgnoreCommand;\r
433         case cmdUnlock:\r
434                 return new UnLockCommand;\r
435         case cmdUpdate:\r
436                 return new UpdateCommand;\r
437         case cmdUpdateCheck:\r
438                 return new UpdateCheckCommand;\r
439         case cmdUrlDiff:\r
440                 return new UrlDiffCommand;\r
441 #endif\r
442         default:\r
443                 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);\r
444                 return new AboutCommand;\r
445         }\r
446 }\r