Dropped unused code
[TortoiseGit.git] / src / TortoiseGitBlame / LogListBlameAction.cpp
blob1810a922c2cba139ea50167e2661fa49f9108869
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2011-2012 Sven Strickroth <email@cs-ware.de>
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.
21 #include "stdafx.h"
22 #include "GitBlameLogList.h"
23 #include "GitRev.h"
24 #include "TortoiseGitBlameDoc.h"
25 #include "TortoiseGitBlameView.h"
26 #include "MainFrm.h"
27 #include "CommonAppUtils.h"
29 IMPLEMENT_DYNAMIC(CGitBlameLogList, CHintListCtrl)
31 void CGitBlameLogList::hideUnimplementedCommands()
33 hideFromContextMenu(
34 GetContextMenuBit(ID_COMPAREWITHPREVIOUS) |
35 GetContextMenuBit(ID_COPYCLIPBOARD) |
36 GetContextMenuBit(ID_COPYHASH) |
37 GetContextMenuBit(ID_EXPORT) |
38 GetContextMenuBit(ID_CREATE_BRANCH) |
39 GetContextMenuBit(ID_CREATE_TAG) |
40 GetContextMenuBit(ID_SWITCHTOREV)
41 , true);
42 m_ContextMenuMask |= GetContextMenuBit(ID_LOG) | GetContextMenuBit(ID_BLAME) | GetContextMenuBit(ID_REPOBROWSE);
45 void CGitBlameLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect,CMenu * menu)
47 POSITION pos = GetFirstSelectedItemPosition();
48 int indexNext = GetNextSelectedItem(pos);
49 if (indexNext < 0)
50 return;
52 CString procCmd;
54 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
56 bool bOpenWith = false;
58 procCmd += _T("/path:\"");
59 procCmd += ((CMainFrame*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName();
60 procCmd += _T("\" ");
61 procCmd += _T(" /rev:")+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString();
63 procCmd += _T(" /command:");
65 switch (cmd)
67 case ID_GNUDIFF1:
68 procCmd += _T("diff /udiff");
69 break;
71 #if 0
72 case ID_GNUDIFF2:
74 CString tempfile=GetTempFile();
75 CString cmd;
76 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
77 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
78 cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
79 g_Git.RunLogFile(cmd,tempfile);
80 CAppUtils::StartUnifiedDiffViewer(tempfile, r1->m_CommitHash.Left(g_Git.GetShortHASHLength()) + _T(":") + r2->m_CommitHash.Left(g_Git.GetShortHASHLength()));
83 break;
84 #endif
85 #if 0
86 case ID_COMPARETWO:
88 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
89 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
90 CFileDiffDlg dlg;
91 dlg.SetDiff(NULL,*r1,*r2);
92 dlg.DoModal();
95 break;
96 #endif
97 #if 0
98 case ID_COMPARE:
100 GitRev * r1 = &m_wcRev;
101 GitRev * r2 = pSelLogEntry;
102 CFileDiffDlg dlg;
103 dlg.SetDiff(NULL,*r1,*r2);
104 dlg.DoModal();
106 //user clicked on the menu item "compare with working copy"
107 //if (PromptShown())
109 // GitDiff diff(this, m_hWnd, true);
110 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
111 // diff.SetHEADPeg(m_LogRevision);
112 // diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
114 //else
115 // CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
117 break;
118 case ID_COMPARE:
119 procCmd+=CString(_T("diff \rev1:"))+CString(GIT_REV_ZERO)+CString(_T(" \rev2:"))+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString();
120 break;
121 #endif
122 case ID_COMPAREWITHPREVIOUS:
123 if (indexNext + 1 < m_logEntries.size()) // cannot diff previous revision in first revision
125 procCmd+=CString(_T("diff /startrev:"))+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString()+CString(_T(" /endrev:"))+this->m_logEntries.GetGitRevAt(indexNext+1).m_CommitHash.ToString();
127 else
129 return;
131 break;
132 case ID_COPYCLIPBOARD:
134 CopySelectionToClipBoard();
136 return;
137 case ID_COPYHASH:
139 CopySelectionToClipBoard(TRUE);
141 return;
142 case ID_EXPORT:
143 procCmd += _T("export");
144 break;
145 case ID_CREATE_BRANCH:
146 procCmd += _T("branch");
147 break;
148 case ID_CREATE_TAG:
149 procCmd += _T("tag");
150 break;
151 case ID_SWITCHTOREV:
152 procCmd += _T("switch");
153 break;
154 case ID_BLAME:
155 procCmd += _T("blame");
156 procCmd += _T(" /endrev:") + this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString();
157 break;
158 case ID_LOG:
159 procCmd += _T("log");
160 break;
161 case ID_REPOBROWSE:
162 procCmd.Format(_T("/command:repobrowser /path:\"%s\" /rev:%s"), g_Git.m_CurrentDir, this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString());
163 break;
164 default:
165 //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
166 return;
168 #if 0
170 case ID_REVERTREV:
172 // we need an URL to complete this command, so error out if we can't get an URL
173 if (pathURL.IsEmpty())
175 CString strMessage;
176 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
177 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
178 TRACE(_T("could not retrieve the URL of the folder!\n"));
179 break; //exit
181 CString msg;
182 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
183 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
185 CGitProgressDlg dlg;
186 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
187 dlg.SetPathList(CTGitPathList(m_path));
188 dlg.SetUrl(pathURL);
189 dlg.SetSecondUrl(pathURL);
190 revisionRanges.AdjustForMerge(true);
191 dlg.SetRevisionRanges(revisionRanges);
192 dlg.SetPegRevision(m_LogRevision);
193 dlg.DoModal();
196 break;
197 case ID_FINDENTRY:
199 m_nSearchIndex = GetSelectionMark();
200 if (m_nSearchIndex < 0)
201 m_nSearchIndex = 0;
202 if (m_pFindDialog)
204 break;
206 else
208 m_pFindDialog = new CFindReplaceDialog();
209 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
212 break;
213 #endif
215 } // switch (cmd)
217 CCommonAppUtils::RunTortoiseProc(procCmd);