CString SVNPatch::CheckPatchPath( const CString& path ) { // first check if the path already matches if (CountMatches(path) > (GetNumberOfFiles()/3)) return path; CProgressDlg progress; CString tmp; progress.SetTitle(IDS_PATCH_SEARCHPATHTITLE); progress.SetShowProgressBar(false); tmp.LoadString(IDS_PATCH_SEARCHPATHLINE1); progress.SetLine(1, tmp); progress.ShowModeless(AfxGetMainWnd()); // now go up the tree and try again CString upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } // still no match found. So try sub folders bool isDir = false; CString subpath; CDirFileEnum filefinder(path); while (filefinder.NextFile(subpath, &isDir)) { if (progress.HasUserCancelled()) return path; if (!isDir) continue; if (g_SVNAdminDir.IsAdminDirPath(subpath)) continue; progress.SetLine(2, subpath, true); if (CountMatches(subpath) > (GetNumberOfFiles()/3)) return subpath; } // if a patch file only contains newly added files // we can't really find the correct path. // But: we can compare paths strings without the filenames // and check if at least those match upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountDirMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } return path; }
void CEditPropExternals::OnBnClickedFindhead() { CProgressDlg progDlg; progDlg.ShowModal(m_hWnd, TRUE); progDlg.SetTitle(IDS_EDITPROPS_PROG_FINDHEADTITLE); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_EDITPROPS_PROG_FINDHEADROOTS))); DWORD count = 0; DWORD total = (DWORD)m_externals.size()*4; SVN svn; svn.SetPromptParentWindow(m_hWnd); SVNInfo svnInfo; svnInfo.SetPromptParentWindow(m_hWnd); for (auto it = m_externals.begin(); it != m_externals.end(); ++it) { progDlg.SetProgress(count++, total); if (progDlg.HasUserCancelled()) break; if (it->root.IsEmpty()) { CTSVNPath p = it->path; p.AppendPathString(it->targetDir); it->root = svn.GetRepositoryRoot(p); } } progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_EDITPROPS_PROG_FINDHEADREVS))); SVNLogHelper logHelper; for (auto it = m_externals.begin(); it != m_externals.end(); ++it) { progDlg.SetProgress(count, total); progDlg.SetLine(2, it->url, true); if (progDlg.HasUserCancelled()) break; count += 4; if (!it->root.IsEmpty()) { auto youngestRev = logHelper.GetYoungestRev(CTSVNPath(it->fullurl)); if (!youngestRev.IsValid()) it->headrev = svn.GetHEADRevision(CTSVNPath(it->fullurl), true); else it->headrev = youngestRev; } } progDlg.Stop(); m_ExtList.Invalidate(); }
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; }
bool DropExportCommand::Execute() { bool bRet = true; #if 0 CString droppath = parser.GetVal(_T("droptarget")); if (CTGitPath(droppath).IsAdminDir()) return false; 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); if (CMessageBox::Show(hwndExplorer, msg, _T("TortoiseSVN"), MB_ICONQUESTION|MB_YESNO) == IDYES) { CProgressDlg progress; progress.SetTitle(IDS_PROC_UNVERSION); progress.SetAnimation(IDR_MOVEANI); progress.FormatNonPathLine(1, IDS_SVNPROGRESS_EXPORTINGWAIT); progress.SetTime(true); progress.ShowModeless(hwndExplorer); 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.SetProgress(count, removeVector.size()); count++; it->Delete(false); } progress.Stop(); } else return false; } else { for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { CString dropper = droppath + _T("\\") + pathList[nPath].GetFileOrDirectoryName(); if (PathFileExists(dropper)) { CString sMsg; CString sBtn1(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_OVERWRITE)); CString sBtn2(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_RENAME)); CString sBtn3(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_CANCEL)); sMsg.Format(IDS_PROC_OVERWRITEEXPORT, (LPCTSTR)dropper); UINT ret = CMessageBox::Show(hwndExplorer, sMsg, _T("TortoiseSVN"), MB_DEFBUTTON1, IDI_QUESTION, sBtn1, sBtn2, sBtn3); if (ret==2) { dropper.Format(IDS_PROC_EXPORTFOLDERNAME, (LPCTSTR)droppath, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName()); int exportcount = 1; while (PathFileExists(dropper)) { dropper.Format(IDS_PROC_EXPORTFOLDERNAME2, (LPCTSTR)droppath, exportcount++, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName()); } } else if (ret == 3) return false; } if (!svn.Export(pathList[nPath], CTSVNPath(dropper), SVNRev::REV_WC ,SVNRev::REV_WC, FALSE, FALSE, svn_depth_infinity, hwndExplorer, parser.HasKey(_T("extended")))) { CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_OK | MB_ICONERROR); bRet = false; } } } #endif return bRet; }
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 PasteMoveCommand::Execute() { CString sDroppath = parser.GetVal(L"droptarget"); CTSVNPath dropPath(sDroppath); ProjectProperties props; props.ReadProps(dropPath); if (dropPath.IsAdminDir()) return FALSE; SVN svn; SVNStatus status; unsigned long count = 0; pathList.RemoveAdminPaths(); CString sNewName; CProgressDlg progress; progress.SetTitle(IDS_PROC_MOVING); progress.SetTime(true); progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND())); for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { CTSVNPath destPath; if (sNewName.IsEmpty()) destPath = CTSVNPath(sDroppath+L"\\"+pathList[nPath].GetFileOrDirectoryName()); else destPath = CTSVNPath(sDroppath+L"\\"+sNewName); if (destPath.Exists()) { CString name = pathList[nPath].GetFileOrDirectoryName(); if (!sNewName.IsEmpty()) name = sNewName; progress.Stop(); CRenameDlg dlg; dlg.SetFileSystemAutoComplete(); dlg.m_name = name; dlg.SetInputValidator(this); m_renPath = pathList[nPath]; dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name); if (dlg.DoModal() != IDOK) { return FALSE; } destPath.SetFromWin(sDroppath+L"\\"+dlg.m_name); } svn_wc_status_kind s = status.GetAllStatus(pathList[nPath]); if ((s == svn_wc_status_none)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_ignored)) { // source file is unversioned: move the file to the target, then add it MoveFile(pathList[nPath].GetWinPath(), destPath.GetWinPath()); if (!svn.Add(CTSVNPathList(destPath), &props, svn_depth_infinity, true, true, false, true)) { svn.ShowErrorDialog(GetExplorerHWND()); return FALSE; //get out of here } CShellUpdater::Instance().AddPathForUpdate(destPath); } else { if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath)) { svn.ShowErrorDialog(GetExplorerHWND()); 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())) { TaskDialog(GetExplorerHWND(), AfxGetResourceHandle(), MAKEINTRESOURCE(IDS_APPNAME), MAKEINTRESOURCE(IDS_SVN_USERCANCELLED), NULL, TDCBF_OK_BUTTON, TD_INFORMATION_ICON, NULL); return FALSE; } } return true; }
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; }
bool PasteCopyCommand::Execute() { CString sDroppath = parser.GetVal(_T("droptarget")); CTSVNPath dropPath(sDroppath); ProjectProperties props; props.ReadProps(dropPath); if (dropPath.IsAdminDir()) return FALSE; SVN svn; SVNStatus status; unsigned long count = 0; CString sNewName; pathList.RemoveAdminPaths(); CProgressDlg progress; progress.SetTitle(IDS_PROC_COPYING); progress.SetAnimation(IDR_MOVEANI); progress.SetTime(true); progress.ShowModeless(CWnd::FromHandle(hwndExplorer)); for(int nPath = 0; nPath < pathList.GetCount(); nPath++) { const CTSVNPath& sourcePath = pathList[nPath]; CTSVNPath fullDropPath = dropPath; 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.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.SetAnimation(IDR_MOVEANI); progress.SetTime(true); progress.SetProgress(count, pathList.GetCount()); progress.ShowModeless(CWnd::FromHandle(hwndExplorer)); // Rebuild the destination path, with the new name fullDropPath.SetFromUnknown(sDroppath); fullDropPath.AppendPathString(dlg.m_name); } svn_wc_status_kind s = status.GetAllStatus(sourcePath); if ((s == svn_wc_status_none)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_ignored)) { // source file is unversioned: move the file to the target, then add it CopyFile(sourcePath.GetWinPath(), fullDropPath.GetWinPath(), FALSE); if (!svn.Add(CTSVNPathList(fullDropPath), &props, svn_depth_infinity, true, false, true)) { TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage()); CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); return FALSE; //get out of here } else CShellUpdater::Instance().AddPathForUpdate(fullDropPath); } else { if (!svn.Copy(CTSVNPathList(sourcePath), fullDropPath, SVNRev::REV_WC, SVNRev())) { TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage()); CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); return FALSE; //get out of here } 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())) { CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION); return false; } } return true; }
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; }
virtual BOOL Cancel() { return progress && progress->HasUserCancelled() ? TRUE : FALSE; }