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.
22 #include "GitBlameLogList.h"
24 #include "TortoiseGitBlameDoc.h"
25 #include "TortoiseGitBlameView.h"
27 #include "CommonAppUtils.h"
29 IMPLEMENT_DYNAMIC(CGitBlameLogList
, CHintListCtrl
)
31 void CGitBlameLogList::hideUnimplementedCommands()
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
)
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
);
52 CString procCmd
= _T("/path:\"");
53 procCmd
+= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName();
55 procCmd
+= _T(" /rev:")+this->m_logEntries
.GetGitRevAt(indexNext
).m_CommitHash
.ToString();
57 procCmd
+= _T(" /command:");
62 procCmd
+= _T("diff /udiff");
64 case ID_COMPAREWITHPREVIOUS
:
65 if (indexNext
+ 1 < m_logEntries
.size()) // cannot diff previous revision in first revision
67 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();
74 case ID_COPYCLIPBOARD
:
76 CopySelectionToClipBoard();
81 CopySelectionToClipBoard(ID_COPY_HASH
);
85 procCmd
+= _T("export");
87 case ID_CREATE_BRANCH
:
88 procCmd
+= _T("branch");
94 procCmd
+= _T("switch");
97 procCmd
+= _T("blame");
98 procCmd
+= _T(" /endrev:") + this->m_logEntries
.GetGitRevAt(indexNext
).m_CommitHash
.ToString();
101 procCmd
+= _T("log");
104 procCmd
.Format(_T("/command:repobrowser /path:\"%s\" /rev:%s"), g_Git
.m_CurrentDir
, this->m_logEntries
.GetGitRevAt(indexNext
).m_CommitHash
.ToString());
107 //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
111 CCommonAppUtils::RunTortoiseGitProc(procCmd
);