void CFilePatchesDlg::PatchSelected() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled())) { if (m_arFileStates.GetAt(index) == FPDLG_FILESTATE_ERROR) MessageBox(m_pPatch->GetPatchRejects(index), NULL, MB_ICONERROR); else if (m_arFileStates.GetAt(index) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(index), true); m_pCallBack->PatchFile(m_pPatch->GetStrippedPath(index), m_pPatch->GetContentMods(index), m_pPatch->GetPropMods(index), _T(""), TRUE); m_ShownIndex = index; m_cFileList.Invalidate(); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } }
void CFilePatchesDlg::PatchAll() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled(); i++) { if (m_arFileStates.GetAt(i) == FPDLG_FILESTATE_ERROR) MessageBox(m_pPatch->GetPatchRejects(i), NULL, MB_ICONERROR); else if (m_arFileStates.GetAt(i) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(i), true); m_pCallBack->PatchFile(m_pPatch->GetStrippedPath(i), m_pPatch->GetContentMods(i), m_pPatch->GetPropMods(i), _T(""), TRUE); m_ShownIndex = i; m_cFileList.Invalidate(); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } }
void CFilePatchesDlg::PatchSelected() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; BOOL ret = TRUE; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled()) && ret == TRUE) { if (m_arFileStates.GetAt(index)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, m_pPatch->GetFullPath(m_sPath, index), true); ret = m_pCallBack->PatchFile(index, true, false); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } }
int CGitLogList::CherryPickFrom(CString from, CString to) { CLogDataVector logs(&m_LogCache); CString range; range.Format(_T("%s..%s"), (LPCTSTR)from, (LPCTSTR)to); if (logs.ParserFromLog(nullptr, 0, 0, &range)) return -1; if (logs.empty()) return 0; CSysProgressDlg progress; progress.SetTitle(CString(MAKEINTRESOURCE(IDS_PROGS_TITLE_CHERRYPICK))); progress.SetAnimation(IDR_MOVEANI); progress.SetTime(true); progress.ShowModeless(this); CBlockCacheForPath cacheBlock(g_Git.m_CurrentDir); for (int i = (int)logs.size() - 1; i >= 0; i--) { if (progress.IsVisible()) { progress.FormatNonPathLine(1, IDS_PROC_PICK, logs.GetGitRevAt(i).m_CommitHash.ToString()); progress.FormatNonPathLine(2, _T("%s"), (LPCTSTR)logs.GetGitRevAt(i).GetSubject()); progress.SetProgress64(logs.size() - i, logs.size()); } if (progress.HasUserCancelled()) { throw std::exception(CUnicodeUtils::GetUTF8(CString(MAKEINTRESOURCE(IDS_USERCANCELLED)))); } CString cmd,out; cmd.Format(_T("git.exe cherry-pick %s"), (LPCTSTR)logs.GetGitRevAt(i).m_CommitHash.ToString()); out.Empty(); if(g_Git.Run(cmd,&out,CP_UTF8)) { throw std::exception(CUnicodeUtils::GetUTF8(CString(MAKEINTRESOURCE(IDS_PROC_CHERRYPICKFAILED)) + _T(":\r\n\r\n") + out)); } } return 0; }
void CFilePatchesDlg::PatchAll() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); BOOL ret = TRUE; for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled() && ret == TRUE; i++) { if (m_arFileStates.GetAt(i)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, m_pPatch->GetFullPath(m_sPath, i), true); ret = m_pCallBack->PatchFile(i, true, false); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } }
void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult) { *pResult = 0; if (m_sPath.IsEmpty()) return; CString temp; CMenu popup; POINT point; DWORD ptW = GetMessagePos(); point.x = GET_X_LPARAM(ptW); point.y = GET_Y_LPARAM(ptW); if (popup.CreatePopupMenu()) { UINT nFlags; nFlags = MF_STRING | (m_cFileList.GetSelectedCount()==1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED); temp.LoadString(IDS_PATCH_REVIEW); popup.AppendMenu(nFlags, ID_PATCH_REVIEW, temp); popup.SetDefaultItem(ID_PATCH_REVIEW, FALSE); temp.LoadString(IDS_PATCH_PREVIEW); popup.AppendMenu(nFlags, ID_PATCHPREVIEW, temp); temp.LoadString(IDS_PATCH_ALL); popup.AppendMenu(MF_STRING | MF_ENABLED, ID_PATCHALL, temp); nFlags = MF_STRING | (m_cFileList.GetSelectedCount()>0 ? MF_ENABLED : MF_DISABLED | MF_GRAYED); temp.LoadString(IDS_PATCH_SELECTED); popup.AppendMenu(nFlags, ID_PATCHSELECTED, temp); // if the context menu is invoked through the keyboard, we have to use // a calculated position on where to anchor the menu on if ((point.x == -1) && (point.y == -1)) { CRect rect; GetWindowRect(&rect); point = rect.CenterPoint(); } bool bReview=false; int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); switch (cmd) { case ID_PATCH_REVIEW: bReview = true; //go through case case ID_PATCHPREVIEW: { if (m_pCallBack) { int nIndex = m_cFileList.GetSelectionMark(); if ( m_arFileStates.GetAt(nIndex)!=FPDLG_FILESTATE_PATCHED) { m_pCallBack->PatchFile(GetFullPath(nIndex), m_pPatch->GetRevision(nIndex),false,bReview); } } } break; case ID_PATCHALL: { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled(); i++) { if (m_arFileStates.GetAt(i)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(i), true); m_pCallBack->PatchFile(GetFullPath(i), m_pPatch->GetRevision(i), TRUE); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } } break; case ID_PATCHSELECTED: { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled())) { if (m_arFileStates.GetAt(index)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(index), true); m_pCallBack->PatchFile(GetFullPath(index), m_pPatch->GetRevision(index), TRUE); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } } break; default: break; } } }