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
50 ,m_bNoDispUpdates(FALSE)
\r
51 , m_bThreadRunning(FALSE)
\r
52 , m_bStrictStopped(false)
\r
53 , m_pStoreSelection(NULL)
\r
55 // use the default GUI font, create a copy of it and
\r
56 // change the copy to BOLD (leave the rest of the font
\r
58 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
60 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
61 lf.lfWeight = FW_BOLD;
\r
62 m_boldFont = CreateFontIndirect(&lf);
\r
64 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
65 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
66 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
67 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
72 CGitLogList::~CGitLogList()
\r
74 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
76 DestroyIcon(m_hModifiedIcon);
\r
77 DestroyIcon(m_hReplacedIcon);
\r
78 DestroyIcon(m_hAddedIcon);
\r
79 DestroyIcon(m_hDeletedIcon);
\r
80 m_logEntries.ClearAll();
\r
83 DeleteObject(m_boldFont);
\r
85 if ( m_pStoreSelection )
\r
87 delete m_pStoreSelection;
\r
88 m_pStoreSelection = NULL;
\r
93 BEGIN_MESSAGE_MAP(CGitLogList, CHintListCtrl)
\r
94 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
95 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
97 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
98 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
102 int CGitLogList:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
104 PreSubclassWindow();
\r
105 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
108 void CGitLogList::PreSubclassWindow()
\r
110 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
111 // load the icons for the action columns
\r
112 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
113 CHintListCtrl::PreSubclassWindow();
\r
116 void CGitLogList::InsertGitColumn()
\r
120 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
124 temp.LoadString(IDS_LOG_GRAPH);
\r
126 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
129 // make the revision column right aligned
\r
131 Column.mask = LVCF_FMT;
\r
132 Column.fmt = LVCFMT_RIGHT;
\r
133 SetColumn(0, &Column);
\r
136 // g_Git.GetLog(log);
\r
138 temp.LoadString(IDS_LOG_ACTIONS);
\r
139 InsertColumn(this->LOGLIST_ACTION, temp);
\r
141 temp.LoadString(IDS_LOG_MESSAGE);
\r
142 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
144 temp.LoadString(IDS_LOG_AUTHOR);
\r
145 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
147 temp.LoadString(IDS_LOG_DATE);
\r
148 InsertColumn(this->LOGLIST_DATE, temp);
\r
151 if (m_bShowBugtraqColumn)
\r
153 // temp = m_ProjectProperties.sLabel;
\r
154 if (temp.IsEmpty())
\r
155 temp.LoadString(IDS_LOG_BUGIDS);
\r
156 InsertColumn(this->LOGLIST_BUG, temp);
\r
161 ResizeAllListCtrlCols();
\r
166 void CGitLogList::ResizeAllListCtrlCols()
\r
169 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
170 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
171 int nItemCount = GetItemCount();
\r
172 TCHAR textbuf[MAX_PATH];
\r
173 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
176 for (int col = 0; col <= maxcol; col++)
\r
179 hdi.mask = HDI_TEXT;
\r
180 hdi.pszText = textbuf;
\r
181 hdi.cchTextMax = sizeof(textbuf);
\r
182 pHdrCtrl->GetItem(col, &hdi);
\r
183 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
184 for (int index = 0; index<nItemCount; ++index)
\r
186 // get the width of the string and add 14 pixels for the column separator and margins
\r
187 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
188 if (index < m_arShownList.GetCount())
\r
190 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
191 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
193 // set the bold font and ask for the string width again
\r
194 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
195 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
196 // restore the system font
\r
197 SendMessage(WM_SETFONT, NULL, NULL);
\r
202 // add the image size
\r
203 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
204 if ((pImgList)&&(pImgList->GetImageCount()))
\r
207 pImgList->GetImageInfo(0, &imginfo);
\r
208 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
209 linewidth += 3; // 3 pixels between icon and text
\r
212 if (cx < linewidth)
\r
215 // Adjust columns "Actions" containing icons
\r
216 if (col == this->LOGLIST_ACTION)
\r
218 if (cx < nMinimumWidth)
\r
220 cx = nMinimumWidth;
\r
224 if (col == this->LOGLIST_MESSAGE)
\r
226 if (cx > LOGLIST_MESSAGE_MAX)
\r
228 cx = LOGLIST_MESSAGE_MAX;
\r
232 // keep the bug id column small
\r
233 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
235 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
237 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
241 SetColumnWidth(col, cx);
\r
248 void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
251 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
252 // Take the default processing unless we set this to something else below.
\r
253 *pResult = CDRF_DODEFAULT;
\r
255 if (m_bNoDispUpdates)
\r
258 switch (pLVCD->nmcd.dwDrawStage)
\r
260 case CDDS_PREPAINT:
\r
262 *pResult = CDRF_NOTIFYITEMDRAW;
\r
266 case CDDS_ITEMPREPAINT:
\r
268 // This is the prepaint stage for an item. Here's where we set the
\r
269 // item's text color.
\r
271 // Tell Windows to send draw notifications for each subitem.
\r
272 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
274 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
276 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
278 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
282 if (data->bCopiedSelf)
\r
284 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
285 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
286 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
290 crText = m_Colors.GetColor(CColors::Modified);
\r
292 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
293 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
294 // if (data->Rev == m_wcRev)
\r
296 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
297 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
298 // tells the control to recalculate the extent of the text.
\r
299 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
303 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
305 if (m_bStrictStopped)
\r
306 crText = GetSysColor(COLOR_GRAYTEXT);
\r
308 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
309 pLVCD->clrText = crText;
\r
313 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
315 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
317 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
319 if (pLVCD->iSubItem == 1)
\r
321 *pResult = CDRF_DODEFAULT;
\r
323 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
327 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
328 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
330 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
332 // Get the selected state of the
\r
333 // item being drawn.
\r
335 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
336 rItem.mask = LVIF_STATE;
\r
337 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
338 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
342 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
344 // Fill the background
\r
345 if (m_Theme.IsAppThemed() && m_bVista)
\r
347 m_Theme.Open(m_hWnd, L"Explorer");
\r
348 int state = LISS_NORMAL;
\r
349 if (rItem.state & LVIS_SELECTED)
\r
351 if (::GetFocus() == m_hWnd)
\r
352 state |= LISS_SELECTED;
\r
354 state |= LISS_SELECTEDNOTFOCUS;
\r
359 if (pLogEntry->bCopiedSelf)
\r
361 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
362 // information at this drawing stage. But we can check the whether the
\r
363 // previous stage changed the background color of the item
\r
364 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
367 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
370 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
371 ::DeleteObject(brush);
\r
378 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
379 m_Theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
381 m_Theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
386 if (rItem.state & LVIS_SELECTED)
\r
388 if (::GetFocus() == m_hWnd)
\r
389 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
391 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
395 //if (pLogEntry->bCopiedSelf)
\r
396 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
398 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
403 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
404 ::DeleteObject(brush);
\r
407 // Draw the icon(s) into the compatible DC
\r
408 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
409 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
412 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
413 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
416 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
417 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
420 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
421 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
423 *pResult = CDRF_SKIPDEFAULT;
\r
429 *pResult = CDRF_DODEFAULT;
\r
433 // CGitLogList message handlers
\r
435 void CGitLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
437 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
439 // Create a pointer to the item
\r
440 LV_ITEM* pItem = &(pDispInfo)->item;
\r
442 // Do the list need text information?
\r
443 if (!(pItem->mask & LVIF_TEXT))
\r
446 // By default, clear text buffer.
\r
447 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
449 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
452 if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)
\r
455 // Which item number?
\r
456 int itemid = pItem->iItem;
\r
457 GitRev * pLogEntry = NULL;
\r
458 if (itemid < m_arShownList.GetCount())
\r
459 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
462 switch (pItem->iSubItem)
\r
464 case this->LOGLIST_GRAPH: //Graphic
\r
469 case this->LOGLIST_ACTION: //action -- no text in the column
\r
471 case this->LOGLIST_MESSAGE: //Message
\r
473 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
475 case this->LOGLIST_AUTHOR: //Author
\r
477 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
479 case this->LOGLIST_DATE: //Date
\r
481 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
492 void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
\r
495 int selIndex = GetSelectionMark();
\r
497 return; // nothing selected, nothing to do with a context menu
\r
499 // if the user selected the info text telling about not all revisions shown due to
\r
500 // the "stop on copy/rename" option, we also don't show the context menu
\r
501 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
504 // if the context menu is invoked through the keyboard, we have to use
\r
505 // a calculated position on where to anchor the menu on
\r
506 if ((point.x == -1) && (point.y == -1))
\r
509 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
510 ClientToScreen(&rect);
\r
511 point = rect.CenterPoint();
\r
513 m_nSearchIndex = selIndex;
\r
514 m_bCancelled = FALSE;
\r
516 // calculate some information the context menu commands can use
\r
517 // CString pathURL = GetURLFromPath(m_path);
\r
519 POSITION pos = GetFirstSelectedItemPosition();
\r
520 int indexNext = GetNextSelectedItem(pos);
\r
524 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
526 GitRev revSelected = pSelLogEntry->Rev;
\r
527 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
528 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
530 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
532 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
533 if (changedpath->lCopyFromRev)
\r
534 revPrevious = changedpath->lCopyFromRev;
\r
537 GitRev revSelected2;
\r
540 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
541 revSelected2 = pLogEntry->Rev;
\r
543 bool bAllFromTheSameAuthor = true;
\r
544 CString firstAuthor;
\r
545 CLogDataVector selEntries;
\r
546 GitRev revLowest, revHighest;
\r
547 GitRevRangeArray revisionRanges;
\r
549 POSITION pos = GetFirstSelectedItemPosition();
\r
550 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
551 revisionRanges.AddRevision(pLogEntry->Rev);
\r
552 selEntries.push_back(pLogEntry);
\r
553 firstAuthor = pLogEntry->sAuthor;
\r
554 revLowest = pLogEntry->Rev;
\r
555 revHighest = pLogEntry->Rev;
\r
558 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
559 revisionRanges.AddRevision(pLogEntry->Rev);
\r
560 selEntries.push_back(pLogEntry);
\r
561 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
562 bAllFromTheSameAuthor = false;
\r
563 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
564 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
570 int FirstSelect=-1, LastSelect=-1;
\r
571 pos = GetFirstSelectedItemPosition();
\r
572 FirstSelect = GetNextSelectedItem(pos);
\r
575 LastSelect = GetNextSelectedItem(pos);
\r
577 //entry is selected, now show the popup menu
\r
579 if (popup.CreatePopupMenu())
\r
581 if (GetSelectedCount() == 1)
\r
584 if (!m_path.IsDirectory())
\r
588 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
589 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
591 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
592 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
593 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
594 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
595 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
596 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
597 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
598 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
605 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
607 // TortoiseMerge could be improved to take a /blame switch
\r
608 // and then not 'cat' the files from a unified diff but
\r
610 // But until that's implemented, the context menu entry for
\r
611 // this feature is commented out.
\r
612 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
614 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
615 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
616 popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
617 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
620 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
622 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
624 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
626 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
628 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
629 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
631 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
634 // popup.AppendMenuIcon(ID_REPOBROWSE, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
\r
635 // popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPY);
\r
637 // popup.AppendMenuIcon(ID_UPDATE, IDS_LOG_POPUP_UPDATE, IDI_UPDATE);
\r
639 popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
641 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
643 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
644 popup.AppendMenuIcon(ID_CHECKOUT, IDS_MENUCHECKOUT, IDI_CHECKOUT);
\r
645 popup.AppendMenuIcon(ID_EXPORT, IDS_MENUEXPORT, IDI_EXPORT);
\r
646 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
648 else if (GetSelectedCount() >= 2)
\r
650 bool bAddSeparator = false;
\r
651 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
653 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
655 if (GetSelectedCount() == 2)
\r
657 popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
658 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
659 bAddSeparator = true;
\r
663 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
665 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
666 bAddSeparator = true;
\r
669 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
672 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
674 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
676 // if (GetSelectedCount() == 1)
\r
678 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
679 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
680 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
683 if (GetSelectedCount() != 0)
\r
685 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
687 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
689 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
690 // DialogEnableWindow(IDOK, FALSE);
\r
691 // SetPromptApp(&theApp);
\r
692 theApp.DoWaitCursor(1);
\r
693 bool bOpenWith = false;
\r
699 CString tempfile=GetTempFile();
\r
701 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
702 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
703 g_Git.RunLogFile(cmd,tempfile);
\r
704 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
710 CString tempfile=GetTempFile();
\r
712 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
713 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
714 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
715 g_Git.RunLogFile(cmd,tempfile);
\r
716 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
721 case ID_COMPARETWO:
\r
723 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
724 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
726 dlg.SetDiff(NULL,*r1,*r2);
\r
737 GitDiff diff(this, this->m_hWnd, true);
\r
738 diff.SetHEADPeg(m_LogRevision);
\r
739 diff.ShowUnifiedDiff(m_path, revPrevious, m_path, revSelected);
\r
742 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revPrevious, m_path, revSelected, GitRev(), m_LogRevision);
\r
750 GitDiff diff(this, this->m_hWnd, true);
\r
751 diff.SetHEADPeg(m_LogRevision);
\r
752 diff.ShowUnifiedDiff(m_path, revSelected2, m_path, revSelected);
\r
755 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revSelected2, m_path, revSelected, GitRev(), m_LogRevision);
\r
760 // we need an URL to complete this command, so error out if we can't get an URL
\r
761 if (pathURL.IsEmpty())
\r
763 CString strMessage;
\r
764 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
765 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
766 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
770 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
771 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
773 CGitProgressDlg dlg;
\r
774 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
775 dlg.SetPathList(CTGitPathList(m_path));
\r
776 dlg.SetUrl(pathURL);
\r
777 dlg.SetSecondUrl(pathURL);
\r
778 revisionRanges.AdjustForMerge(true);
\r
779 dlg.SetRevisionRanges(revisionRanges);
\r
780 dlg.SetPegRevision(m_LogRevision);
\r
787 // we need an URL to complete this command, so error out if we can't get an URL
\r
788 if (pathURL.IsEmpty())
\r
790 CString strMessage;
\r
791 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
792 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
793 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
797 CString path = m_path.GetWinPathString();
\r
798 bool bGotSavePath = false;
\r
799 if ((GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
801 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
805 CBrowseFolder folderBrowser;
\r
806 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
807 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
811 CGitProgressDlg dlg;
\r
812 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
813 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
814 dlg.SetUrl(pathURL);
\r
815 dlg.SetSecondUrl(pathURL);
\r
816 revisionRanges.AdjustForMerge(false);
\r
817 dlg.SetRevisionRanges(revisionRanges);
\r
818 dlg.SetPegRevision(m_LogRevision);
\r
823 case ID_REVERTTOREV:
\r
825 // we need an URL to complete this command, so error out if we can't get an URL
\r
826 if (pathURL.IsEmpty())
\r
828 CString strMessage;
\r
829 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
830 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
831 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
836 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
837 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
839 CGitProgressDlg dlg;
\r
840 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
841 dlg.SetPathList(CTGitPathList(m_path));
\r
842 dlg.SetUrl(pathURL);
\r
843 dlg.SetSecondUrl(pathURL);
\r
844 GitRevRangeArray revarray;
\r
845 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
846 dlg.SetRevisionRanges(revarray);
\r
847 dlg.SetPegRevision(m_LogRevision);
\r
854 // we need an URL to complete this command, so error out if we can't get an URL
\r
855 if (pathURL.IsEmpty())
\r
857 CString strMessage;
\r
858 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
859 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
860 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
865 dlg.m_URL = pathURL;
\r
866 dlg.m_path = m_path;
\r
867 dlg.m_CopyRev = revSelected;
\r
868 if (dlg.DoModal() == IDOK)
\r
870 // should we show a progress dialog here? Copies are done really fast
\r
871 // and without much network traffic.
\r
872 if (!Copy(CTGitPathList(CTGitPath(pathURL)), CTGitPath(dlg.m_URL), dlg.m_CopyRev, dlg.m_CopyRev, dlg.m_sLogMessage))
\r
873 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
875 CMessageBox::Show(this->m_hWnd, IDS_LOG_COPY_SUCCESS, IDS_APPNAME, MB_ICONINFORMATION);
\r
881 //user clicked on the menu item "compare with working copy"
\r
884 GitDiff diff(this, m_hWnd, true);
\r
885 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
886 diff.SetHEADPeg(m_LogRevision);
\r
887 diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
890 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
893 case ID_COMPARETWO:
\r
895 GitRev r1 = revSelected;
\r
896 GitRev r2 = revSelected2;
\r
897 if (GetSelectedCount() > 2)
\r
902 //user clicked on the menu item "compare revisions"
\r
905 GitDiff diff(this, m_hWnd, true);
\r
906 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
907 diff.SetHEADPeg(m_LogRevision);
\r
908 diff.ShowCompare(CTGitPath(pathURL), r2, CTGitPath(pathURL), r1);
\r
911 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), r2, CTGitPath(pathURL), r1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
914 case ID_COMPAREWITHPREVIOUS:
\r
918 GitDiff diff(this, m_hWnd, true);
\r
919 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
920 diff.SetHEADPeg(m_LogRevision);
\r
921 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
924 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
927 case ID_BLAMECOMPARE:
\r
929 //user clicked on the menu item "compare with working copy"
\r
930 //now first get the revision which is selected
\r
933 GitDiff diff(this, this->m_hWnd, true);
\r
934 diff.SetHEADPeg(m_LogRevision);
\r
935 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
938 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
943 //user clicked on the menu item "compare and blame revisions"
\r
946 GitDiff diff(this, this->m_hWnd, true);
\r
947 diff.SetHEADPeg(m_LogRevision);
\r
948 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
951 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
954 case ID_BLAMEWITHPREVIOUS:
\r
956 //user clicked on the menu item "Compare and Blame with previous revision"
\r
959 GitDiff diff(this, this->m_hWnd, true);
\r
960 diff.SetHEADPeg(m_LogRevision);
\r
961 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
964 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
969 //now first get the revision which is selected
\r
970 CString revFilename;
\r
973 CString strWinPath = m_path.GetWinPathString();
\r
974 int rfind = strWinPath.ReverseFind('.');
\r
976 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)strWinPath.Left(rfind), (LONG)revSelected, (LPCTSTR)strWinPath.Mid(rfind));
\r
978 revFilename.Format(_T("%s-%ld"), (LPCTSTR)strWinPath, revSelected);
\r
980 if (CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd))
\r
982 CTGitPath tempfile;
\r
983 tempfile.SetFromWin(revFilename);
\r
984 CProgressDlg progDlg;
\r
985 progDlg.SetTitle(IDS_APPNAME);
\r
986 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
988 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
989 progDlg.SetLine(1, sInfoLine, true);
\r
990 SetAndClearProgressInfo(&progDlg);
\r
991 progDlg.ShowModeless(m_hWnd);
\r
992 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
994 // try again with another peg revision
\r
995 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
998 SetAndClearProgressInfo((HWND)NULL);
\r
999 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1005 SetAndClearProgressInfo((HWND)NULL);
\r
1013 CProgressDlg progDlg;
\r
1014 progDlg.SetTitle(IDS_APPNAME);
\r
1015 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1016 CString sInfoLine;
\r
1017 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
1018 progDlg.SetLine(1, sInfoLine, true);
\r
1019 SetAndClearProgressInfo(&progDlg);
\r
1020 progDlg.ShowModeless(m_hWnd);
\r
1021 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
1022 bool bSuccess = true;
\r
1023 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
1026 // try again, but with the selected revision as the peg revision
\r
1027 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
1030 SetAndClearProgressInfo((HWND)NULL);
\r
1031 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1040 SetAndClearProgressInfo((HWND)NULL);
\r
1041 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1044 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1045 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
1047 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1048 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1049 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1057 dlg.EndRev = revSelected;
\r
1058 if (dlg.DoModal() == IDOK)
\r
1063 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
1064 if (!tempfile.IsEmpty())
\r
1066 if (dlg.m_bTextView)
\r
1068 //open the default text editor for the result file
\r
1069 CAppUtils::StartTextViewer(tempfile);
\r
1073 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
1074 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
1082 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1090 CString url = _T("tgit:")+pathURL;
\r
1091 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
1092 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1093 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
1094 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1097 case ID_FINDENTRY:
\r
1099 m_nSearchIndex = GetSelectionMark();
\r
1100 if (m_nSearchIndex < 0)
\r
1101 m_nSearchIndex = 0;
\r
1102 if (m_pFindDialog)
\r
1108 m_pFindDialog = new CFindReplaceDialog();
\r
1109 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
1113 case ID_REPOBROWSE:
\r
1116 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
1117 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1118 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
1120 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1125 EditLogMessage(selIndex);
\r
1128 case ID_EDITAUTHOR:
\r
1130 EditAuthor(selEntries);
\r
1135 CEditPropertiesDlg dlg;
\r
1136 dlg.SetProjectProperties(&m_ProjectProperties);
\r
1137 CTGitPathList escapedlist;
\r
1138 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
1139 dlg.SetRevision(revSelected);
\r
1140 dlg.RevProps(true);
\r
1144 case ID_COPYCLIPBOARD:
\r
1146 CopySelectionToClipBoard();
\r
1152 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
1153 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1154 (LPCTSTR)pathURL, (LONG)revSelected);
\r
1155 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1161 CString url = _T("tgit:")+pathURL;
\r
1162 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
1163 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1164 (LPCTSTR)url, (LONG)revSelected);
\r
1165 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1170 CString url = m_ProjectProperties.sWebViewerRev;
\r
1171 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1172 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1173 if (!url.IsEmpty())
\r
1174 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1177 case ID_VIEWPATHREV:
\r
1179 CString relurl = pathURL;
\r
1180 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
1181 relurl = relurl.Mid(sRoot.GetLength());
\r
1182 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
1183 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1184 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1185 url.Replace(_T("%PATH%"), relurl);
\r
1186 if (!url.IsEmpty())
\r
1187 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1194 theApp.DoWaitCursor(-1);
\r
1195 // EnableOKButton();
\r
1196 } // if (popup.CreatePopupMenu())
\r
1200 bool CGitLogList::IsSelectionContinuous()
\r
1202 if ( GetSelectedCount()==1 )
\r
1204 // if only one revision is selected, the selection is of course
\r
1209 POSITION pos = GetFirstSelectedItemPosition();
\r
1210 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1213 int itemindex = GetNextSelectedItem(pos);
\r
1216 int nextindex = GetNextSelectedItem(pos);
\r
1217 if (nextindex - itemindex > 1)
\r
1219 bContinuous = false;
\r
1222 itemindex = nextindex;
\r
1225 return bContinuous;
\r
1228 void CGitLogList::CopySelectionToClipBoard()
\r
1231 CString sClipdata;
\r
1232 POSITION pos = GetFirstSelectedItemPosition();
\r
1236 sRev.LoadString(IDS_LOG_REVISION);
\r
1238 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1240 sDate.LoadString(IDS_LOG_DATE);
\r
1242 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1245 CString sLogCopyText;
\r
1247 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1248 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1249 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1251 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1252 sPaths += cpath->GetAction() + _T(" : ") + cpath->sPath;
\r
1253 if (cpath->sCopyFromPath.IsEmpty())
\r
1254 sPaths += _T("\r\n");
\r
1257 CString sCopyFrom;
\r
1258 sCopyFrom.Format(_T(" (%s: %s, %s, %ld)\r\n"), CString(MAKEINTRESOURCE(IDS_LOG_COPYFROM)),
\r
1259 (LPCTSTR)cpath->sCopyFromPath,
\r
1260 (LPCTSTR)CString(MAKEINTRESOURCE(IDS_LOG_REVISION)),
\r
1261 (LPCTSTR)cpath->lCopyFromRev);
\r
1262 sPaths += sCopyFrom;
\r
1266 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
1267 (LPCTSTR)sRev, pLogEntry->Rev,
\r
1268 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->sAuthor,
\r
1269 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->sDate,
\r
1270 (LPCTSTR)sMessage, (LPCTSTR)pLogEntry->sMessage,
\r
1272 sClipdata += sLogCopyText;
\r
1274 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1279 void CGitLogList::DiffSelectedRevWithPrevious()
\r
1282 if (m_bThreadRunning)
\r
1284 UpdateLogInfoLabel();
\r
1285 int selIndex = m_LogList.GetSelectionMark();
\r
1288 int selCount = m_LogList.GetSelectedCount();
\r
1289 if (selCount != 1)
\r
1292 // Find selected entry in the log list
\r
1293 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1294 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1295 long rev1 = pLogEntry->Rev;
\r
1296 long rev2 = rev1-1;
\r
1297 CTGitPath path = m_path;
\r
1299 // See how many files under the relative root were changed in selected revision
\r
1301 LogChangedPath * changed = NULL;
\r
1302 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1304 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1305 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1312 if (m_path.IsDirectory() && nChanged == 1)
\r
1314 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1315 // Do diff on that file instead of whole directory
\r
1316 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1319 m_bCancelled = FALSE;
\r
1320 DialogEnableWindow(IDOK, FALSE);
\r
1321 SetPromptApp(&theApp);
\r
1322 theApp.DoWaitCursor(1);
\r
1324 if (PromptShown())
\r
1326 GitDiff diff(this, m_hWnd, true);
\r
1327 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1328 diff.SetHEADPeg(m_LogRevision);
\r
1329 diff.ShowCompare(path, rev2, path, rev1);
\r
1333 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1336 theApp.DoWaitCursor(-1);
\r
1341 void CGitLogList::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1343 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1346 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1348 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1350 if (pFindInfo->lvfi.psz == 0)
\r
1353 CString sCmp = pFindInfo->lvfi.psz;
\r
1355 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1357 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1358 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1359 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1361 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1369 if (sCmp.Compare(sRev)==0)
\r
1376 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1378 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1380 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1381 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1382 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1384 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1392 if (sCmp.Compare(sRev)==0)
\r
1404 int CGitLogList::FillGitLog()
\r
1408 this->m_logEntries.ClearAll();
\r
1409 this->m_logEntries.ParserFromLog();
\r
1410 SetItemCountEx(this->m_logEntries.size());
\r
1412 this->m_arShownList.RemoveAll();
\r
1414 for(int i=0;i<m_logEntries.size();i++)
\r
1415 this->m_arShownList.Add(&m_logEntries[i]);
\r
1420 BOOL CGitLogList::PreTranslateMessage(MSG* pMsg)
\r
1422 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1423 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1424 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1426 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1428 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1430 DiffSelectedRevWithPrevious();
\r
1435 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1437 DiffSelectedFile();
\r
1444 if (m_hAccel && !bSkipAccelerator)
\r
1446 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1452 //m_tooltips.RelayEvent(pMsg);
\r
1453 return __super::PreTranslateMessage(pMsg);
\r
1456 void CGitLogList::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1458 // a double click on an entry in the revision list has happened
\r
1461 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1462 DiffSelectedRevWithPrevious();
\r
1465 int CGitLogList::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1467 m_ProcCallBack=proc;
\r
1470 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1471 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1472 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1474 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1475 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1476 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1482 //this is the thread function which calls the subversion function
\r
1483 UINT CGitLogList::LogThreadEntry(LPVOID pVoid)
\r
1485 return ((CGitLogList*)pVoid)->LogThread();
\r
1489 UINT CGitLogList::LogThread()
\r
1492 if(m_ProcCallBack)
\r
1493 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1495 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1497 //does the user force the cache to refresh (shift or control key down)?
\r
1498 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1499 || (GetKeyState (VK_SHIFT) < 0);
\r
1501 //disable the "Get All" button while we're receiving
\r
1505 temp.LoadString(IDS_PROGRESSWAIT);
\r
1506 ShowText(temp, true);
\r
1508 // git_revnum_t r = -1;
\r
1510 // get the repository root url, because the changed-files-list has the
\r
1511 // paths shown there relative to the repository root.
\r
1512 // CTGitPath rootpath;
\r
1513 // BOOL succeeded = GetRootAndHead(m_path, rootpath, r);
\r
1515 // m_sRepositoryRoot = rootpath.GetGitPathString();
\r
1516 // m_sURL = m_path.GetGitPathString();
\r
1518 // we need the UUID to unambigously identify the log cache
\r
1519 // if (logCachePool.IsEnabled())
\r
1520 // m_sUUID = logCachePool.GetRepositoryInfo().GetRepositoryUUID (rootpath);
\r
1522 // if the log dialog is started from a working copy, we need to turn that
\r
1523 // local path into an url here
\r
1526 // if (!m_path.IsUrl())
\r
1528 // m_sURL = GetURLFromPath(m_path);
\r
1530 // The URL is escaped because Git::logReceiver
\r
1531 // returns the path in a native format
\r
1532 // m_sURL = CPathUtils::PathUnescape(m_sURL);
\r
1534 // m_sRelativeRoot = m_sURL.Mid(CPathUtils::PathUnescape(m_sRepositoryRoot).GetLength());
\r
1535 // m_sSelfRelativeURL = m_sRelativeRoot;
\r
1538 if (succeeded && !m_mergePath.IsEmpty() && m_mergedRevs.empty())
\r
1540 // in case we got a merge path set, retrieve the merge info
\r
1541 // of that path and check whether one of the merge URLs
\r
1542 // match the URL we show the log for.
\r
1543 GitPool localpool(pool);
\r
1544 git_error_clear(Err);
\r
1545 apr_hash_t * mergeinfo = NULL;
\r
1546 if (git_client_mergeinfo_get_merged (&mergeinfo, m_mergePath.GetGitApiPath(localpool), GitRev(GitRev::REV_WC), m_pctx, localpool) == NULL)
\r
1548 // now check the relative paths
\r
1549 apr_hash_index_t *hi;
\r
1555 for (hi = apr_hash_first(localpool, mergeinfo); hi; hi = apr_hash_next(hi))
\r
1557 apr_hash_this(hi, &key, NULL, &val);
\r
1558 if (m_sURL.Compare(CUnicodeUtils::GetUnicode((char*)key)) == 0)
\r
1560 apr_array_header_t * arr = (apr_array_header_t*)val;
\r
1563 for (long i=0; i<arr->nelts; ++i)
\r
1565 git_merge_range_t * pRange = APR_ARRAY_IDX(arr, i, git_merge_range_t*);
\r
1568 for (git_revnum_t r=pRange->start+1; r<=pRange->end; ++r)
\r
1570 m_mergedRevs.insert(r);
\r
1582 m_LogProgress.SetPos(1);
\r
1583 if (m_startrev == GitRev::REV_HEAD)
\r
1587 if (m_endrev == GitRev::REV_HEAD)
\r
1594 m_limitcounter = m_limit;
\r
1595 m_LogProgress.SetRange32(0, m_limit);
\r
1598 m_LogProgress.SetRange32(m_endrev, m_startrev);
\r
1600 if (!m_pegrev.IsValid())
\r
1601 m_pegrev = m_startrev;
\r
1602 size_t startcount = m_logEntries.size();
\r
1604 m_bStrictStopped = false;
\r
1608 succeeded = ReceiveLog (CTGitPathList(m_path), m_pegrev, m_startrev, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1609 if ((!succeeded)&&(!m_path.IsUrl()))
\r
1611 // try again with REV_WC as the start revision, just in case the path doesn't
\r
1612 // exist anymore in HEAD
\r
1613 succeeded = ReceiveLog(CTGitPathList(m_path), GitRev(), GitRev::REV_WC, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1616 m_LogList.ClearText();
\r
1619 m_LogList.ShowText(GetLastErrorMessage(), true);
\r
1623 if (!m_wcRev.IsValid())
\r
1625 // fetch the revision the wc path is on so we can mark it
\r
1626 CTGitPath revWCPath = m_ProjectProperties.GetPropsPath();
\r
1627 if (!m_path.IsUrl())
\r
1628 revWCPath = m_path;
\r
1629 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RecursiveLogRev"), FALSE)))
\r
1631 git_revnum_t minrev, maxrev;
\r
1632 bool switched, modified, sparse;
\r
1633 GetWCRevisionStatus(revWCPath, true, minrev, maxrev, switched, modified, sparse);
\r
1639 CTGitPath dummypath;
\r
1641 git_wc_status2_t * stat = status.GetFirstFileStatus(revWCPath, dummypath, false, git_depth_empty);
\r
1642 if (stat && stat->entry && stat->entry->cmt_rev)
\r
1643 m_wcRev = stat->entry->cmt_rev;
\r
1644 if (stat && stat->entry && (stat->entry->kind == git_node_dir))
\r
1645 m_wcRev = stat->entry->revision;
\r
1649 if (m_bStrict && (m_lowestRev>1) && ((m_limit>0) ? ((startcount + m_limit)>m_logEntries.size()) : (m_endrev<m_lowestRev)))
\r
1650 m_bStrictStopped = true;
\r
1651 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
1653 m_timFrom = (__time64_t(m_tFrom));
\r
1654 m_timTo = (__time64_t(m_tTo));
\r
1655 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1656 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1657 m_DateFrom.SetTime(&m_timFrom);
\r
1658 m_DateTo.SetTime(&m_timTo);
\r
1660 //DialogEnableWindow(IDC_GETALL, TRUE);
\r
1663 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1665 RedrawItems(0, m_arShownList.GetCount());
\r
1667 ResizeAllListCtrlCols();
\r
1670 if ( m_pStoreSelection )
\r
1672 // Deleting the instance will restore the
\r
1673 // selection of the CLogDlg.
\r
1674 delete m_pStoreSelection;
\r
1675 m_pStoreSelection = NULL;
\r
1679 // If no selection has been set then this must be the first time
\r
1680 // the revisions are shown. Let's preselect the topmost revision.
\r
1681 if ( GetItemCount()>0 )
\r
1683 SetSelectionMark(0);
\r
1684 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1688 //RefreshCursor();
\r
1689 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1690 // the log messages
\r
1692 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1694 if(m_ProcCallBack)
\r
1695 m_ProcCallBack(m_ProcData,GITLOG_END);
\r