1 // GitLogList.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "GitLogList.h"
\r
8 //#include "VssStyle.h"
\r
9 #include "IconMenu.h"
\r
12 #include "InputDlg.h"
\r
13 #include "PropDlg.h"
\r
14 #include "SVNProgressDlg.h"
\r
15 #include "ProgressDlg.h"
\r
16 //#include "RepositoryBrowser.h"
\r
17 //#include "CopyDlg.h"
\r
18 //#include "StatGraphDlg.h"
\r
20 #include "MessageBox.h"
\r
21 #include "Registry.h"
\r
22 #include "AppUtils.h"
\r
23 #include "PathUtils.h"
\r
24 #include "StringUtils.h"
\r
25 #include "UnicodeUtils.h"
\r
26 #include "TempFile.h"
\r
27 //#include "GitInfo.h"
\r
28 //#include "GitDiff.h"
\r
29 #include "IconMenu.h"
\r
30 //#include "RevisionRangeDlg.h"
\r
31 //#include "BrowseFolder.h"
\r
32 //#include "BlameDlg.h"
\r
33 //#include "Blame.h"
\r
34 //#include "GitHelpers.h"
\r
35 #include "GitStatus.h"
\r
36 //#include "LogDlgHelper.h"
\r
37 //#include "CachedLogInfo.h"
\r
38 //#include "RepositoryInfo.h"
\r
39 //#include "EditPropertiesDlg.h"
\r
40 #include "FileDiffDlg.h"
\r
45 IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl)
\r
47 CGitLogList::CGitLogList():CHintListCtrl()
\r
48 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
51 // use the default GUI font, create a copy of it and
\r
52 // change the copy to BOLD (leave the rest of the font
\r
54 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
56 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
57 lf.lfWeight = FW_BOLD;
\r
58 m_boldFont = CreateFontIndirect(&lf);
\r
62 CGitLogList::~CGitLogList()
\r
64 DestroyIcon(m_hModifiedIcon);
\r
65 DestroyIcon(m_hReplacedIcon);
\r
66 DestroyIcon(m_hAddedIcon);
\r
67 DestroyIcon(m_hDeletedIcon);
\r
68 m_logEntries.ClearAll();
\r
71 DeleteObject(m_boldFont);
\r
76 BEGIN_MESSAGE_MAP(CGitLogList, CHintListCtrl)
\r
77 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
78 ON_NOTIFY(LVN_GETDISPINFO, 0, OnLvnGetdispinfoLoglist)
\r
80 ON_NOTIFY(NM_DBLCLK, 0, OnNMDblclkLoglist)
\r
81 ON_NOTIFY(LVN_ODFINDITEM, IDC_LOGLIST, OnLvnOdfinditemLoglist)
\r
84 int CGitLogList:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
86 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
87 // load the icons for the action columns
\r
88 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
89 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
90 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
91 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
93 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
96 void CGitLogList::InsertGitColumn()
\r
100 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
104 temp.LoadString(IDS_LOG_GRAPH);
\r
106 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
109 // make the revision column right aligned
\r
111 Column.mask = LVCF_FMT;
\r
112 Column.fmt = LVCFMT_RIGHT;
\r
113 SetColumn(0, &Column);
\r
116 // g_Git.GetLog(log);
\r
118 temp.LoadString(IDS_LOG_ACTIONS);
\r
119 InsertColumn(this->LOGLIST_ACTION, temp);
\r
121 temp.LoadString(IDS_LOG_MESSAGE);
\r
122 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
124 temp.LoadString(IDS_LOG_AUTHOR);
\r
125 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
127 temp.LoadString(IDS_LOG_DATE);
\r
128 InsertColumn(this->LOGLIST_DATE, temp);
\r
131 if (m_bShowBugtraqColumn)
\r
133 // temp = m_ProjectProperties.sLabel;
\r
134 if (temp.IsEmpty())
\r
135 temp.LoadString(IDS_LOG_BUGIDS);
\r
136 InsertColumn(this->LOGLIST_BUG, temp);
\r
141 ResizeAllListCtrlCols();
\r
146 void CGitLogList::ResizeAllListCtrlCols()
\r
149 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
150 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
151 int nItemCount = GetItemCount();
\r
152 TCHAR textbuf[MAX_PATH];
\r
153 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
156 for (int col = 0; col <= maxcol; col++)
\r
159 hdi.mask = HDI_TEXT;
\r
160 hdi.pszText = textbuf;
\r
161 hdi.cchTextMax = sizeof(textbuf);
\r
162 pHdrCtrl->GetItem(col, &hdi);
\r
163 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
164 for (int index = 0; index<nItemCount; ++index)
\r
166 // get the width of the string and add 14 pixels for the column separator and margins
\r
167 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
168 if (index < m_arShownList.GetCount())
\r
170 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
171 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
173 // set the bold font and ask for the string width again
\r
174 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
175 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
176 // restore the system font
\r
177 SendMessage(WM_SETFONT, NULL, NULL);
\r
182 // add the image size
\r
183 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
184 if ((pImgList)&&(pImgList->GetImageCount()))
\r
187 pImgList->GetImageInfo(0, &imginfo);
\r
188 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
189 linewidth += 3; // 3 pixels between icon and text
\r
192 if (cx < linewidth)
\r
195 // Adjust columns "Actions" containing icons
\r
196 if (col == this->LOGLIST_ACTION)
\r
198 if (cx < nMinimumWidth)
\r
200 cx = nMinimumWidth;
\r
204 if (col == this->LOGLIST_MESSAGE)
\r
206 if (cx > LOGLIST_MESSAGE_MAX)
\r
208 cx = LOGLIST_MESSAGE_MAX;
\r
212 // keep the bug id column small
\r
213 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
215 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
217 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
221 SetColumnWidth(col, cx);
\r
228 void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
231 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
232 // Take the default processing unless we set this to something else below.
\r
233 *pResult = CDRF_DODEFAULT;
\r
235 if (m_bNoDispUpdates)
\r
238 switch (pLVCD->nmcd.dwDrawStage)
\r
240 case CDDS_PREPAINT:
\r
242 *pResult = CDRF_NOTIFYITEMDRAW;
\r
246 case CDDS_ITEMPREPAINT:
\r
248 // This is the prepaint stage for an item. Here's where we set the
\r
249 // item's text color.
\r
251 // Tell Windows to send draw notifications for each subitem.
\r
252 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
254 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
256 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
258 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
262 if (data->bCopiedSelf)
\r
264 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
265 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
266 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
270 crText = m_Colors.GetColor(CColors::Modified);
\r
272 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
273 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
274 // if (data->Rev == m_wcRev)
\r
276 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
277 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
278 // tells the control to recalculate the extent of the text.
\r
279 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
283 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
285 if (m_bStrictStopped)
\r
286 crText = GetSysColor(COLOR_GRAYTEXT);
\r
288 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
289 pLVCD->clrText = crText;
\r
293 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
295 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
297 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
299 if (pLVCD->iSubItem == 1)
\r
301 *pResult = CDRF_DODEFAULT;
\r
303 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
307 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
308 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
310 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
312 // Get the selected state of the
\r
313 // item being drawn.
\r
315 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
316 rItem.mask = LVIF_STATE;
\r
317 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
318 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
322 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
324 // Fill the background
\r
325 if (m_Theme.IsAppThemed() && m_bVista)
\r
327 m_Theme.Open(m_hWnd, L"Explorer");
\r
328 int state = LISS_NORMAL;
\r
329 if (rItem.state & LVIS_SELECTED)
\r
331 if (::GetFocus() == m_hWnd)
\r
332 state |= LISS_SELECTED;
\r
334 state |= LISS_SELECTEDNOTFOCUS;
\r
339 if (pLogEntry->bCopiedSelf)
\r
341 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
342 // information at this drawing stage. But we can check the whether the
\r
343 // previous stage changed the background color of the item
\r
344 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
347 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
350 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
351 ::DeleteObject(brush);
\r
358 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
359 m_Theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
361 m_Theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
366 if (rItem.state & LVIS_SELECTED)
\r
368 if (::GetFocus() == m_hWnd)
\r
369 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
371 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
375 //if (pLogEntry->bCopiedSelf)
\r
376 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
378 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
383 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
384 ::DeleteObject(brush);
\r
387 // Draw the icon(s) into the compatible DC
\r
388 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
389 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
392 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
393 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
396 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
397 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
400 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
401 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
403 *pResult = CDRF_SKIPDEFAULT;
\r
409 *pResult = CDRF_DODEFAULT;
\r
413 // CGitLogList message handlers
\r
415 void CGitLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
417 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
419 // Create a pointer to the item
\r
420 LV_ITEM* pItem = &(pDispInfo)->item;
\r
422 // Do the list need text information?
\r
423 if (!(pItem->mask & LVIF_TEXT))
\r
426 // By default, clear text buffer.
\r
427 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
429 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
432 if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)
\r
435 // Which item number?
\r
436 int itemid = pItem->iItem;
\r
437 GitRev * pLogEntry = NULL;
\r
438 if (itemid < m_arShownList.GetCount())
\r
439 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
442 switch (pItem->iSubItem)
\r
444 case this->LOGLIST_GRAPH: //Graphic
\r
449 case this->LOGLIST_ACTION: //action -- no text in the column
\r
451 case this->LOGLIST_MESSAGE: //Message
\r
453 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
455 case this->LOGLIST_AUTHOR: //Author
\r
457 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
459 case this->LOGLIST_DATE: //Date
\r
461 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
472 void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
\r
475 int selIndex = GetSelectionMark();
\r
477 return; // nothing selected, nothing to do with a context menu
\r
479 // if the user selected the info text telling about not all revisions shown due to
\r
480 // the "stop on copy/rename" option, we also don't show the context menu
\r
481 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
484 // if the context menu is invoked through the keyboard, we have to use
\r
485 // a calculated position on where to anchor the menu on
\r
486 if ((point.x == -1) && (point.y == -1))
\r
489 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
490 ClientToScreen(&rect);
\r
491 point = rect.CenterPoint();
\r
493 m_nSearchIndex = selIndex;
\r
494 m_bCancelled = FALSE;
\r
496 // calculate some information the context menu commands can use
\r
497 // CString pathURL = GetURLFromPath(m_path);
\r
499 POSITION pos = GetFirstSelectedItemPosition();
\r
500 int indexNext = GetNextSelectedItem(pos);
\r
504 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
506 GitRev revSelected = pSelLogEntry->Rev;
\r
507 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
508 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
510 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
512 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
513 if (changedpath->lCopyFromRev)
\r
514 revPrevious = changedpath->lCopyFromRev;
\r
517 GitRev revSelected2;
\r
520 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
521 revSelected2 = pLogEntry->Rev;
\r
523 bool bAllFromTheSameAuthor = true;
\r
524 CString firstAuthor;
\r
525 CLogDataVector selEntries;
\r
526 GitRev revLowest, revHighest;
\r
527 GitRevRangeArray revisionRanges;
\r
529 POSITION pos = GetFirstSelectedItemPosition();
\r
530 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
531 revisionRanges.AddRevision(pLogEntry->Rev);
\r
532 selEntries.push_back(pLogEntry);
\r
533 firstAuthor = pLogEntry->sAuthor;
\r
534 revLowest = pLogEntry->Rev;
\r
535 revHighest = pLogEntry->Rev;
\r
538 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
539 revisionRanges.AddRevision(pLogEntry->Rev);
\r
540 selEntries.push_back(pLogEntry);
\r
541 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
542 bAllFromTheSameAuthor = false;
\r
543 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
544 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
550 int FirstSelect=-1, LastSelect=-1;
\r
551 pos = GetFirstSelectedItemPosition();
\r
552 FirstSelect = GetNextSelectedItem(pos);
\r
555 LastSelect = GetNextSelectedItem(pos);
\r
557 //entry is selected, now show the popup menu
\r
559 if (popup.CreatePopupMenu())
\r
561 if (GetSelectedCount() == 1)
\r
564 if (!m_path.IsDirectory())
\r
568 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
569 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
571 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
572 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
573 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
574 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
575 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
576 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
577 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
578 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
585 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
587 // TortoiseMerge could be improved to take a /blame switch
\r
588 // and then not 'cat' the files from a unified diff but
\r
590 // But until that's implemented, the context menu entry for
\r
591 // this feature is commented out.
\r
592 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
594 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
595 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
596 popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
597 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
600 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
602 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
604 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
606 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
608 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
609 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
611 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
614 // popup.AppendMenuIcon(ID_REPOBROWSE, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
\r
615 // popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPY);
\r
617 // popup.AppendMenuIcon(ID_UPDATE, IDS_LOG_POPUP_UPDATE, IDI_UPDATE);
\r
619 popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
621 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
623 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
624 popup.AppendMenuIcon(ID_CHECKOUT, IDS_MENUCHECKOUT, IDI_CHECKOUT);
\r
625 popup.AppendMenuIcon(ID_EXPORT, IDS_MENUEXPORT, IDI_EXPORT);
\r
626 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
628 else if (GetSelectedCount() >= 2)
\r
630 bool bAddSeparator = false;
\r
631 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
633 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
635 if (GetSelectedCount() == 2)
\r
637 popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
638 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
639 bAddSeparator = true;
\r
643 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
645 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
646 bAddSeparator = true;
\r
649 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
652 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
654 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
656 // if (GetSelectedCount() == 1)
\r
658 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
659 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
660 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
663 if (GetSelectedCount() != 0)
\r
665 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
667 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
669 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
670 // DialogEnableWindow(IDOK, FALSE);
\r
671 // SetPromptApp(&theApp);
\r
672 theApp.DoWaitCursor(1);
\r
673 bool bOpenWith = false;
\r
679 CString tempfile=GetTempFile();
\r
681 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
682 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
683 g_Git.RunLogFile(cmd,tempfile);
\r
684 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
690 CString tempfile=GetTempFile();
\r
692 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
693 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
694 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
695 g_Git.RunLogFile(cmd,tempfile);
\r
696 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
701 case ID_COMPARETWO:
\r
703 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
704 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
706 dlg.SetDiff(NULL,*r1,*r2);
\r
717 GitDiff diff(this, this->m_hWnd, true);
\r
718 diff.SetHEADPeg(m_LogRevision);
\r
719 diff.ShowUnifiedDiff(m_path, revPrevious, m_path, revSelected);
\r
722 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revPrevious, m_path, revSelected, GitRev(), m_LogRevision);
\r
730 GitDiff diff(this, this->m_hWnd, true);
\r
731 diff.SetHEADPeg(m_LogRevision);
\r
732 diff.ShowUnifiedDiff(m_path, revSelected2, m_path, revSelected);
\r
735 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revSelected2, m_path, revSelected, GitRev(), m_LogRevision);
\r
740 // we need an URL to complete this command, so error out if we can't get an URL
\r
741 if (pathURL.IsEmpty())
\r
743 CString strMessage;
\r
744 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
745 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
746 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
750 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
751 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
753 CGitProgressDlg dlg;
\r
754 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
755 dlg.SetPathList(CTGitPathList(m_path));
\r
756 dlg.SetUrl(pathURL);
\r
757 dlg.SetSecondUrl(pathURL);
\r
758 revisionRanges.AdjustForMerge(true);
\r
759 dlg.SetRevisionRanges(revisionRanges);
\r
760 dlg.SetPegRevision(m_LogRevision);
\r
767 // we need an URL to complete this command, so error out if we can't get an URL
\r
768 if (pathURL.IsEmpty())
\r
770 CString strMessage;
\r
771 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
772 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
773 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
777 CString path = m_path.GetWinPathString();
\r
778 bool bGotSavePath = false;
\r
779 if ((GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
781 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
785 CBrowseFolder folderBrowser;
\r
786 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
787 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
791 CGitProgressDlg dlg;
\r
792 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
793 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
794 dlg.SetUrl(pathURL);
\r
795 dlg.SetSecondUrl(pathURL);
\r
796 revisionRanges.AdjustForMerge(false);
\r
797 dlg.SetRevisionRanges(revisionRanges);
\r
798 dlg.SetPegRevision(m_LogRevision);
\r
803 case ID_REVERTTOREV:
\r
805 // we need an URL to complete this command, so error out if we can't get an URL
\r
806 if (pathURL.IsEmpty())
\r
808 CString strMessage;
\r
809 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
810 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
811 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
816 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
817 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
819 CGitProgressDlg dlg;
\r
820 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
821 dlg.SetPathList(CTGitPathList(m_path));
\r
822 dlg.SetUrl(pathURL);
\r
823 dlg.SetSecondUrl(pathURL);
\r
824 GitRevRangeArray revarray;
\r
825 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
826 dlg.SetRevisionRanges(revarray);
\r
827 dlg.SetPegRevision(m_LogRevision);
\r
834 // we need an URL to complete this command, so error out if we can't get an URL
\r
835 if (pathURL.IsEmpty())
\r
837 CString strMessage;
\r
838 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
839 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
840 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
845 dlg.m_URL = pathURL;
\r
846 dlg.m_path = m_path;
\r
847 dlg.m_CopyRev = revSelected;
\r
848 if (dlg.DoModal() == IDOK)
\r
850 // should we show a progress dialog here? Copies are done really fast
\r
851 // and without much network traffic.
\r
852 if (!Copy(CTGitPathList(CTGitPath(pathURL)), CTGitPath(dlg.m_URL), dlg.m_CopyRev, dlg.m_CopyRev, dlg.m_sLogMessage))
\r
853 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
855 CMessageBox::Show(this->m_hWnd, IDS_LOG_COPY_SUCCESS, IDS_APPNAME, MB_ICONINFORMATION);
\r
861 //user clicked on the menu item "compare with working copy"
\r
864 GitDiff diff(this, m_hWnd, true);
\r
865 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
866 diff.SetHEADPeg(m_LogRevision);
\r
867 diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
870 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
873 case ID_COMPARETWO:
\r
875 GitRev r1 = revSelected;
\r
876 GitRev r2 = revSelected2;
\r
877 if (GetSelectedCount() > 2)
\r
882 //user clicked on the menu item "compare revisions"
\r
885 GitDiff diff(this, m_hWnd, true);
\r
886 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
887 diff.SetHEADPeg(m_LogRevision);
\r
888 diff.ShowCompare(CTGitPath(pathURL), r2, CTGitPath(pathURL), r1);
\r
891 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), r2, CTGitPath(pathURL), r1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
894 case ID_COMPAREWITHPREVIOUS:
\r
898 GitDiff diff(this, m_hWnd, true);
\r
899 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
900 diff.SetHEADPeg(m_LogRevision);
\r
901 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
904 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
907 case ID_BLAMECOMPARE:
\r
909 //user clicked on the menu item "compare with working copy"
\r
910 //now first get the revision which is selected
\r
913 GitDiff diff(this, this->m_hWnd, true);
\r
914 diff.SetHEADPeg(m_LogRevision);
\r
915 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
918 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
923 //user clicked on the menu item "compare and blame revisions"
\r
926 GitDiff diff(this, this->m_hWnd, true);
\r
927 diff.SetHEADPeg(m_LogRevision);
\r
928 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
931 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
934 case ID_BLAMEWITHPREVIOUS:
\r
936 //user clicked on the menu item "Compare and Blame with previous revision"
\r
939 GitDiff diff(this, this->m_hWnd, true);
\r
940 diff.SetHEADPeg(m_LogRevision);
\r
941 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
944 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
949 //now first get the revision which is selected
\r
950 CString revFilename;
\r
953 CString strWinPath = m_path.GetWinPathString();
\r
954 int rfind = strWinPath.ReverseFind('.');
\r
956 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)strWinPath.Left(rfind), (LONG)revSelected, (LPCTSTR)strWinPath.Mid(rfind));
\r
958 revFilename.Format(_T("%s-%ld"), (LPCTSTR)strWinPath, revSelected);
\r
960 if (CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd))
\r
962 CTGitPath tempfile;
\r
963 tempfile.SetFromWin(revFilename);
\r
964 CProgressDlg progDlg;
\r
965 progDlg.SetTitle(IDS_APPNAME);
\r
966 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
968 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
969 progDlg.SetLine(1, sInfoLine, true);
\r
970 SetAndClearProgressInfo(&progDlg);
\r
971 progDlg.ShowModeless(m_hWnd);
\r
972 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
974 // try again with another peg revision
\r
975 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
978 SetAndClearProgressInfo((HWND)NULL);
\r
979 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
985 SetAndClearProgressInfo((HWND)NULL);
\r
993 CProgressDlg progDlg;
\r
994 progDlg.SetTitle(IDS_APPNAME);
\r
995 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
997 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
998 progDlg.SetLine(1, sInfoLine, true);
\r
999 SetAndClearProgressInfo(&progDlg);
\r
1000 progDlg.ShowModeless(m_hWnd);
\r
1001 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
1002 bool bSuccess = true;
\r
1003 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
1006 // try again, but with the selected revision as the peg revision
\r
1007 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
1010 SetAndClearProgressInfo((HWND)NULL);
\r
1011 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1020 SetAndClearProgressInfo((HWND)NULL);
\r
1021 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1024 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1025 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
1027 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1028 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1029 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1037 dlg.EndRev = revSelected;
\r
1038 if (dlg.DoModal() == IDOK)
\r
1043 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
1044 if (!tempfile.IsEmpty())
\r
1046 if (dlg.m_bTextView)
\r
1048 //open the default text editor for the result file
\r
1049 CAppUtils::StartTextViewer(tempfile);
\r
1053 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
1054 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
1062 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1070 CString url = _T("tgit:")+pathURL;
\r
1071 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
1072 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1073 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
1074 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1077 case ID_FINDENTRY:
\r
1079 m_nSearchIndex = GetSelectionMark();
\r
1080 if (m_nSearchIndex < 0)
\r
1081 m_nSearchIndex = 0;
\r
1082 if (m_pFindDialog)
\r
1088 m_pFindDialog = new CFindReplaceDialog();
\r
1089 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
1093 case ID_REPOBROWSE:
\r
1096 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
1097 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1098 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
1100 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1105 EditLogMessage(selIndex);
\r
1108 case ID_EDITAUTHOR:
\r
1110 EditAuthor(selEntries);
\r
1115 CEditPropertiesDlg dlg;
\r
1116 dlg.SetProjectProperties(&m_ProjectProperties);
\r
1117 CTGitPathList escapedlist;
\r
1118 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
1119 dlg.SetRevision(revSelected);
\r
1120 dlg.RevProps(true);
\r
1124 case ID_COPYCLIPBOARD:
\r
1126 CopySelectionToClipBoard();
\r
1132 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
1133 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1134 (LPCTSTR)pathURL, (LONG)revSelected);
\r
1135 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1141 CString url = _T("tgit:")+pathURL;
\r
1142 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
1143 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1144 (LPCTSTR)url, (LONG)revSelected);
\r
1145 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1150 CString url = m_ProjectProperties.sWebViewerRev;
\r
1151 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1152 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1153 if (!url.IsEmpty())
\r
1154 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1157 case ID_VIEWPATHREV:
\r
1159 CString relurl = pathURL;
\r
1160 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
1161 relurl = relurl.Mid(sRoot.GetLength());
\r
1162 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
1163 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1164 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1165 url.Replace(_T("%PATH%"), relurl);
\r
1166 if (!url.IsEmpty())
\r
1167 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1174 theApp.DoWaitCursor(-1);
\r
1175 // EnableOKButton();
\r
1176 } // if (popup.CreatePopupMenu())
\r
1180 bool CGitLogList::IsSelectionContinuous()
\r
1182 if ( GetSelectedCount()==1 )
\r
1184 // if only one revision is selected, the selection is of course
\r
1189 POSITION pos = GetFirstSelectedItemPosition();
\r
1190 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1193 int itemindex = GetNextSelectedItem(pos);
\r
1196 int nextindex = GetNextSelectedItem(pos);
\r
1197 if (nextindex - itemindex > 1)
\r
1199 bContinuous = false;
\r
1202 itemindex = nextindex;
\r
1205 return bContinuous;
\r
1208 void CGitLogList::CopySelectionToClipBoard()
\r
1211 CString sClipdata;
\r
1212 POSITION pos = GetFirstSelectedItemPosition();
\r
1216 sRev.LoadString(IDS_LOG_REVISION);
\r
1218 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1220 sDate.LoadString(IDS_LOG_DATE);
\r
1222 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1225 CString sLogCopyText;
\r
1227 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1228 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1229 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1231 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1232 sPaths += cpath->GetAction() + _T(" : ") + cpath->sPath;
\r
1233 if (cpath->sCopyFromPath.IsEmpty())
\r
1234 sPaths += _T("\r\n");
\r
1237 CString sCopyFrom;
\r
1238 sCopyFrom.Format(_T(" (%s: %s, %s, %ld)\r\n"), CString(MAKEINTRESOURCE(IDS_LOG_COPYFROM)),
\r
1239 (LPCTSTR)cpath->sCopyFromPath,
\r
1240 (LPCTSTR)CString(MAKEINTRESOURCE(IDS_LOG_REVISION)),
\r
1241 (LPCTSTR)cpath->lCopyFromRev);
\r
1242 sPaths += sCopyFrom;
\r
1246 sLogCopyText.Format(_T("%s: %d\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
\r
1247 (LPCTSTR)sRev, pLogEntry->Rev,
\r
1248 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->sAuthor,
\r
1249 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->sDate,
\r
1250 (LPCTSTR)sMessage, (LPCTSTR)pLogEntry->sMessage,
\r
1252 sClipdata += sLogCopyText;
\r
1254 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1259 void CGitLogList::DiffSelectedRevWithPrevious()
\r
1262 if (m_bThreadRunning)
\r
1264 UpdateLogInfoLabel();
\r
1265 int selIndex = m_LogList.GetSelectionMark();
\r
1268 int selCount = m_LogList.GetSelectedCount();
\r
1269 if (selCount != 1)
\r
1272 // Find selected entry in the log list
\r
1273 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1274 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1275 long rev1 = pLogEntry->Rev;
\r
1276 long rev2 = rev1-1;
\r
1277 CTGitPath path = m_path;
\r
1279 // See how many files under the relative root were changed in selected revision
\r
1281 LogChangedPath * changed = NULL;
\r
1282 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1284 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1285 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1292 if (m_path.IsDirectory() && nChanged == 1)
\r
1294 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1295 // Do diff on that file instead of whole directory
\r
1296 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1299 m_bCancelled = FALSE;
\r
1300 DialogEnableWindow(IDOK, FALSE);
\r
1301 SetPromptApp(&theApp);
\r
1302 theApp.DoWaitCursor(1);
\r
1304 if (PromptShown())
\r
1306 GitDiff diff(this, m_hWnd, true);
\r
1307 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1308 diff.SetHEADPeg(m_LogRevision);
\r
1309 diff.ShowCompare(path, rev2, path, rev1);
\r
1313 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1316 theApp.DoWaitCursor(-1);
\r
1321 void CGitLogList::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1323 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1326 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1328 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1330 if (pFindInfo->lvfi.psz == 0)
\r
1333 CString sCmp = pFindInfo->lvfi.psz;
\r
1335 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1337 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1338 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1339 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1341 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1349 if (sCmp.Compare(sRev)==0)
\r
1356 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1358 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1360 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1361 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1362 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1364 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1372 if (sCmp.Compare(sRev)==0)
\r
1384 int CGitLogList::FillGitLog()
\r
1388 this->m_logEntries.ClearAll();
\r
1389 this->m_logEntries.ParserFromLog();
\r
1390 SetItemCountEx(this->m_logEntries.size());
\r
1392 this->m_arShownList.RemoveAll();
\r
1394 for(int i=0;i<m_logEntries.size();i++)
\r
1395 this->m_arShownList.Add(&m_logEntries[i]);
\r
1400 BOOL CGitLogList::PreTranslateMessage(MSG* pMsg)
\r
1402 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1403 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1404 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1406 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1408 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1410 DiffSelectedRevWithPrevious();
\r
1415 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1417 DiffSelectedFile();
\r
1424 if (m_hAccel && !bSkipAccelerator)
\r
1426 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1432 //m_tooltips.RelayEvent(pMsg);
\r
1433 return __super::PreTranslateMessage(pMsg);
\r
1436 void CGitLogList::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1438 // a double click on an entry in the revision list has happened
\r
1441 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1442 DiffSelectedRevWithPrevious();
\r