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 DiffCommand::Execute() { bool bRet = false; CString path2 = CPathUtils::GetLongPathname(parser.GetVal(L"path2")); bool bAlternativeTool = !!parser.HasKey(L"alternative"); bool bBlame = !!parser.HasKey(L"blame"); bool ignoreprops = !!parser.HasKey(L"ignoreprops"); if (path2.IsEmpty()) { SVNDiff diff(NULL, GetExplorerHWND()); diff.SetAlternativeTool(bAlternativeTool); diff.SetJumpLine(parser.GetLongVal(L"line")); if ( parser.HasKey(L"startrev") && parser.HasKey(L"endrev") ) { SVNRev StartRevision = SVNRev(parser.GetVal(L"startrev")); SVNRev EndRevision = SVNRev(parser.GetVal(L"endrev")); SVNRev pegRevision; if (parser.HasVal(L"pegrevision")) pegRevision = SVNRev(parser.GetVal(L"pegrevision")); CString diffoptions; if (parser.HasVal(L"diffoptions")) diffoptions = parser.GetVal(L"diffoptions"); bRet = diff.ShowCompare(cmdLinePath, StartRevision, cmdLinePath, EndRevision, pegRevision, ignoreprops, diffoptions, false, bBlame); } else { svn_revnum_t baseRev = 0; if (parser.HasKey(L"unified")) { SVNRev pegRevision; if (parser.HasVal(L"pegrevision")) pegRevision = SVNRev(parser.GetVal(L"pegrevision")); CString diffoptions; if (parser.HasVal(L"diffoptions")) diffoptions = parser.GetVal(L"diffoptions"); diff.ShowUnifiedDiff(cmdLinePath, SVNRev::REV_BASE, cmdLinePath, SVNRev::REV_WC, pegRevision, diffoptions, false, bBlame, false); } else { if (cmdLinePath.IsDirectory()) { if (!ignoreprops) bRet = diff.DiffProps(cmdLinePath, SVNRev::REV_WC, SVNRev::REV_BASE, baseRev); if (bRet == false) { CChangedDlg dlg; dlg.m_pathList = CTSVNPathList(cmdLinePath); dlg.DoModal(); bRet = true; } } else { bRet = diff.DiffFileAgainstBase(cmdLinePath, baseRev, ignoreprops); } } } } else bRet = CAppUtils::StartExtDiff( CTSVNPath(path2), cmdLinePath, CString(), CString(), CAppUtils::DiffFlags().AlternativeTool(bAlternativeTool), parser.GetLongVal(L"line"), L""); return bRet; }
BOOL CCopyDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); ExtendFrameIntoClientArea(IDC_EXTGROUP); m_aeroControls.SubclassControl(this, IDC_DOSWITCH); m_aeroControls.SubclassControl(this, IDC_MAKEPARENTS); m_aeroControls.SubclassOkCancelHelp(this); m_bCancelled = false; DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_CHECKBOXES; m_ExtList.SetExtendedStyle(exStyle); SetWindowTheme(m_ExtList.GetSafeHwnd(), L"Explorer", NULL); m_ExtList.ShowText(CString(MAKEINTRESOURCE(IDS_COPY_WAITFOREXTERNALS))); AdjustControlSize(IDC_COPYHEAD); AdjustControlSize(IDC_COPYREV); AdjustControlSize(IDC_COPYWC); AdjustControlSize(IDC_DOSWITCH); AdjustControlSize(IDC_MAKEPARENTS); CTSVNPath path(m_path); CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, path.GetUIPathString(), sWindowTitle); m_History.SetMaxHistoryItems((LONG)CRegDWORD(L"Software\\TortoiseSVN\\MaxHistoryItems", 25)); SetRevision(m_CopyRev); m_tooltips.AddTool(IDC_HISTORY, IDS_COMMITDLG_HISTORY_TT); if (SVN::PathIsURL(path)) { DialogEnableWindow(IDC_COPYWC, FALSE); DialogEnableWindow(IDC_DOSWITCH, FALSE); SetDlgItemText(IDC_COPYSTARTLABEL, CString(MAKEINTRESOURCE(IDS_COPYDLG_FROMURL))); } SVN svn; CString sUUID; m_repoRoot = svn.GetRepositoryRootAndUUID(path, true, sUUID); m_repoRoot.TrimRight('/'); m_wcURL = svn.GetURLFromPath(path); if (m_wcURL.IsEmpty() || (!path.IsUrl() && !path.Exists())) { CString Wrong_URL=path.GetSVNPathString(); CString temp; temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)Wrong_URL); ::MessageBox(this->m_hWnd, temp, L"TortoiseSVN", MB_ICONERROR); this->EndDialog(IDCANCEL); //exit } m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoPaths\\"+sUUID, L"url"); m_URLCombo.SetCurSel(0); CString relPath = m_wcURL.Mid(m_repoRoot.GetLength()); if (!m_URL.IsEmpty()) { // allow the use of urls relative to the repo root if (m_URL[0] != '^') relPath = m_URL.Mid(m_repoRoot.GetLength()); else relPath = m_URL.Mid(1); } CTSVNPath r = CTSVNPath(relPath); relPath = r.GetUIPathString(); relPath.Replace('\\', '/'); m_URLCombo.AddString(relPath, 0); m_URLCombo.SelectString(-1, relPath); m_URL = m_wcURL; SetDlgItemText(IDC_DESTURL, CPathUtils::CombineUrls(m_repoRoot, relPath)); SetDlgItemText(IDC_FROMURL, m_wcURL); CString reg; reg.Format(L"Software\\TortoiseSVN\\History\\commit%s", (LPCTSTR)sUUID); m_History.Load(reg, L"logmsgs"); m_ProjectProperties.ReadProps(m_path); if (CRegDWORD(L"Software\\TortoiseSVN\\AlwaysWarnIfNoIssue", FALSE)) m_ProjectProperties.bWarnIfNoIssue = TRUE; m_cLogMessage.Init(m_ProjectProperties); m_cLogMessage.SetFont((CString)CRegString(L"Software\\TortoiseSVN\\LogFontName", L"Courier New"), (DWORD)CRegDWORD(L"Software\\TortoiseSVN\\LogFontSize", 8)); GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(FALSE); CBugTraqAssociations bugtraq_associations; bugtraq_associations.Load(m_ProjectProperties.GetProviderUUID(), m_ProjectProperties.sProviderParams); if (bugtraq_associations.FindProvider(CTSVNPathList(m_path), &m_bugtraq_association)) { CComPtr<IBugTraqProvider> pProvider; HRESULT hr = pProvider.CoCreateInstance(m_bugtraq_association.GetProviderClass()); if (SUCCEEDED(hr)) { m_BugTraqProvider = pProvider; ATL::CComBSTR temp; ATL::CComBSTR parameters; parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString()); hr = pProvider->GetLinkText(GetSafeHwnd(), parameters, &temp); if (SUCCEEDED(hr)) { SetDlgItemText(IDC_BUGTRAQBUTTON, temp == 0 ? L"" : temp); GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(TRUE); GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_SHOW); } } GetDlgItem(IDC_LOGMESSAGE)->SetFocus(); } if (m_ProjectProperties.sMessage.IsEmpty()) { GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE); GetDlgItem(IDC_LOGMESSAGE)->SetFocus(); } else { GetDlgItem(IDC_BUGID)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_SHOW); if (!m_ProjectProperties.sLabel.IsEmpty()) SetDlgItemText(IDC_BUGIDLABEL, m_ProjectProperties.sLabel); GetDlgItem(IDC_BUGID)->SetFocus(); } if (!m_sLogMessage.IsEmpty()) m_cLogMessage.SetText(m_sLogMessage); else m_cLogMessage.SetText(m_ProjectProperties.GetLogMsgTemplate(PROJECTPROPNAME_LOGTEMPLATEBRANCH)); OnEnChangeLogmessage(); m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKALL); m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKNONE); // line up all controls and adjust their sizes. #define LINKSPACING 9 RECT rc = AdjustControlSize(IDC_SELECTLABEL); rc.right -= 15; // AdjustControlSize() adds 20 pixels for the checkbox/radio button bitmap, but this is a label... rc = AdjustStaticSize(IDC_CHECKALL, rc, LINKSPACING); rc = AdjustStaticSize(IDC_CHECKNONE, rc, LINKSPACING); CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_TEXT); CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_HELP, CString(MAKEINTRESOURCE(IDS_INPUT_ENTERLOG))); CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_INVISIBLE))); CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKALL)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK); CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKNONE)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK); CAppUtils::SetAccProperty(m_URLCombo.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_TOURLLABEL))); CAppUtils::SetAccProperty(GetDlgItem(IDC_FROMURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_COPYSTARTLABEL))); CAppUtils::SetAccProperty(GetDlgItem(IDC_DESTURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_DESTLABEL))); AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_COPYSTARTLABEL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_FROMURL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_TOURLLABEL, TOP_LEFT); AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_BROWSE, TOP_RIGHT); AddAnchor(IDC_DESTLABEL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_DESTURL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_MSGGROUP, TOP_LEFT, MIDDLE_RIGHT); AddAnchor(IDC_HISTORY, TOP_LEFT); AddAnchor(IDC_BUGTRAQBUTTON, TOP_LEFT); AddAnchor(IDC_BUGIDLABEL, TOP_RIGHT); AddAnchor(IDC_BUGID, TOP_RIGHT); AddAnchor(IDC_INVISIBLE, TOP_RIGHT); AddAnchor(IDC_LOGMESSAGE, TOP_LEFT, MIDDLE_RIGHT); AddAnchor(IDC_FROMGROUP, MIDDLE_LEFT, MIDDLE_RIGHT); AddAnchor(IDC_COPYHEAD, MIDDLE_LEFT); AddAnchor(IDC_COPYREV, MIDDLE_LEFT); AddAnchor(IDC_COPYREVTEXT, MIDDLE_RIGHT); AddAnchor(IDC_BROWSEFROM, MIDDLE_RIGHT); AddAnchor(IDC_COPYWC, MIDDLE_LEFT); AddAnchor(IDC_EXTGROUP, MIDDLE_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_SELECTLABEL, MIDDLE_LEFT); AddAnchor(IDC_CHECKALL, MIDDLE_LEFT); AddAnchor(IDC_CHECKNONE, MIDDLE_LEFT); AddAnchor(IDC_EXTERNALSLIST, MIDDLE_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_DOSWITCH, BOTTOM_LEFT); AddAnchor(IDC_MAKEPARENTS, BOTTOM_LEFT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); if ((m_pParentWnd==NULL)&&(GetExplorerHWND())) CenterWindow(CWnd::FromHandle(GetExplorerHWND())); EnableSaveRestore(L"CopyDlg"); m_bSettingChanged = false; if (!m_path.IsUrl()) { // start a thread to obtain the highest revision number of the working copy // without blocking the dialog if ((m_pThread = AfxBeginThread(FindRevThreadEntry, this))==NULL) { OnCantStartThread(); } } return TRUE; }
BOOL CLockDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); ExtendFrameIntoClientArea(IDC_FILELIST); m_aeroControls.SubclassControl(this, IDC_SELECTALL); m_aeroControls.SubclassControl(this, IDC_STEALLOCKS); m_aeroControls.SubclassOkCancelHelp(this); m_History.SetMaxHistoryItems((LONG)CRegDWORD(_T("Software\\TortoiseSVN\\MaxHistoryItems"), 25)); m_History.Load(_T("Software\\TortoiseSVN\\History\\commit"), _T("logmsgs")); m_cFileList.Init(SVNSLC_COLEXT | SVNSLC_COLLOCK, _T("LockDlg")); m_cFileList.SetSelectButton(&m_SelectAll); m_cFileList.SetConfirmButton((CButton*)GetDlgItem(IDOK)); m_cFileList.SetCancelBool(&m_bCancelled); m_cFileList.EnableFileDrop(); m_cFileList.SetBackgroundImage(IDI_LOCK_BKG); if (m_ProjectProperties) m_cEdit.Init(*m_ProjectProperties); else m_cEdit.Init(); m_cEdit.SetFont((CString)CRegString(_T("Software\\TortoiseSVN\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseSVN\\LogFontSize"), 8)); if (!m_sLockMessage.IsEmpty()) m_cEdit.SetText(m_sLockMessage); else if (m_ProjectProperties) m_cEdit.SetText(m_ProjectProperties->GetLogMsgTemplate(PROJECTPROPNAME_LOGTEMPLATELOCK)); CAppUtils::SetAccProperty(m_cEdit.GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_TEXT); CAppUtils::SetAccProperty(m_cEdit.GetSafeHwnd(), PROPID_ACC_HELP, CString(MAKEINTRESOURCE(IDS_INPUT_ENTERLOG))); m_tooltips.Create(this); m_SelectAll.SetCheck(BST_INDETERMINATE); CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, m_pathList.GetCommonRoot().GetUIPathString(), sWindowTitle); OnEnChangeLockmessage(); AdjustControlSize(IDC_STEALLOCKS); AdjustControlSize(IDC_SELECTALL); AddAnchor(IDC_HISTORY, TOP_LEFT); AddAnchor(IDC_LOCKTITLELABEL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_LOCKMESSAGE, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_STEALLOCKS, BOTTOM_LEFT); AddAnchor(IDC_SELECTALL, BOTTOM_LEFT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); if (GetExplorerHWND()) CenterWindow(CWnd::FromHandle(GetExplorerHWND())); EnableSaveRestore(_T("LockDlg")); // start a thread to obtain the file list with the status without // blocking the dialog m_pThread = AfxBeginThread(StatusThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { OnCantStartThread(); } else { m_pThread->m_bAutoDelete = FALSE; m_pThread->ResumeThread(); } m_bBlock = TRUE; GetDlgItem(IDC_LOCKMESSAGE)->SetFocus(); return FALSE; }
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; }
bool ConflictEditorCommand::Execute() { CTSVNPath merge = cmdLinePath; CTSVNPath directory = merge.GetDirectory(); bool bRet = false; bool bAlternativeTool = !!parser.HasKey(L"alternative"); // Use Subversion 1.10 API to resolve possible tree conlifcts. SVNConflictInfo conflict; if (!conflict.Get(merge)) { conflict.ShowErrorDialog(GetExplorerHWND()); return false; } // Resolve tree conflicts first. if (conflict.HasTreeConflict()) { CProgressDlg progressDlg; progressDlg.SetTitle(IDS_PROC_EDIT_TREE_CONFLICTS); CString sProgressLine; sProgressLine.LoadString(IDS_PROGRS_FETCHING_TREE_CONFLICT_INFO); progressDlg.SetLine(1, sProgressLine); progressDlg.SetShowProgressBar(false); progressDlg.ShowModal(GetExplorerHWND(), FALSE); conflict.SetProgressDlg(&progressDlg); if (!conflict.FetchTreeDetails()) { // Ignore errors while fetching additional tree conflict information. // Use still may want to resolve it manually. conflict.ClearSVNError(); } progressDlg.Stop(); conflict.SetProgressDlg(NULL); CNewTreeConflictEditorDlg dlg; dlg.SetConflictInfo(&conflict); dlg.DoModal(GetExplorerHWND()); if (dlg.IsCancelled()) return false; if (dlg.GetResult() == svn_client_conflict_option_postpone) return false; // Send notififcation that status may be changed. We cannot use // '/resolvemsghwnd' here because satus of multiple files may be changed // during tree conflict resolution. if (parser.HasVal(L"refreshmsghwnd")) { HWND refreshMsgWnd = (HWND)parser.GetLongLongVal(L"refreshmsghwnd"); UINT WM_REFRESH_STATUS_MSG = RegisterWindowMessage(L"TORTOISESVN_REFRESH_STATUS_MSG"); ::PostMessage(refreshMsgWnd, WM_REFRESH_STATUS_MSG, 0, 0); } } // we have the conflicted file (%merged) // now look for the other required files SVNInfo info; const SVNInfoData * pInfoData = info.GetFirstFileInfo(merge, SVNRev(), SVNRev()); if (pInfoData == NULL) return false; for (auto conflIt = pInfoData->conflicts.cbegin(); conflIt != pInfoData->conflicts.cend(); ++conflIt) { switch (conflIt->kind) { case svn_wc_conflict_kind_text: { // we have a text conflict, use our merge tool to resolve the conflict CTSVNPath theirs = CTSVNPath(conflIt->conflict_new); CTSVNPath mine = CTSVNPath(conflIt->conflict_wrk); CTSVNPath base = CTSVNPath(conflIt->conflict_old); if (mine.IsEmpty()) mine = merge; bRet = !!CAppUtils::StartExtMerge(CAppUtils::MergeFlags().AlternativeTool(bAlternativeTool), base, theirs, mine, merge, true, CString(), CString(), CString(), CString(), merge.GetFileOrDirectoryName()); } break; case svn_wc_conflict_kind_property: { // we have a property conflict CTSVNPath prej(conflIt->prejfile); CEditPropConflictDlg dlg; dlg.SetPrejFile(prej); dlg.SetConflictedItem(merge); dlg.SetPropertyName(conflIt->propname); dlg.SetPropValues(conflIt->propvalue_base, conflIt->propvalue_working, conflIt->propvalue_incoming_old, conflIt->propvalue_incoming_new); bRet = (dlg.DoModal() != IDCANCEL); } break; case svn_wc_conflict_kind_tree: { CTSVNPath treeConflictPath = CTSVNPath(conflIt->treeconflict_path); CTreeConflictEditorDlg dlg; dlg.SetPath(treeConflictPath); dlg.SetConflictLeftSources(conflIt->src_left_version_url, conflIt->src_left_version_path, conflIt->src_left_version_rev, conflIt->src_left_version_kind); dlg.SetConflictRightSources(conflIt->src_right_version_url, conflIt->src_right_version_path, conflIt->src_right_version_rev, conflIt->src_right_version_kind); dlg.SetConflictReason(conflIt->treeconflict_reason); dlg.SetConflictAction(conflIt->treeconflict_action); dlg.SetConflictOperation(conflIt->treeconflict_operation); dlg.SetKind(conflIt->treeconflict_nodekind); INT_PTR dlgRet = dlg.DoModal(); bRet = (dlgRet != IDCANCEL); } break; } } return bRet; }
bool CatCommand::Execute() { if (!GitAdminDir::IsWorkingTreeOrBareRepo(g_Git.m_CurrentDir)) { CMessageBox::Show(GetExplorerHWND(), IDS_NOGITREPO, IDS_APPNAME, MB_ICONERROR); return false; } CString savepath = CPathUtils::GetLongPathname(parser.GetVal(L"savepath")); CString revision = parser.GetVal(L"revision"); if (g_Git.UsingLibGit2(CGit::GIT_CMD_GETONEFILE)) { CAutoRepository repo(g_Git.GetGitRepository()); if (!repo) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), g_Git.GetLibGit2LastErr(L"Could not open repository."), L"TortoiseGit", MB_ICONERROR); return false; } CAutoObject obj; if (git_revparse_single(obj.GetPointer(), repo, CUnicodeUtils::GetUTF8(revision))) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), g_Git.GetLibGit2LastErr(L"Could not parse revision."), L"TortoiseGit", MB_ICONERROR); return false; } if (git_object_type(obj) == GIT_OBJECT_BLOB) { CAutoFILE file = _wfsopen(savepath, L"wb", SH_DENYRW); if (file == nullptr) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), L"Could not open file for writing.", L"TortoiseGit", MB_ICONERROR); return false; } CAutoBuf buf; if (git_blob_filtered_content(buf, reinterpret_cast<git_blob*>(static_cast<git_object*>(obj)), CUnicodeUtils::GetUTF8(cmdLinePath.GetGitPathString()), 0)) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), g_Git.GetLibGit2LastErr(L"Could not get filtered content."), L"TortoiseGit", MB_ICONERROR); return false; } if (fwrite(buf->ptr, sizeof(char), buf->size, file) != buf->size) { ::DeleteFile(savepath); CString err = CFormatMessageWrapper(); CMessageBox::Show(GetExplorerHWND(), L"Could not write to file: " + err, L"TortoiseGit", MB_ICONERROR); return false; } return true; } if (g_Git.GetOneFile(revision, cmdLinePath, savepath)) { MessageBox(GetExplorerHWND(), g_Git.GetGitLastErr(L"Could get file.", CGit::GIT_CMD_GETONEFILE), L"TortoiseGit", MB_ICONERROR); return false; } return true; } CString cmd, output, err; cmd.Format(L"git.exe cat-file -t %s", static_cast<LPCTSTR>(revision)); if (g_Git.Run(cmd, &output, &err, CP_UTF8)) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), output + L'\n' + err, L"TortoiseGit", MB_ICONERROR); return false; } if (CStringUtils::StartsWith(output, L"blob")) cmd.Format(L"git.exe cat-file -p %s", static_cast<LPCTSTR>(revision)); else cmd.Format(L"git.exe show %s -- \"%s\"", static_cast<LPCTSTR>(revision), static_cast<LPCTSTR>(this->cmdLinePath.GetWinPathString())); if (g_Git.RunLogFile(cmd, savepath, &err)) { ::DeleteFile(savepath); MessageBox(GetExplorerHWND(), L"Cat file failed:\n" + err, L"TortoiseGit", MB_ICONERROR); return false; } return true; }