1 // GitLogList.cpp : implementation file
\r
4 Description: qgit revision list view
\r
6 Author: Marco Costalba (C) 2005-2007
\r
8 Copyright: See COPYING file that comes with this distribution
\r
12 #include "TortoiseProc.h"
\r
13 #include "GitLogList.h"
\r
15 //#include "VssStyle.h"
\r
16 #include "IconMenu.h"
\r
19 #include "InputDlg.h"
\r
20 #include "PropDlg.h"
\r
21 #include "SVNProgressDlg.h"
\r
22 #include "ProgressDlg.h"
\r
23 #include "SysProgressDlg.h"
\r
24 //#include "RepositoryBrowser.h"
\r
25 //#include "CopyDlg.h"
\r
26 //#include "StatGraphDlg.h"
\r
28 #include "MessageBox.h"
\r
29 #include "Registry.h"
\r
30 #include "AppUtils.h"
\r
31 #include "PathUtils.h"
\r
32 #include "StringUtils.h"
\r
33 #include "UnicodeUtils.h"
\r
34 #include "TempFile.h"
\r
35 //#include "GitInfo.h"
\r
36 //#include "GitDiff.h"
\r
37 #include "IconMenu.h"
\r
38 //#include "RevisionRangeDlg.h"
\r
39 //#include "BrowseFolder.h"
\r
40 //#include "BlameDlg.h"
\r
41 //#include "Blame.h"
\r
42 //#include "GitHelpers.h"
\r
43 #include "GitStatus.h"
\r
44 //#include "LogDlgHelper.h"
\r
45 //#include "CachedLogInfo.h"
\r
46 //#include "RepositoryInfo.h"
\r
47 //#include "EditPropertiesDlg.h"
\r
48 #include "FileDiffDlg.h"
\r
49 #include "CommitDlg.h"
\r
50 #include "RebaseDlg.h"
\r
52 IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl)
\r
54 int CGitLogList::CherryPickFrom(CString from, CString to)
\r
56 CLogDataVector logs;
\r
57 if(logs.ParserFromLog(NULL,-1,0,&from,&to))
\r
60 if(logs.size() == 0)
\r
63 CSysProgressDlg progress;
\r
64 if (progress.IsValid())
\r
66 progress.SetTitle(_T("Cherry Pick"));
\r
67 progress.SetAnimation(IDR_MOVEANI);
\r
68 progress.SetTime(true);
\r
69 progress.ShowModeless(this);
\r
72 for(int i=logs.size()-1;i>=0;i--)
\r
74 if (progress.IsValid())
\r
76 progress.FormatPathLine(1, _T("Pick up %s"), logs[i].m_CommitHash);
\r
77 progress.FormatPathLine(2, _T("%s"), logs[i].m_Subject);
\r
78 progress.SetProgress(logs.size()-i, logs.size());
\r
80 if ((progress.IsValid())&&(progress.HasUserCancelled()))
\r
82 //CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION);
\r
83 throw std::exception(CUnicodeUtils::GetUTF8(_T("User canceled\r\n\r\n")));
\r
87 cmd.Format(_T("git.exe cherry-pick %s"),logs[i].m_CommitHash);
\r
89 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
91 throw std::exception(CUnicodeUtils::GetUTF8(CString(_T("Cherry Pick Failure\r\n\r\n"))+out));
\r
99 void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
\r
101 POSITION pos = GetFirstSelectedItemPosition();
\r
102 int indexNext = GetNextSelectedItem(pos);
\r
106 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
108 theApp.DoWaitCursor(1);
\r
109 bool bOpenWith = false;
\r
110 switch (cmd&0xFFFF)
\r
114 CTGitPathList pathlist;
\r
115 bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));
\r
116 CAppUtils::Commit(CString(),true,CString(),
\r
117 pathlist,pathlist,bSelectFilesForCommit);
\r
119 this->GetParent()->PostMessage(WM_COMMAND,ID_LOGDLG_REFRESH,0);
\r
124 CString tempfile=GetTempFile();
\r
126 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
127 cmd.Format(_T("git.exe diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
128 g_Git.RunLogFile(cmd,tempfile);
\r
129 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
135 CString tempfile=GetTempFile();
\r
137 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
138 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
139 cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
140 g_Git.RunLogFile(cmd,tempfile);
\r
141 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
146 case ID_COMPARETWO:
\r
148 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
149 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
151 dlg.SetDiff(NULL,*r1,*r2);
\r
160 GitRev * r1 = &m_wcRev;
\r
161 GitRev * r2 = pSelLogEntry;
\r
163 dlg.SetDiff(NULL,*r1,*r2);
\r
166 //user clicked on the menu item "compare with working copy"
\r
167 //if (PromptShown())
\r
169 // GitDiff diff(this, m_hWnd, true);
\r
170 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
171 // diff.SetHEADPeg(m_LogRevision);
\r
172 // diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
175 // CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
179 case ID_COMPAREWITHPREVIOUS:
\r
184 if(pSelLogEntry->m_ParentHash.size()>0)
\r
185 //if(m_logEntries.m_HashMap[pSelLogEntry->m_ParentHash[0]]>=0)
\r
187 dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash,pSelLogEntry->m_ParentHash[0]);
\r
191 CMessageBox::Show(NULL,_T("No previous version"),_T("TortoiseGit"),MB_OK);
\r
193 //if (PromptShown())
\r
195 // GitDiff diff(this, m_hWnd, true);
\r
196 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
197 // diff.SetHEADPeg(m_LogRevision);
\r
198 // diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
201 // CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
204 case ID_COPYCLIPBOARD:
\r
206 CopySelectionToClipBoard();
\r
211 CopySelectionToClipBoard(TRUE);
\r
215 CAppUtils::Export(&pSelLogEntry->m_CommitHash);
\r
217 case ID_CREATE_BRANCH:
\r
218 CAppUtils::CreateBranchTag(FALSE,&pSelLogEntry->m_CommitHash);
\r
222 case ID_CREATE_TAG:
\r
223 CAppUtils::CreateBranchTag(TRUE,&pSelLogEntry->m_CommitHash);
\r
227 case ID_SWITCHTOREV:
\r
228 CAppUtils::Switch(&pSelLogEntry->m_CommitHash);
\r
233 CAppUtils::GitReset(&pSelLogEntry->m_CommitHash);
\r
237 case ID_REBASE_PICK:
\r
238 SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_PICK);
\r
240 case ID_REBASE_EDIT:
\r
241 SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_EDIT);
\r
243 case ID_REBASE_SQUASH:
\r
244 SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);
\r
246 case ID_REBASE_SKIP:
\r
247 SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SKIP);
\r
249 case ID_COMBINE_COMMIT:
\r
253 CString hashFirst,hashLast;
\r
255 int headindex=GetHeadIndex();
\r
256 if(headindex>=0) //incase show all branch, head is not the first commits.
\r
258 head.Format(_T("HEAD~%d"),FirstSelect-headindex);
\r
259 hashFirst=g_Git.GetHash(head);
\r
261 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
262 hashLast=g_Git.GetHash(head);
\r
265 GitRev* pFirstEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
266 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
267 if(pFirstEntry->m_CommitHash != hashFirst || pLastEntry->m_CommitHash != hashLast)
\r
269 CMessageBox::Show(NULL,_T(
\r
270 "Cannot combine commits now.\r\n\
\r
271 Make sure you are viewing the log of your current branch and \
\r
272 no filters are applied."),_T("TortoiseGit"),MB_OK);
\r
276 headhash=g_Git.GetHash(CString(_T("HEAD")));
\r
278 if(!g_Git.CheckCleanWorkTree())
\r
280 CMessageBox::Show(NULL,_T("Combine needs a clean work tree"),_T("TortoiseGit"),MB_OK);
\r
285 //Use throw to abort this process (reset back to original HEAD)
\r
288 cmd.Format(_T("git.exe reset --hard %s"),pFirstEntry->m_CommitHash);
\r
289 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
291 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);
\r
292 throw std::exception(CUnicodeUtils::GetUTF8(_T("Could not reset to first commit (first step) aborting...\r\n\r\n")+out));
\r
294 cmd.Format(_T("git.exe reset --mixed %s"),hashLast);
\r
295 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
297 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);
\r
298 throw std::exception(CUnicodeUtils::GetUTF8(_T("Could not reset to last commit (second step) aborting...\r\n\r\n")+out));
\r
301 for(int i=FirstSelect;i<=LastSelect;i++)
\r
303 GitRev* pRev = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
304 dlg.m_sLogMessage+=pRev->m_Subject+_T("\n")+pRev->m_Body;
\r
305 dlg.m_sLogMessage+=_T("\n");
\r
307 dlg.m_bWholeProject=true;
\r
308 dlg.m_bSelectFilesForCommit = true;
\r
309 dlg.m_bCommitAmend=true;
\r
310 dlg.m_AmendStr=dlg.m_sLogMessage;
\r
313 if (dlg.DoModal() == IDOK)
\r
315 if(pFirstEntry->m_CommitHash!=headhash)
\r
317 //Commitrange firstEntry..headhash (from top of combine to original head) needs to be 'cherry-picked'
\r
318 //on top of new commit.
\r
319 //Use the rebase --onto command for it.
\r
321 //All this can be done in one step using the following command:
\r
322 //cmd.Format(_T("git.exe format-patch --stdout --binary --full-index -k %s..%s | git am -k -3"),
\r
323 // pFirstEntry->m_CommitHash,
\r
325 //But I am not sure if a '|' is going to work in a CreateProcess() call.
\r
327 //Later the progress dialog could be used to execute these steps.
\r
329 if(CherryPickFrom(pFirstEntry->m_CommitHash,headhash))
\r
332 msg.Format(_T("Error while cherry pick commits on top of combined commits. Aborting.\r\n\r\n"));
\r
333 throw std::exception(CUnicodeUtils::GetUTF8(msg));
\r
336 CString currentBranch=g_Git.GetCurrentBranch();
\r
337 cmd.Format(_T("git.exe rebase --onto \"%s\" %s %s"),
\r
339 pFirstEntry->m_CommitHash,
\r
341 if(g_Git.Run(cmd,&out,CP_UTF8)!=0)
\r
344 msg.Format(_T("Error while rebasing commits on top of combined commits. Aborting.\r\n\r\n%s"),out);
\r
345 // CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK);
\r
346 g_Git.Run(_T("git.exe rebase --abort"),&out,CP_UTF8);
\r
347 throw std::exception(CUnicodeUtils::GetUTF8(msg));
\r
350 //HEAD is now on <no branch>.
\r
351 //The following steps are to get HEAD back on the original branch and reset the branch to the new HEAD
\r
352 //To avoid 2 working copy changes, we could use git branch -f <original branch> <hash new head>
\r
353 //And then git checkout <original branch>
\r
354 //But I don't know if 'git branch -f' removes tracking options. So for now, do a checkout and a reset.
\r
357 CString newHead=g_Git.GetHash(CString(_T("HEAD")));
\r
359 //Checkout working branch
\r
360 cmd.Format(_T("git.exe checkout -f \"%s\""),currentBranch);
\r
361 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
362 throw std::exception(CUnicodeUtils::GetUTF8(_T("Could not checkout original branch. Aborting...\r\n\r\n")+out));
\r
364 //Reset to new HEAD
\r
365 cmd.Format(_T("git.exe reset --hard %s"),newHead);
\r
366 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
367 throw std::exception(CUnicodeUtils::GetUTF8(_T("Could not reset to new head. Aborting...\r\n\r\n")+out));
\r
372 throw std::exception("User aborted the combine process");
\r
374 catch(std::exception& e)
\r
376 CMessageBox::Show(NULL,CUnicodeUtils::GetUnicode(CStringA(e.what())),_T("TortoiseGit: Combine error"),MB_OK|MB_ICONERROR);
\r
377 cmd.Format(_T("git.exe reset --hard %s"),headhash);
\r
379 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
381 CMessageBox::Show(NULL,_T("Could not reset to original HEAD\r\n\r\n")+out,_T("TortoiseGit"),MB_OK);
\r
388 case ID_CHERRY_PICK:
\r
389 if(!g_Git.CheckCleanWorkTree())
\r
391 CMessageBox::Show(NULL,_T("Cherry Pick requires a clean working tree"),_T("TortoiseGit"),MB_OK);
\r
396 dlg.m_IsCherryPick = TRUE;
\r
397 dlg.m_Upstream = this->m_CurrentBranch;
\r
398 POSITION pos = GetFirstSelectedItemPosition();
\r
401 int indexNext = GetNextSelectedItem(pos);
\r
402 dlg.m_CommitList.m_logEntries.push_back(*(GitRev*)m_arShownList[indexNext]);
\r
403 dlg.m_CommitList.m_logEntries.at(dlg.m_CommitList.m_logEntries.size()-1).m_Action |= CTGitPath::LOGACTIONS_REBASE_PICK;
\r
406 if(dlg.DoModal() == IDOK)
\r
412 case ID_REBASE_TO_VERSION:
\r
413 if(!g_Git.CheckCleanWorkTree())
\r
415 CMessageBox::Show(NULL,_T("Rebase requires a clean working tree"),_T("TortoiseGit"),MB_OK);
\r
420 dlg.m_Upstream = pSelLogEntry->m_CommitHash;
\r
422 if(dlg.DoModal() == IDOK)
\r
430 case ID_STASH_APPLY:
\r
431 CAppUtils::StashApply(pSelLogEntry->m_Ref);
\r
434 case ID_REFLOG_DEL:
\r
437 str.Format(_T("Warning: %s will be permanently deleted. It can <ct=0x0000FF><b>NOT</b></ct> be recovered!\r\n \r\n Are you sure you want to continue?"),pSelLogEntry->m_Ref);
\r
438 if(CMessageBox::Show(NULL,str,_T("TortoiseGit"),MB_YESNO|MB_ICONWARNING) == IDYES)
\r
441 cmd.Format(_T("git.exe reflog delete %s"),pSelLogEntry->m_Ref);
\r
442 if(g_Git.Run(cmd,&out,CP_ACP))
\r
444 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);
\r
446 ::PostMessage(this->GetParent()->m_hWnd,MSG_REFLOG_CHANGED,0,0);
\r
450 case ID_CREATE_PATCH:
\r
452 int select=this->GetSelectedCount();
\r
454 cmd = CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe");
\r
455 cmd += _T(" /command:formatpatch");
\r
457 cmd += _T(" /path:")+g_Git.m_CurrentDir+_T(" ");
\r
459 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
460 GitRev * r2 = NULL;
\r
463 cmd += _T(" /startrev:")+r1->m_CommitHash;
\r
467 r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
468 if( this->m_IsOldFirst )
\r
470 cmd += _T(" /startrev:")+r1->m_CommitHash+_T("~1");
\r
471 cmd += _T(" /endrev:")+r2->m_CommitHash;
\r
475 cmd += _T(" /startrev:")+r2->m_CommitHash+_T("~1");
\r
476 cmd += _T(" /endrev:")+r1->m_CommitHash;
\r
481 CAppUtils::LaunchApplication(cmd,IDS_ERR_PROC,false);
\r
486 int index = cmd>>16;
\r
487 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) == m_HashMap.end() )
\r
489 CMessageBox::Show(NULL,IDS_ERROR_NOREF,IDS_APPNAME,MB_OK|MB_ICONERROR);
\r
492 if( index >= m_HashMap[pSelLogEntry->m_CommitHash].size())
\r
494 CMessageBox::Show(NULL,IDS_ERROR_INDEX,IDS_APPNAME,MB_OK|MB_ICONERROR);
\r
498 ref=m_HashMap[pSelLogEntry->m_CommitHash][index];
\r
500 msg=CString(_T("<ct=0x0000FF>Delete</ct> <b>"))+ref;
\r
501 msg+=_T("</b>\n\n Are you sure?");
\r
502 if( CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_YESNO) == IDYES )
\r
506 if(this->GetShortName(ref,shortname,_T("refs/heads/")))
\r
508 cmd.Format(_T("git.exe branch -D %s"),shortname);
\r
511 if(this->GetShortName(ref,shortname,_T("refs/remotes/")))
\r
513 cmd.Format(_T("git.exe branch -r -D %s"),shortname);
\r
516 if(this->GetShortName(ref,shortname,_T("refs/tags/")))
\r
518 cmd.Format(_T("git.exe tag -d %s"),shortname);
\r
521 if(this->GetShortName(ref,shortname,_T("refs/stash")))
\r
523 if(CMessageBox::Show(NULL,_T("<ct=0x0000FF>Are you sure remove <b>ALL</b> stash?</ct>"),
\r
524 _T("TortoiseGit"),MB_YESNO)==IDYES)
\r
525 cmd.Format(_T("git.exe stash clear"));
\r
531 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
533 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);
\r
535 this->ReloadHashMap();
\r
537 this->GetItemRect(FirstSelect,&rect,LVIR_BOUNDS);
\r
538 this->InvalidateRect(rect);
\r
543 //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
\r
549 // we need an URL to complete this command, so error out if we can't get an URL
\r
550 if (pathURL.IsEmpty())
\r
552 CString strMessage;
\r
553 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
554 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
555 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
559 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
560 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
562 CGitProgressDlg dlg;
\r
563 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
564 dlg.SetPathList(CTGitPathList(m_path));
\r
565 dlg.SetUrl(pathURL);
\r
566 dlg.SetSecondUrl(pathURL);
\r
567 revisionRanges.AdjustForMerge(true);
\r
568 dlg.SetRevisionRanges(revisionRanges);
\r
569 dlg.SetPegRevision(m_LogRevision);
\r
576 // we need an URL to complete this command, so error out if we can't get an URL
\r
577 if (pathURL.IsEmpty())
\r
579 CString strMessage;
\r
580 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
581 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
582 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
586 CString path = m_path.GetWinPathString();
\r
587 bool bGotSavePath = false;
\r
588 if ((GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
590 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
594 CBrowseFolder folderBrowser;
\r
595 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
596 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
600 CGitProgressDlg dlg;
\r
601 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
602 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
603 dlg.SetUrl(pathURL);
\r
604 dlg.SetSecondUrl(pathURL);
\r
605 revisionRanges.AdjustForMerge(false);
\r
606 dlg.SetRevisionRanges(revisionRanges);
\r
607 dlg.SetPegRevision(m_LogRevision);
\r
612 case ID_REVERTTOREV:
\r
614 // we need an URL to complete this command, so error out if we can't get an URL
\r
615 if (pathURL.IsEmpty())
\r
617 CString strMessage;
\r
618 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
619 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
620 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
625 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
626 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
628 CGitProgressDlg dlg;
\r
629 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
630 dlg.SetPathList(CTGitPathList(m_path));
\r
631 dlg.SetUrl(pathURL);
\r
632 dlg.SetSecondUrl(pathURL);
\r
633 GitRevRangeArray revarray;
\r
634 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
635 dlg.SetRevisionRanges(revarray);
\r
636 dlg.SetPegRevision(m_LogRevision);
\r
644 case ID_BLAMECOMPARE:
\r
646 //user clicked on the menu item "compare with working copy"
\r
647 //now first get the revision which is selected
\r
650 GitDiff diff(this, this->m_hWnd, true);
\r
651 diff.SetHEADPeg(m_LogRevision);
\r
652 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
655 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
660 //user clicked on the menu item "compare and blame revisions"
\r
663 GitDiff diff(this, this->m_hWnd, true);
\r
664 diff.SetHEADPeg(m_LogRevision);
\r
665 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
668 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
671 case ID_BLAMEWITHPREVIOUS:
\r
673 //user clicked on the menu item "Compare and Blame with previous revision"
\r
676 GitDiff diff(this, this->m_hWnd, true);
\r
677 diff.SetHEADPeg(m_LogRevision);
\r
678 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
681 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
689 CProgressDlg progDlg;
\r
690 progDlg.SetTitle(IDS_APPNAME);
\r
691 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
693 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
694 progDlg.SetLine(1, sInfoLine, true);
\r
695 SetAndClearProgressInfo(&progDlg);
\r
696 progDlg.ShowModeless(m_hWnd);
\r
697 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
698 bool bSuccess = true;
\r
699 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
702 // try again, but with the selected revision as the peg revision
\r
703 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
706 SetAndClearProgressInfo((HWND)NULL);
\r
707 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
716 SetAndClearProgressInfo((HWND)NULL);
\r
717 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
720 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
721 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
723 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
724 cmd += tempfile.GetWinPathString() + _T(" ");
\r
725 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
733 dlg.EndRev = revSelected;
\r
734 if (dlg.DoModal() == IDOK)
\r
739 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
740 if (!tempfile.IsEmpty())
\r
742 if (dlg.m_bTextView)
\r
744 //open the default text editor for the result file
\r
745 CAppUtils::StartTextViewer(tempfile);
\r
749 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
750 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
758 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
766 CString url = _T("tgit:")+pathURL;
\r
767 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
768 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
769 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
770 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
775 m_nSearchIndex = GetSelectionMark();
\r
776 if (m_nSearchIndex < 0)
\r
777 m_nSearchIndex = 0;
\r
784 m_pFindDialog = new CFindReplaceDialog();
\r
785 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
789 case ID_REPOBROWSE:
\r
792 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
793 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
794 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
796 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
801 EditLogMessage(selIndex);
\r
804 case ID_EDITAUTHOR:
\r
806 EditAuthor(selEntries);
\r
811 CEditPropertiesDlg dlg;
\r
812 dlg.SetProjectProperties(&m_ProjectProperties);
\r
813 CTGitPathList escapedlist;
\r
814 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
815 dlg.SetRevision(revSelected);
\r
816 dlg.RevProps(true);
\r
824 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
825 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
826 (LPCTSTR)pathURL, (LONG)revSelected);
\r
827 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
833 CString url = _T("tgit:")+pathURL;
\r
834 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
835 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
836 (LPCTSTR)url, (LONG)revSelected);
\r
837 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
842 CString url = m_ProjectProperties.sWebViewerRev;
\r
843 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
844 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
845 if (!url.IsEmpty())
\r
846 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
849 case ID_VIEWPATHREV:
\r
851 CString relurl = pathURL;
\r
852 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
853 relurl = relurl.Mid(sRoot.GetLength());
\r
854 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
855 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
856 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
857 url.Replace(_T("%PATH%"), relurl);
\r
858 if (!url.IsEmpty())
\r
859 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
866 theApp.DoWaitCursor(-1);
\r
869 void CGitLogList::SetSelectedAction(int action)
\r
871 POSITION pos = GetFirstSelectedItemPosition();
\r
875 index = GetNextSelectedItem(pos);
\r
876 ((GitRev*)m_arShownList[index])->m_Action = action;
\r
878 this->GetItemRect(index,&rect,LVIR_BOUNDS);
\r
879 this->InvalidateRect(rect);
\r