bool CHooks::ApproveHook( HWND hWnd, hookiterator it ) { if (it->second.bApproved || it->second.bStored) return it->second.bApproved; CString sQuestion; sQuestion.Format(IDS_HOOKS_APPROVE_TASK1, (LPCWSTR)it->second.commandline); bool bApproved = false; bool bDoNotAskAgain = false; CTaskDialog taskdlg(sQuestion, CString(MAKEINTRESOURCE(IDS_HOOKS_APPROVE_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_HOOKS_APPROVE_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_HOOKS_APPROVE_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_HOOKS_APPROVE_TASK5))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); bApproved = taskdlg.DoModal(hWnd) == 1; bDoNotAskAgain = !!taskdlg.GetVerificationCheckboxState(); if (bDoNotAskAgain) { CRegDWORD reg(it->second.sRegKey, 0); reg = bApproved ? 1 : 0; it->second.bStored = true; } it->second.bApproved = bApproved; return bApproved; }
bool RenameCommand::RenameWithReplace(HWND hWnd, const CTSVNPathList &srcPathList, const CTSVNPath &destPath, const CString &message /* = L"" */, bool move_as_child /* = false */, bool make_parents /* = false */) const { SVN svn; UINT idret = IDYES; bool bRet = true; if (destPath.Exists() && !destPath.IsDirectory() && !destPath.IsEquivalentToWithoutCase(srcPathList[0])) { CString sReplace; sReplace.Format(IDS_PROC_REPLACEEXISTING, destPath.GetWinPath()); CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); INT_PTR ret = taskdlg.DoModal(hWnd); if (ret == 1) // replace idret = IDYES; else idret = IDNO; if (idret == IDYES) { if (!svn.Remove(CTSVNPathList(destPath), true, false)) { destPath.Delete(true); } } } if ((idret != IDNO)&&(!svn.Move(srcPathList, destPath, message, move_as_child, make_parents))) { auto apr_err = svn.GetSVNError()->apr_err; if ((apr_err == SVN_ERR_ENTRY_NOT_FOUND) || (apr_err == SVN_ERR_WC_PATH_NOT_FOUND)) { bRet = !!MoveFile(srcPathList[0].GetWinPath(), destPath.GetWinPath()); } else { svn.ShowErrorDialog(hWnd, srcPathList.GetCommonDirectory()); bRet = false; } } if (idret == IDNO) bRet = false; return bRet; }
bool DropExternalCommand::Execute() { bool bSuccess = false; CString droppath = parser.GetVal(L"droptarget"); CTSVNPath droptsvnpath = CTSVNPath(droppath); if (droptsvnpath.IsAdminDir()) droptsvnpath = droptsvnpath.GetDirectory(); if (!droptsvnpath.IsDirectory()) droptsvnpath = droptsvnpath.GetDirectory(); // first get the svn:externals property from the target folder SVNProperties props(droptsvnpath, SVNRev::REV_WC, false, false); std::string sExternalsValue; for (int i = 0; i < props.GetCount(); ++i) { if (props.GetItemName(i).compare(SVN_PROP_EXTERNALS) == 0) { sExternalsValue = props.GetItemValue(i); break; } } // we don't add admin dirs as externals pathList.RemoveAdminPaths(); if (pathList.GetCount() == 0) return bSuccess; SVNStatus status; status.GetStatus(droptsvnpath); CString sTargetRepoRootUrl; if (status.status && status.status->repos_root_url) { sTargetRepoRootUrl = CUnicodeUtils::GetUnicode(status.status->repos_root_url); } if (sTargetRepoRootUrl.IsEmpty()) { // failed to get the status and/or the repo root url CString messageString; messageString.Format(IDS_ERR_NOURLOFFILE, droptsvnpath.GetWinPath()); ::MessageBox(GetExplorerHWND(), messageString, L"TortoiseSVN", MB_ICONERROR); } SVN svn; for (auto i = 0; i < pathList.GetCount(); ++i) { CTSVNPath destPath = droptsvnpath; destPath.AppendPathString(pathList[i].GetFileOrDirectoryName()); bool bExists = !!PathFileExists(destPath.GetWinPath()); if (!bExists && (PathIsDirectory(pathList[i].GetWinPath()) || CopyFile(pathList[i].GetWinPath(), destPath.GetWinPath(), TRUE))) { SVNStatus sourceStatus; sourceStatus.GetStatus(pathList[i]); if (sourceStatus.status && sourceStatus.status->repos_root_url) { CString sExternalRootUrl = CUnicodeUtils::GetUnicode(sourceStatus.status->repos_root_url); CString sExternalUrl = svn.GetURLFromPath(pathList[i]); CString sExtValue = sExternalUrl + L" " + pathList[i].GetFileOrDirectoryName(); // check if the url is from the same repo as the target, and if it is // use a relative external url instead of a full url if (sTargetRepoRootUrl.Compare(sExternalRootUrl) == 0) { sExtValue = L"^" + sExternalUrl.Mid(sTargetRepoRootUrl.GetLength()) + L" " + pathList[i].GetFileOrDirectoryName(); } if (!sExternalsValue.empty()) { if (sExternalsValue[sExternalsValue.size() - 1] != '\n') sExternalsValue += "\n"; } sExternalsValue += CUnicodeUtils::StdGetUTF8((LPCWSTR)sExtValue); bSuccess = true; } } else { // the file already exists, there can't be an external with the // same name. CString messageString; messageString.Format(IDS_DROPEXT_FILEEXISTS, (LPCWSTR)pathList[i].GetFileOrDirectoryName()); ::MessageBox(GetExplorerHWND(), messageString, L"TortoiseSVN", MB_ICONERROR); bSuccess = false; } } if (bSuccess) { bSuccess = !!props.Add(SVN_PROP_EXTERNALS, sExternalsValue, true); if (bSuccess) { CString sInfo; sInfo.Format(IDS_DROPEXT_UPDATE_TASK1, (LPCTSTR)droptsvnpath.GetFileOrDirectoryName()); CTaskDialog taskdlg(sInfo, CString(MAKEINTRESOURCE(IDS_DROPEXT_UPDATE_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_DROPEXT_UPDATE_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_DROPEXT_UPDATE_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); bool doUpdate = (taskdlg.DoModal(GetExplorerHWND()) == 1); if (doUpdate) { DWORD exitcode = 0; CString error; ProjectProperties pprops; pprops.ReadPropsPathList(pathList); CHooks::Instance().SetProjectProperties(droptsvnpath, pprops); if (CHooks::Instance().StartUpdate(GetExplorerHWND(), pathList, exitcode, error)) { if (exitcode) { CString temp; temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error); ::MessageBox(GetExplorerHWND(), temp, L"TortoiseSVN", MB_ICONERROR); return FALSE; } } CSVNProgressDlg progDlg; theApp.m_pMainWnd = &progDlg; progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Update); progDlg.SetAutoClose(parser); progDlg.SetOptions(ProgOptSkipPreChecks); progDlg.SetPathList(CTSVNPathList(droptsvnpath)); progDlg.SetRevision(SVNRev(L"HEAD")); progDlg.SetProjectProperties(pprops); progDlg.SetDepth(svn_depth_unknown); progDlg.DoModal(); return !progDlg.DidErrorsOccur(); } } else { // adding the svn:externals property failed, remove all the copied files props.ShowErrorDialog(GetExplorerHWND()); } } return bSuccess != false; }
bool DropMoveCommand::Execute() { CString droppath = parser.GetVal(_T("droptarget")); if (CTSVNPath(droppath).IsAdminDir()) return FALSE; SVN svn; unsigned long count = 0; pathList.RemoveAdminPaths(); CString sNewName; if ((parser.HasKey(_T("rename")))&&(pathList.GetCount()==1)) { // ask for a new name of the source item CRenameDlg renDlg; renDlg.SetInputValidator(this); renDlg.m_windowtitle.LoadString(IDS_PROC_MOVERENAME); renDlg.m_name = pathList[0].GetFileOrDirectoryName(); if (renDlg.DoModal() != IDOK) { return FALSE; } sNewName = renDlg.m_name; } CProgressDlg progress; if (progress.IsValid()) { progress.SetTitle(IDS_PROC_MOVING); progress.SetAnimation(IDR_MOVEANI); progress.SetTime(true); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); } UINT msgRet = IDNO; for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { CTSVNPath destPath; if (sNewName.IsEmpty()) destPath = CTSVNPath(droppath+_T("\\")+pathList[nPath].GetFileOrDirectoryName()); else destPath = CTSVNPath(droppath+_T("\\")+sNewName); // path the same but case-changed is ok: results in a case-rename if (!(pathList[nPath].IsEquivalentToWithoutCase(destPath) && !pathList[nPath].IsEquivalentTo(destPath))) { if (destPath.Exists()) { CString name = pathList[nPath].GetFileOrDirectoryName(); if (!sNewName.IsEmpty()) name = sNewName; progress.Stop(); CRenameDlg dlg; dlg.SetInputValidator(this); dlg.m_name = name; dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name); if (dlg.DoModal() != IDOK) { return FALSE; } destPath.SetFromWin(droppath+_T("\\")+dlg.m_name); } } if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath)) { if ((svn.GetSVNError() && svn.GetSVNError()->apr_err == SVN_ERR_ENTRY_EXISTS) && (destPath.Exists())) { if ((msgRet != IDYESTOALL) && (msgRet != IDNOTOALL)) { // target file already exists. Ask user if he wants to replace the file CString sReplace; sReplace.Format(IDS_PROC_REPLACEEXISTING, destPath.GetWinPath()); if (CTaskDialog::IsSupported()) { CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS|TDF_ALLOW_DIALOG_CANCELLATION|TDF_POSITION_RELATIVE_TO_WINDOW); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK5))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); INT_PTR ret = taskdlg.DoModal(GetExplorerHWND()); if (ret == 1) // replace msgRet = taskdlg.GetVerificationCheckboxState() ? IDYES : IDYESTOALL; else msgRet = taskdlg.GetVerificationCheckboxState() ? IDNO : IDNOTOALL; } else { msgRet = TSVNMessageBox(GetExplorerHWND(), sReplace, _T("TortoiseSVN"), MB_ICONQUESTION|MB_YESNO|MB_YESTOALL|MB_NOTOALL); } } if ((msgRet == IDYES) || (msgRet == IDYESTOALL)) { if (!svn.Remove(CTSVNPathList(destPath), true, false)) { destPath.Delete(true); } if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath)) { svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); return FALSE; //get out of here } CShellUpdater::Instance().AddPathForUpdate(destPath); } } else { svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); return FALSE; //get out of here } } else CShellUpdater::Instance().AddPathForUpdate(destPath); count++; if (progress.IsValid()) { progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath()); progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath()); progress.SetProgress(count, pathList.GetCount()); } if ((progress.IsValid())&&(progress.HasUserCancelled())) { TSVNMessageBox(GetExplorerHWND(), IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION); return FALSE; } } return true; }
void CCopyDlg::OnOK() { if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible())) { m_pLogDlg->SendMessage(WM_CLOSE); return; } m_bCancelled = true; // check if the status thread has already finished if ((m_pThread)&&(m_bThreadRunning)) { WaitForSingleObject(m_pThread->m_hThread, 1000); if (m_bThreadRunning) { // we gave the thread a chance to quit. Since the thread didn't // listen to us we have to kill it. TerminateThread(m_pThread->m_hThread, (DWORD)-1); InterlockedExchange(&m_bThreadRunning, FALSE); } } CString id; GetDlgItemText(IDC_BUGID, id); CString sRevText; GetDlgItemText(IDC_COPYREVTEXT, sRevText); if (!m_ProjectProperties.CheckBugID(id)) { ShowEditBalloon(IDC_BUGID, IDS_COMMITDLG_ONLYNUMBERS, IDS_ERR_ERROR, TTI_ERROR); return; } m_sLogMessage = m_cLogMessage.GetText(); if ((m_ProjectProperties.bWarnIfNoIssue) && (id.IsEmpty() && !m_ProjectProperties.HasBugID(m_sLogMessage))) { CTaskDialog taskdlg(CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK1)), CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); if (taskdlg.DoModal(m_hWnd) != 1) return; } UpdateData(TRUE); if (GetCheckedRadioButton(IDC_COPYHEAD, IDC_COPYREV) == IDC_COPYHEAD) m_CopyRev = SVNRev(SVNRev::REV_HEAD); else if (GetCheckedRadioButton(IDC_COPYHEAD, IDC_COPYREV) == IDC_COPYWC) m_CopyRev = SVNRev(SVNRev::REV_WC); else m_CopyRev = SVNRev(sRevText); if (!m_CopyRev.IsValid()) { ShowEditBalloon(IDC_COPYREVTEXT, IDS_ERR_INVALIDREV, IDS_ERR_ERROR, TTI_ERROR); return; } CString combourl = m_URLCombo.GetWindowString(); if (combourl.IsEmpty()) combourl = m_URLCombo.GetString(); if ((m_wcURL.CompareNoCase(combourl)==0)&&(m_CopyRev.IsHead())) { CString temp; temp.FormatMessage(IDS_ERR_COPYITSELF, (LPCTSTR)m_wcURL, (LPCTSTR)m_URLCombo.GetString()); ::MessageBox(this->m_hWnd, temp, L"TortoiseSVN", MB_ICONERROR); return; } m_URLCombo.SaveHistory(); m_URL = CPathUtils::CombineUrls(m_repoRoot, m_URLCombo.GetString()); if (!CTSVNPath(m_URL).IsValidOnWindows()) { CString sInfo; sInfo.Format(IDS_WARN_NOVALIDPATH_TASK1, (LPCTSTR)m_URL); CTaskDialog taskdlg(sInfo, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetExpansionArea(CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK5))); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); if (taskdlg.DoModal(m_hWnd) != 1) return; } CStringUtils::WriteAsciiStringToClipboard(m_URL); // now let the bugtraq plugin check the commit message CComPtr<IBugTraqProvider2> pProvider2 = NULL; if (m_BugTraqProvider) { HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2); if (SUCCEEDED(hr)) { ATL::CComBSTR temp; ATL::CComBSTR sourceURL; sourceURL.Attach(m_wcURL.AllocSysString()); ATL::CComBSTR parameters; parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString()); ATL::CComBSTR targetURL; targetURL.Attach(m_URL.AllocSysString()); ATL::CComBSTR commitMessage; commitMessage.Attach(m_sLogMessage.AllocSysString()); CBstrSafeVector pathList(1); pathList.PutElement(0, m_path.GetSVNPathString()); hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, sourceURL, targetURL, pathList, commitMessage, &temp); if (FAILED(hr)) { OnComError(hr); } else { CString sError = temp == 0 ? L"" : temp; if (!sError.IsEmpty()) { CAppUtils::ReportFailedHook(m_hWnd, sError); return; } } } } CTSVNPathList checkedItems; checkedItems.AddPath(m_path); DWORD exitcode = 0; CString error; CHooks::Instance().SetProjectProperties(m_path, m_ProjectProperties); if (CHooks::Instance().CheckCommit(m_hWnd, checkedItems, m_sLogMessage, exitcode, error)) { if (exitcode) { CString sErrorMsg; sErrorMsg.Format(IDS_HOOK_ERRORMSG, (LPCWSTR)error); CTaskDialog taskdlg(sErrorMsg, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK4))); taskdlg.SetDefaultCommandControl(1); taskdlg.SetMainIcon(TD_ERROR_ICON); bool retry = (taskdlg.DoModal(GetSafeHwnd()) == 1); if (retry) return; } } if (!m_sLogMessage.IsEmpty()) { m_History.AddEntry(m_sLogMessage); m_History.Save(); } m_sBugID.Trim(); if (!m_sBugID.IsEmpty()) { m_sBugID.Replace(L", ", L","); m_sBugID.Replace(L" ,", L","); CString sBugID = m_ProjectProperties.sMessage; sBugID.Replace(L"%BUGID%", m_sBugID); if (m_ProjectProperties.bAppend) m_sLogMessage += L"\n" + sBugID + L"\n"; else m_sLogMessage = sBugID + L"\n" + m_sLogMessage; UpdateData(FALSE); } CResizableStandAloneDialog::OnOK(); }
bool ExportCommand::Execute() { bool bRet = false; // When the user clicked on a working copy, we know that the export should // be done from that. We then have to ask where the export should go to. // If however the user clicked on an unversioned folder, we assume that // this is where the export should go to and have to ask from where // the export should be done from. bool bURL = !!SVN::PathIsURL(cmdLinePath); svn_wc_status_kind s = SVNStatus::GetAllStatus(cmdLinePath); if ((bURL)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_none)) { // ask from where the export has to be done CExportDlg dlg; if (bURL) dlg.m_URL = cmdLinePath.GetSVNPathString(); else dlg.m_strExportDirectory = cmdLinePath.GetWinPathString(); if (parser.HasKey(_T("revision"))) { SVNRev Rev = SVNRev(parser.GetVal(_T("revision"))); dlg.Revision = Rev; } dlg.m_blockPathAdjustments = parser.HasKey(L"blockpathadjustments"); if (dlg.DoModal() == IDOK) { CTSVNPath exportPath(dlg.m_strExportDirectory); CSVNProgressDlg progDlg; theApp.m_pMainWnd = &progDlg; progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Export); progDlg.SetAutoClose (parser); DWORD options = dlg.m_bNoExternals ? ProgOptIgnoreExternals : ProgOptNone; options |= dlg.m_bNoKeywords ? ProgOptIgnoreKeywords : ProgOptNone; if (dlg.m_eolStyle.CompareNoCase(_T("CRLF"))==0) options |= ProgOptEolCRLF; if (dlg.m_eolStyle.CompareNoCase(_T("CR"))==0) options |= ProgOptEolCR; if (dlg.m_eolStyle.CompareNoCase(_T("LF"))==0) options |= ProgOptEolLF; progDlg.SetOptions(options); progDlg.SetPathList(CTSVNPathList(exportPath)); progDlg.SetUrl(dlg.m_URL); progDlg.SetRevision(dlg.Revision); progDlg.SetDepth(dlg.m_depth); progDlg.DoModal(); bRet = !progDlg.DidErrorsOccur(); } } else { // ask where the export should go to. CBrowseFolder folderBrowser; CString strTemp; strTemp.LoadString(IDS_PROC_EXPORT_1); folderBrowser.SetInfo(strTemp); folderBrowser.m_style = BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_EDITBOX; strTemp.LoadString(IDS_PROC_EXPORT_2); folderBrowser.SetCheckBoxText(strTemp); strTemp.LoadString(IDS_PROC_OMMITEXTERNALS); folderBrowser.SetCheckBoxText2(strTemp); folderBrowser.DisableCheckBox2WhenCheckbox1IsEnabled(true); CRegDWORD regExtended = CRegDWORD(_T("Software\\TortoiseSVN\\ExportExtended"), FALSE); CBrowseFolder::m_bCheck = regExtended; TCHAR saveto[MAX_PATH]; if (folderBrowser.Show(GetExplorerHWND(), saveto, _countof(saveto))==CBrowseFolder::OK) { CString saveplace = CString(saveto); if (cmdLinePath.IsEquivalentTo(CTSVNPath(saveplace))) { // exporting to itself: // remove all svn admin dirs, effectively unversion the 'exported' folder. CString msg; msg.Format(IDS_PROC_EXPORTUNVERSION, (LPCTSTR)saveplace); bool bUnversion = false; if (CTaskDialog::IsSupported()) { CTaskDialog taskdlg(msg, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS|TDF_USE_COMMAND_LINKS|TDF_ALLOW_DIALOG_CANCELLATION|TDF_POSITION_RELATIVE_TO_WINDOW); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(1); taskdlg.SetMainIcon(TD_WARNING_ICON); bUnversion = (taskdlg.DoModal(GetExplorerHWND()) == 1); } else { bUnversion = (MessageBox(GetExplorerHWND(), msg, _T("TortoiseSVN"), MB_ICONQUESTION|MB_YESNO) == IDYES); } if (bUnversion) { CProgressDlg progress; progress.SetTitle(IDS_PROC_UNVERSION); progress.SetAnimation(IDR_MOVEANI); progress.FormatNonPathLine(1, IDS_SVNPROGRESS_EXPORTINGWAIT); progress.SetTime(true); progress.ShowModeless(GetExplorerHWND()); std::vector<CTSVNPath> removeVector; CDirFileEnum lister(saveplace); CString srcFile; bool bFolder = false; while (lister.NextFile(srcFile, &bFolder)) { CTSVNPath item(srcFile); if ((bFolder)&&(g_SVNAdminDir.IsAdminDirName(item.GetFileOrDirectoryName()))) { removeVector.push_back(item); } } DWORD count = 0; for (std::vector<CTSVNPath>::iterator it = removeVector.begin(); (it != removeVector.end()) && (!progress.HasUserCancelled()); ++it) { progress.FormatPathLine(1, IDS_SVNPROGRESS_UNVERSION, (LPCTSTR)it->GetWinPath()); progress.SetProgress64(count, removeVector.size()); count++; it->Delete(false); } progress.Stop(); bRet = true; } else return false; } else { CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": export %s to %s\n"), (LPCTSTR)cmdLinePath.GetUIPathString(), (LPCTSTR)saveto); SVN svn; if (!svn.Export(cmdLinePath, CTSVNPath(saveplace), SVNRev::REV_WC, SVNRev::REV_WC, false, !!folderBrowser.m_bCheck2, false, svn_depth_infinity, GetExplorerHWND(), folderBrowser.m_bCheck ? SVN::SVNExportIncludeUnversioned : SVN::SVNExportNormal)) { svn.ShowErrorDialog(GetExplorerHWND(), cmdLinePath); bRet = false; } else bRet = true; regExtended = CBrowseFolder::m_bCheck; } } } return bRet; }
bool DropCopyCommand::Execute() { CString sDroppath = parser.GetVal(L"droptarget"); if (CTSVNPath(sDroppath).IsAdminDir()) return FALSE; SVN svn; unsigned long count = 0; CString sNewName; pathList.RemoveAdminPaths(); if ((parser.HasKey(L"rename"))&&(pathList.GetCount()==1)) { // ask for a new name of the source item CRenameDlg renDlg; renDlg.SetInputValidator(this); renDlg.SetFileSystemAutoComplete(); renDlg.m_windowtitle.LoadString(IDS_PROC_COPYRENAME); renDlg.m_name = pathList[0].GetFileOrDirectoryName(); if (renDlg.DoModal() != IDOK) { return FALSE; } sNewName = renDlg.m_name; } CProgressDlg progress; progress.SetTitle(IDS_PROC_COPYING); progress.SetTime(true); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); UINT msgRet = IDNO; INT_PTR msgRetNonversioned = 0; for (int nPath = 0; nPath < pathList.GetCount(); nPath++) { const CTSVNPath& sourcePath = pathList[nPath]; CTSVNPath fullDropPath(sDroppath); if (sNewName.IsEmpty()) fullDropPath.AppendPathString(sourcePath.GetFileOrDirectoryName()); else fullDropPath.AppendPathString(sNewName); // Check for a drop-on-to-ourselves if (sourcePath.IsEquivalentTo(fullDropPath)) { // Offer a rename progress.Stop(); CRenameDlg dlg; dlg.SetFileSystemAutoComplete(); dlg.m_windowtitle.Format(IDS_PROC_NEWNAMECOPY, (LPCTSTR)sourcePath.GetUIFileOrDirectoryName()); if (dlg.DoModal() != IDOK) { return FALSE; } // rebuild the progress dialog progress.EnsureValid(); progress.SetTitle(IDS_PROC_COPYING); progress.SetTime(true); progress.SetProgress(count, pathList.GetCount()); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); // Rebuild the destination path, with the new name fullDropPath.SetFromUnknown(sDroppath); fullDropPath.AppendPathString(dlg.m_name); } if (!svn.Copy(CTSVNPathList(sourcePath), fullDropPath, SVNRev::REV_WC, SVNRev())) { if ((svn.GetSVNError() && svn.GetSVNError()->apr_err == SVN_ERR_ENTRY_EXISTS) && (fullDropPath.Exists())) { if ((msgRet != IDYESTOALL) && (msgRet != IDNOTOALL)) { // target file already exists. Ask user if he wants to replace the file CString sReplace; sReplace.Format(IDS_PROC_REPLACEEXISTING, fullDropPath.GetWinPath()); CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK5))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); INT_PTR ret = taskdlg.DoModal(GetExplorerHWND()); if (ret == 1) // replace msgRet = taskdlg.GetVerificationCheckboxState() ? IDYES : IDYESTOALL; else msgRet = taskdlg.GetVerificationCheckboxState() ? IDNO : IDNOTOALL; } if ((msgRet == IDYES) || (msgRet == IDYESTOALL)) { if (!svn.Remove(CTSVNPathList(fullDropPath), true, false)) { fullDropPath.Delete(true); } if (!svn.Copy(CTSVNPathList(pathList[nPath]), fullDropPath, SVNRev::REV_WC, SVNRev())) { svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); return FALSE; //get out of here } } } else { svn.ShowErrorDialog(GetExplorerHWND(), sourcePath); return FALSE; //get out of here } } else if (svn.GetSVNError() && svn.GetSVNError()->apr_err == SVN_ERR_WC_PATH_NOT_FOUND) { INT_PTR ret = 0; if (msgRetNonversioned == 0) { CString sReplace; sReplace.Format(IDS_PROC_MOVEUNVERSIONED_TASK1, fullDropPath.GetWinPath()); CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK2)), L"TortoiseSVN", TDCBF_CANCEL_BUTTON, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(101, CString(MAKEINTRESOURCE(IDS_PROC_COPYUNVERSIONED_TASK3))); taskdlg.AddCommandControl(102, CString(MAKEINTRESOURCE(IDS_PROC_COPYUNVERSIONED_TASK4))); taskdlg.AddCommandControl(103, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK5))); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK6))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(103); taskdlg.SetMainIcon(TD_WARNING_ICON); ret = taskdlg.DoModal(GetExplorerHWND()); if (taskdlg.GetVerificationCheckboxState()) msgRetNonversioned = ret; } else { ret = msgRetNonversioned; } switch (ret) { case 101: // copy CopyFile(pathList[nPath].GetWinPath(), fullDropPath.GetWinPath(), FALSE); break; case 102: // copy and add CopyFile(pathList[nPath].GetWinPath(), fullDropPath.GetWinPath(), FALSE); if (!svn.Add(CTSVNPathList(fullDropPath), NULL, svn_depth_infinity, true, false, false, false)) { svn.ShowErrorDialog(GetExplorerHWND(), fullDropPath); return FALSE; //get out of here } break; case 103: // skip default: break; } } else CShellUpdater::Instance().AddPathForUpdate(fullDropPath); count++; if (progress.IsValid()) { progress.FormatPathLine(1, IDS_PROC_COPYINGPROG, sourcePath.GetWinPath()); progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, fullDropPath.GetWinPath()); progress.SetProgress(count, pathList.GetCount()); } if ((progress.IsValid())&&(progress.HasUserCancelled())) { TaskDialog(GetExplorerHWND(), AfxGetResourceHandle(), MAKEINTRESOURCE(IDS_APPNAME), MAKEINTRESOURCE(IDS_SVN_USERCANCELLED), NULL, TDCBF_OK_BUTTON, TD_INFORMATION_ICON, NULL); return false; } } return true; }
void CExportDlg::OnOK() { if (!UpdateData(TRUE)) return; // don't dismiss dialog (error message already shown by MFC framework) if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible())) { m_pLogDlg->SendMessage(WM_CLOSE); return; } // check it the export path is a valid windows path CTSVNPath ExportDirectory; if (::PathIsRelative(m_strExportDirectory)) { ExportDirectory = CTSVNPath(sOrigCWD); ExportDirectory.AppendPathString(L"\\" + m_strExportDirectory); m_strExportDirectory = ExportDirectory.GetWinPathString(); } else ExportDirectory = CTSVNPath(m_strExportDirectory); if (!ExportDirectory.IsValidOnWindows()) { ShowEditBalloon(IDC_CHECKOUTDIRECTORY, IDS_ERR_NOVALIDPATH, IDS_ERR_ERROR, TTI_ERROR); return; } // check if the specified revision is valid if (GetCheckedRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N) == IDC_REVISION_HEAD) { Revision = SVNRev(L"HEAD"); } else Revision = SVNRev(m_sRevision); if (!Revision.IsValid()) { ShowEditBalloon(IDC_REVISION_NUM, IDS_ERR_INVALIDREV, IDS_ERR_ERROR, TTI_ERROR); return; } bool bAutoCreateTargetName = m_bAutoCreateTargetName; m_bAutoCreateTargetName = false; m_URLCombo.SaveHistory(); m_URL = m_URLCombo.GetString(); // we need an url to export from - local paths won't work if (!SVN::PathIsURL(CTSVNPath(m_URL))) { m_tooltips.ShowBalloon(IDC_URLCOMBO, IDS_ERR_MUSTBEURL, IDS_ERR_ERROR, TTI_ERROR); m_bAutoCreateTargetName = bAutoCreateTargetName; return; } if (m_strExportDirectory.IsEmpty()) { m_bAutoCreateTargetName = bAutoCreateTargetName; return; } // if the export directory does not exist, where should we export to? // We ask if the directory should be created... if (!PathFileExists(m_strExportDirectory)) { CPathUtils::MakeSureDirectoryPathExists(m_strExportDirectory); } // if the directory we should export to is not empty, show a warning: // maybe the user doesn't want to overwrite the existing files. if (!PathIsDirectoryEmpty(m_strExportDirectory)) { CString message; message.Format(CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY)),(LPCTSTR)m_strExportDirectory); CTaskDialog taskdlg(message, CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK3_1))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); bool doIt = (taskdlg.DoModal(GetExplorerHWND()) == 1); if (!doIt) { m_bAutoCreateTargetName = bAutoCreateTargetName; return; //don't dismiss the dialog } } m_eolCombo.GetWindowText(m_eolStyle); if (m_eolStyle.Compare(L"default")==0) m_eolStyle.Empty(); switch (m_depthCombo.GetCurSel()) { case 0: m_depth = svn_depth_infinity; break; case 1: m_depth = svn_depth_immediates; break; case 2: m_depth = svn_depth_files; break; case 3: m_depth = svn_depth_empty; break; default: m_depth = svn_depth_empty; break; } UpdateData(FALSE); CRegDWORD regNoExt(L"Software\\TortoiseSVN\\noext"); regNoExt = m_bNoExternals; CResizableStandAloneDialog::OnOK(); }
bool RemoveCommand::Execute() { bool bRet = false; // removing items from a working copy is done item-by-item so we // have a chance to show a progress bar // // removing items from an URL in the repository requires that we // ask the user for a log message. SVN svn; if ((pathList.GetCount())&&(SVN::PathIsURL(pathList[0]))) { // Delete using URL's, not wc paths svn.SetPromptApp(&theApp); CInputLogDlg dlg; CString sUUID; svn.GetRepositoryRootAndUUID(pathList[0], true, sUUID); dlg.SetUUID(sUUID); CString sHint; if (pathList.GetCount() == 1) sHint.Format(IDS_INPUT_REMOVEONE, (LPCTSTR)pathList[0].GetSVNPathString()); else sHint.Format(IDS_INPUT_REMOVEMORE, pathList.GetCount()); dlg.SetActionText(sHint); if (dlg.DoModal()==IDOK) { if (!svn.Remove(pathList, true, !!parser.HasKey(L"keep"), dlg.GetLogMessage())) { svn.ShowErrorDialog(GetExplorerHWND(), pathList.GetCommonDirectory()); return false; } return true; } return false; } else { bool bForce = false; for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": remove file %s\n", (LPCTSTR)pathList[nPath].GetUIPathString()); // even though SVN::Remove takes a list of paths to delete at once // we delete each item individually so we can prompt the user // if something goes wrong or unversioned/modified items are // to be deleted CTSVNPathList removePathList(pathList[nPath]); if ((bForce)&&(!parser.HasKey(L"keep"))) { CTSVNPath delPath = removePathList[0]; if (!delPath.IsDirectory()) delPath.Delete(true); // note: we don't move folders to the trash bin, so they can't // get restored anymore - svn removes *all* files in a removed // folder, even modified and unversioned ones // We could move the folders here to the trash bin too, but then // the folder would be gone and will require a recursive commit. // Of course: a solution would be to first create a copy of the folder, // move the original folder to the trash, then rename the copied folder // to the original name, then let svn delete the folder - but // that would just take too much time for bigger folders... } if (!svn.Remove(removePathList, bForce, !!parser.HasKey(L"keep"))) { if ((svn.GetSVNError()->apr_err == SVN_ERR_UNVERSIONED_RESOURCE) || (svn.GetSVNError()->apr_err == SVN_ERR_CLIENT_MODIFIED)) { UINT ret = 0; CString msg; if (pathList[nPath].IsDirectory()) msg.Format(IDS_PROC_REMOVEFORCE_TASK1_2, (LPCTSTR)svn.GetLastErrorMessage(0), (LPCTSTR)pathList[nPath].GetFileOrDirectoryName()); else msg.Format(IDS_PROC_REMOVEFORCE_TASK1, (LPCTSTR)svn.GetLastErrorMessage(0), (LPCTSTR)pathList[nPath].GetFileOrDirectoryName()); CTaskDialog taskdlg(msg, CString(MAKEINTRESOURCE(IDS_PROC_REMOVEFORCE_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW); taskdlg.AddCommandControl(IDYES, CString(MAKEINTRESOURCE(IDS_PROC_REMOVEFORCE_TASK3))); taskdlg.AddCommandControl(IDNO, CString(MAKEINTRESOURCE(IDS_PROC_REMOVEFORCE_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_REMOVEFORCE_TASK5))); taskdlg.SetDefaultCommandControl(IDNO); taskdlg.SetMainIcon(TD_WARNING_ICON); ret = (UINT)taskdlg.DoModal(GetExplorerHWND()); if (taskdlg.GetVerificationCheckboxState()) bForce = true; if (ret == IDYESTOALL) bForce = true; if ((ret == IDYES)||(ret==IDYESTOALL)) { if (!parser.HasKey(L"keep")) { CTSVNPath delPath = removePathList[0]; if (!delPath.IsDirectory()) delPath.Delete(true); // note: see comment for the delPath.Delete() above } if (!svn.Remove(removePathList, true, !!parser.HasKey(L"keep"))) { svn.ShowErrorDialog(GetExplorerHWND(), removePathList.GetCommonDirectory()); } else bRet = true; } } else svn.ShowErrorDialog(GetExplorerHWND(), removePathList.GetCommonDirectory()); } } } if (bRet) CShellUpdater::Instance().AddPathsForUpdate(pathList); return bRet; }
bool DropExportCommand::Execute() { bool bRet = true; CString droppath = parser.GetVal(L"droptarget"); if (CTSVNPath(droppath).IsAdminDir()) return false; SVN::SVNExportType exportType = SVN::SVNExportNormal; if (parser.HasKey(L"extended")) { exportType = SVN::SVNExportIncludeUnversioned; CString et = parser.GetVal(L"extended"); if (et == L"localchanges") exportType = SVN::SVNExportOnlyLocalChanges; if (et == L"unversioned") exportType = SVN::SVNExportIncludeUnversioned; } SVN svn; if ((pathList.GetCount() == 1)&& (pathList[0].IsEquivalentTo(CTSVNPath(droppath)))) { // exporting to itself: // remove all svn admin dirs, effectively unversion the 'exported' folder. CString msg; msg.Format(IDS_PROC_EXPORTUNVERSION, (LPCTSTR)droppath); CTaskDialog taskdlg(msg, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_EXPORTUNVERSION_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(1); taskdlg.SetMainIcon(TD_WARNING_ICON); if (taskdlg.DoModal(GetExplorerHWND()) != 1) return false; CProgressDlg progress; progress.SetTitle(IDS_PROC_UNVERSION); progress.FormatNonPathLine(1, IDS_SVNPROGRESS_EXPORTINGWAIT); progress.SetTime(true); progress.ShowModeless(GetExplorerHWND()); std::vector<CTSVNPath> removeVector; CDirFileEnum lister(droppath); CString srcFile; bool bFolder = false; while (lister.NextFile(srcFile, &bFolder)) { CTSVNPath item(srcFile); if ((bFolder)&&(g_SVNAdminDir.IsAdminDirName(item.GetFileOrDirectoryName()))) { removeVector.push_back(item); } } DWORD count = 0; for (std::vector<CTSVNPath>::iterator it = removeVector.begin(); (it != removeVector.end()) && (!progress.HasUserCancelled()); ++it) { progress.FormatPathLine(1, IDS_SVNPROGRESS_UNVERSION, (LPCTSTR)it->GetWinPath()); progress.SetProgress64(count, removeVector.size()); count++; it->Delete(false); } progress.Stop(); } else { bool bOverwrite = !!parser.HasKey(L"overwrite"); bool bAutorename = !!parser.HasKey(L"autorename"); UINT retDefault = bAutorename ? IDCUSTOM1 : 0; for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { CString dropper = droppath + L"\\" + pathList[nPath].GetFileOrDirectoryName(); if ((!bOverwrite)&&(PathFileExists(dropper))) { CString renameddropper; renameddropper.FormatMessage(IDS_PROC_EXPORTFOLDERNAME, (LPCTSTR)droppath, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName()); int exportcount = 1; while (PathFileExists(renameddropper)) { renameddropper.FormatMessage(IDS_PROC_EXPORTFOLDERNAME2, (LPCTSTR)droppath, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName(), exportcount++); } UINT ret = retDefault; if (ret == 0) { CString sMsg; sMsg.Format(IDS_PROC_OVERWRITEEXPORT, (LPCTSTR)dropper); CTaskDialog taskdlg(sMsg, CString(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_TASK2)), L"TortoiseSVN", 0, TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(IDCUSTOM1, CString(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_TASK3))); CString task4; task4.Format(IDS_PROC_OVERWRITEEXPORT_TASK4, (LPCTSTR)renameddropper); taskdlg.AddCommandControl(IDCUSTOM2, task4); taskdlg.AddCommandControl(IDCUSTOM3, CString(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_TASK5))); taskdlg.SetDefaultCommandControl(IDCUSTOM2); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_TASK6))); taskdlg.SetMainIcon(TD_WARNING_ICON); ret = (UINT)taskdlg.DoModal(GetExplorerHWND()); if (taskdlg.GetVerificationCheckboxState()) retDefault = ret; } if (ret == IDCUSTOM3) return false; if (ret==IDCUSTOM2) { dropper = renameddropper; } } if (!svn.Export(pathList[nPath], CTSVNPath(dropper), SVNRev::REV_WC ,SVNRev::REV_WC, !!parser.HasKey(L"overwrite"), false, false, svn_depth_infinity, GetExplorerHWND(), exportType)) { svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); bRet = false; } } } return bRet; }
bool DropMoveCommand::Execute() { CString droppath = parser.GetVal(L"droptarget"); if (CTSVNPath(droppath).IsAdminDir()) return FALSE; SVN svn; unsigned long count = 0; pathList.RemoveAdminPaths(); CString sNewName; if ((parser.HasKey(L"rename"))&&(pathList.GetCount()==1)) { // ask for a new name of the source item CRenameDlg renDlg; renDlg.SetFileSystemAutoComplete(); renDlg.SetInputValidator(this); renDlg.m_windowtitle.LoadString(IDS_PROC_MOVERENAME); renDlg.m_name = pathList[0].GetFileOrDirectoryName(); if (renDlg.DoModal() != IDOK) { return FALSE; } sNewName = renDlg.m_name; } CProgressDlg progress; if (progress.IsValid()) { progress.SetTitle(IDS_PROC_MOVING); progress.SetTime(true); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); } UINT msgRet = IDNO; INT_PTR msgRetNonversioned = 0; for (int nPath = 0; nPath < pathList.GetCount(); nPath++) { CTSVNPath destPath; if (sNewName.IsEmpty()) destPath = CTSVNPath(droppath+L"\\"+pathList[nPath].GetFileOrDirectoryName()); else destPath = CTSVNPath(droppath+L"\\"+sNewName); // path the same but case-changed is ok: results in a case-rename if (!(pathList[nPath].IsEquivalentToWithoutCase(destPath) && !pathList[nPath].IsEquivalentTo(destPath))) { if (destPath.Exists()) { progress.Stop(); CString name = pathList[nPath].GetFileOrDirectoryName(); if (!sNewName.IsEmpty()) name = sNewName; progress.Stop(); CRenameDlg dlg; dlg.SetFileSystemAutoComplete(); dlg.SetInputValidator(this); dlg.m_name = name; dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name); if (dlg.DoModal() != IDOK) { return FALSE; } destPath.SetFromWin(droppath+L"\\"+dlg.m_name); progress.EnsureValid(); progress.SetTitle(IDS_PROC_MOVING); progress.SetTime(true); progress.SetProgress(count, pathList.GetCount()); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); } } if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath)) { if ((svn.GetSVNError() && svn.GetSVNError()->apr_err == SVN_ERR_ENTRY_EXISTS) && (destPath.Exists())) { if ((msgRet != IDYESTOALL) && (msgRet != IDNOTOALL)) { progress.Stop(); // target file already exists. Ask user if he wants to replace the file CString sReplace; sReplace.Format(IDS_PROC_REPLACEEXISTING, destPath.GetWinPath()); CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_REPLACEEXISTING_TASK5))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); INT_PTR ret = taskdlg.DoModal(GetExplorerHWND()); if (ret == 1) // replace msgRet = taskdlg.GetVerificationCheckboxState() ? IDYESTOALL : IDYES; else msgRet = taskdlg.GetVerificationCheckboxState() ? IDNOTOALL : IDNO; progress.EnsureValid(); progress.SetTitle(IDS_PROC_MOVING); progress.SetTime(true); progress.SetProgress(count, pathList.GetCount()); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); } if ((msgRet == IDYES) || (msgRet == IDYESTOALL)) { if (!svn.Remove(CTSVNPathList(destPath), true, false)) { destPath.Delete(true); } if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath)) { progress.Stop(); svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); return FALSE; //get out of here } CShellUpdater::Instance().AddPathForUpdate(destPath); } } else if (svn.GetSVNError() && svn.GetSVNError()->apr_err == SVN_ERR_WC_PATH_NOT_FOUND) { INT_PTR ret = 0; if (msgRetNonversioned == 0) { progress.Stop(); CString sReplace; sReplace.Format(IDS_PROC_MOVEUNVERSIONED_TASK1, destPath.GetWinPath()); CTaskDialog taskdlg(sReplace, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK2)), L"TortoiseSVN", TDCBF_CANCEL_BUTTON, TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT); taskdlg.AddCommandControl(101, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK3))); taskdlg.AddCommandControl(102, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK4))); taskdlg.AddCommandControl(103, CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK5))); taskdlg.SetVerificationCheckboxText(CString(MAKEINTRESOURCE(IDS_PROC_MOVEUNVERSIONED_TASK6))); taskdlg.SetVerificationCheckbox(false); taskdlg.SetDefaultCommandControl(103); taskdlg.SetMainIcon(TD_WARNING_ICON); ret = taskdlg.DoModal(GetExplorerHWND()); if (taskdlg.GetVerificationCheckboxState()) msgRetNonversioned = ret; progress.EnsureValid(); progress.SetTitle(IDS_PROC_MOVING); progress.SetTime(true); progress.SetProgress(count, pathList.GetCount()); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); } else { ret = msgRetNonversioned; } switch (ret) { case 101: // move MoveFile(pathList[nPath].GetWinPath(), destPath.GetWinPath()); break; case 102: // move and add MoveFile(pathList[nPath].GetWinPath(), destPath.GetWinPath()); if (!svn.Add(CTSVNPathList(destPath), NULL, svn_depth_infinity, true, false, false, false)) { progress.Stop(); svn.ShowErrorDialog(GetExplorerHWND(), destPath); return FALSE; //get out of here } break; case 103: // skip default: break; } } else { progress.Stop(); svn.ShowErrorDialog(GetExplorerHWND(), pathList[nPath]); return FALSE; //get out of here } } else CShellUpdater::Instance().AddPathForUpdate(destPath); count++; if (progress.IsValid()) { progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath()); progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath()); progress.SetProgress(count, pathList.GetCount()); } if ((progress.IsValid())&&(progress.HasUserCancelled())) { progress.Stop(); TaskDialog(GetExplorerHWND(), AfxGetResourceHandle(), MAKEINTRESOURCE(IDS_APPNAME), MAKEINTRESOURCE(IDS_SVN_USERCANCELLED), NULL, TDCBF_OK_BUTTON, TD_INFORMATION_ICON, NULL); return FALSE; } } return true; }
void CInputLogDlg::OnOK() { UpdateData(); m_sLogMsg = m_cInput.GetText(); if (m_pProjectProperties) { CString id; GetDlgItemText(IDC_BUGID, id); id.Trim(_T("\n\r")); if (!m_bLock && !m_pProjectProperties->CheckBugID(id)) { ShowEditBalloon(IDC_BUGID, IDS_COMMITDLG_ONLYNUMBERS, TTI_ERROR); return; } if (!m_bLock && (m_pProjectProperties->bWarnIfNoIssue) && (id.IsEmpty() && !m_pProjectProperties->HasBugID(m_sLogMsg))) { if (CTaskDialog::IsSupported()) { CTaskDialog taskdlg(CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK1)), CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK2)), L"TortoiseSVN", 0, TDF_USE_COMMAND_LINKS|TDF_ALLOW_DIALOG_CANCELLATION|TDF_POSITION_RELATIVE_TO_WINDOW); taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK3))); taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK4))); taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON); taskdlg.SetDefaultCommandControl(2); taskdlg.SetMainIcon(TD_WARNING_ICON); if (taskdlg.DoModal(m_hWnd) != 1) return; } else { if (TSVNMessageBox(this->m_hWnd, IDS_COMMITDLG_NOISSUEWARNING, IDS_APPNAME, MB_YESNO | MB_ICONWARNING)!=IDYES) return; } } m_sBugID.Trim(); CString sExistingBugID = m_pProjectProperties->FindBugID(m_sLogMsg); sExistingBugID.Trim(); if (!m_sBugID.IsEmpty() && m_sBugID.Compare(sExistingBugID)) { m_sBugID.Replace(_T(", "), _T(",")); m_sBugID.Replace(_T(" ,"), _T(",")); CString sBugID = m_pProjectProperties->sMessage; sBugID.Replace(_T("%BUGID%"), m_sBugID); if (m_pProjectProperties->bAppend) m_sLogMsg += _T("\n") + sBugID + _T("\n"); else m_sLogMsg = sBugID + _T("\n") + m_sLogMsg; } if (!m_bLock) { // now let the bugtraq plugin check the commit message CComPtr<IBugTraqProvider2> pProvider2 = NULL; if (m_BugTraqProvider) { HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2); if (SUCCEEDED(hr)) { ATL::CComBSTR temp; CString common = m_rootpath.GetSVNPathString(); ATL::CComBSTR repositoryRoot; repositoryRoot.Attach(common.AllocSysString()); ATL::CComBSTR parameters; parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString()); ATL::CComBSTR commonRoot(m_pathlist.GetCommonRoot().GetDirectory().GetWinPath()); ATL::CComBSTR commitMessage; commitMessage.Attach(m_sLogMsg.AllocSysString()); CBstrSafeVector pathList(m_pathlist.GetCount()); for (LONG index = 0; index < m_pathlist.GetCount(); ++index) pathList.PutElement(index, m_pathlist[index].GetSVNPathString()); hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, repositoryRoot, commonRoot, pathList, commitMessage, &temp); if (FAILED(hr)) { OnComError(hr); } else { CString sError = temp == 0 ? _T("") : temp; if (!sError.IsEmpty()) { CAppUtils::ReportFailedHook(m_hWnd, sError); return; } } } } } } CString reg; reg.Format(_T("Software\\TortoiseSVN\\History\\commit%s"), (LPCTSTR)m_sUUID); CRegHistory history; history.Load(reg, _T("logmsgs")); history.AddEntry(m_sLogMsg); history.Save(); CResizableStandAloneDialog::OnOK(); }