Esempio n. 1
0
    void SubversionPathTest()
    {
        CTSVNPath testPath;
        testPath.SetFromWin(L"c:\\");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "C:/") == 0);
        testPath.SetFromWin(L"c:\\folder");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "C:/folder") == 0);
        testPath.SetFromWin(L"c:\\a\\b\\c\\d\\e");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "C:/a/b/c/d/e") == 0);
        testPath.SetFromUnknown(L"http://testing/");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "http://testing") == 0);
        testPath.SetFromSVN(NULL);
        ATLASSERT(strlen(testPath.GetSVNApiPath(pool))==0);
        testPath.SetFromWin(L"\\\\a\\b\\c\\d\\e");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "//a/b/c/d/e") == 0);
        testPath.SetFromWin(L"\\\\?\\C:\\Windows");
        ATLASSERT(wcscmp(testPath.GetWinPath(), L"C:\\Windows")==0);
        testPath.SetFromUnknown(L"\\\\?\\C:\\Windows");
        ATLASSERT(wcscmp(testPath.GetWinPath(), L"C:\\Windows")==0);
#if defined(_MFC_VER)
        testPath.SetFromUnknown(L"http://testing again");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "http://testing%20again") == 0);
        testPath.SetFromUnknown(L"http://testing%20again");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "http://testing%20again") == 0);
        testPath.SetFromUnknown(L"http://testing special chars \344\366\374");
        ATLASSERT(strcmp(testPath.GetSVNApiPath(pool), "http://testing%20special%20chars%20%c3%a4%c3%b6%c3%bc") == 0);
#endif
    }
Esempio n. 2
0
    void AdminDirTest()
    {
        CTSVNPath testPath;
        testPath.SetFromUnknown(L"c:\\.svndir");
        ATLASSERT(!testPath.IsAdminDir());
        testPath.SetFromUnknown(L"c:\\test.svn");
        ATLASSERT(!testPath.IsAdminDir());
        testPath.SetFromUnknown(L"c:\\.svn");
        ATLASSERT(testPath.IsAdminDir());
        testPath.SetFromUnknown(L"c:\\.svndir\\test");
        ATLASSERT(!testPath.IsAdminDir());
        testPath.SetFromUnknown(L"c:\\.svn\\test");
        ATLASSERT(testPath.IsAdminDir());

        CTSVNPathList pathList;
        pathList.AddPath(CTSVNPath(L"c:\\.svndir"));
        pathList.AddPath(CTSVNPath(L"c:\\.svn"));
        pathList.AddPath(CTSVNPath(L"c:\\.svn\\test"));
        pathList.AddPath(CTSVNPath(L"c:\\test"));
        pathList.RemoveAdminPaths();
        ATLASSERT(pathList.GetCount()==2);
        pathList.Clear();
        pathList.AddPath(CTSVNPath(L"c:\\test"));
        pathList.RemoveAdminPaths();
        ATLASSERT(pathList.GetCount()==1);
    }
Esempio n. 3
0
bool CTSVNPathList::LoadFromFile(const CTSVNPath& filename)
{
    Clear();
    try
    {
        CString strLine;
        CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);

        // for every selected file/folder
        CTSVNPath path;
        while (file.ReadString(strLine))
        {
            path.SetFromUnknown(strLine);
            AddPath(path);
        }
        file.Close();
    }
    catch (CFileException* pE)
    {
        std::unique_ptr<TCHAR[]> error(new TCHAR[10000]);
        pE->GetErrorMessage(error.get(), 10000);
        ::MessageBox(NULL, error.get(), L"TortoiseSVN", MB_ICONERROR);
        pE->Delete();
        return false;
    }
    return true;
}
Esempio n. 4
0
void CRevisionGraphWnd::GetSelected
    ( const CVisibleGraphNode* node
    , bool head
    , CTSVNPath& path
    , SVNRev& rev
    , SVNRev& peg)
{
    CString repoRoot = m_state.GetRepositoryRoot();

    // get path and revision

    path.SetFromSVN (repoRoot + CUnicodeUtils::GetUnicode (node->GetPath().GetPath().c_str()));
    rev = head ? SVNRev::REV_HEAD : node->GetRevision();

    // handle 'modified WC' node

    if (node->GetClassification().Is (CNodeClassification::IS_MODIFIED_WC))
    {
        path.SetFromUnknown (m_sPath);
        rev = SVNRev::REV_WC;

        // don't set peg, if we aren't the first node
        // (i.e. would not be valid for node1)

        if (node == m_SelectedEntry1)
            peg = SVNRev::REV_WC;
    }
    else
    {
        // set head, if still necessary

        if (head && !peg.IsValid())
            peg = node->GetRevision();
    }
}
Esempio n. 5
0
    void SortTest()
    {
        CTSVNPathList testList;
        CTSVNPath testPath;
        testPath.SetFromUnknown(L"c:/Z");
        testList.AddPath(testPath);
        testPath.SetFromUnknown(L"c:/B");
        testList.AddPath(testPath);
        testPath.SetFromUnknown(L"c:\\a");
        testList.AddPath(testPath);
        testPath.SetFromUnknown(L"c:/Test");
        testList.AddPath(testPath);

        testList.SortByPathname();

        ATLASSERT(testList[0].GetWinPathString() == L"c:\\a");
        ATLASSERT(testList[1].GetWinPathString() == L"c:\\B");
        ATLASSERT(testList[2].GetWinPathString() == L"c:\\Test");
        ATLASSERT(testList[3].GetWinPathString() == L"c:\\Z");
    }
Esempio n. 6
0
    void GetDirectoryTest()
    {
        // Bit tricky, this test, because we need to know something about the file
        // layout on the machine which is running the test
        TCHAR winDir[MAX_PATH + 1] = { 0 };
        GetWindowsDirectory(winDir, _countof(winDir));
        CString sWinDir(winDir);

        CTSVNPath testPath;
        // This is a file which we know will always be there
        testPath.SetFromUnknown(sWinDir + L"\\win.ini");
        ATLASSERT(!testPath.IsDirectory());
        ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
        ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() == sWinDir);

        // Now do the test on the win directory itself - It's hard to be sure about the containing directory
        // but we know it must be different to the directory itself
        testPath.SetFromUnknown(sWinDir);
        ATLASSERT(testPath.IsDirectory());
        ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
        ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() != sWinDir);
        ATLASSERT(testPath.GetContainingDirectory().GetWinPathString().GetLength() < sWinDir.GetLength());

        // Try a root path
        testPath.SetFromUnknown(L"C:\\");
        ATLASSERT(testPath.IsDirectory());
        ATLASSERT(testPath.GetDirectory().GetWinPathString().CompareNoCase(L"C:\\")==0);
        ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
        // Try a root UNC path
        testPath.SetFromUnknown(L"\\MYSTATION");
        ATLASSERT(testPath.GetContainingDirectory().IsEmpty());

        // test the UI path methods
        testPath.SetFromUnknown(L"c:\\testing%20test");
        ATLASSERT(testPath.GetUIFileOrDirectoryName().CompareNoCase(L"testing%20test") == 0);
#ifdef _MFC_VER
        testPath.SetFromUnknown(L"http://server.com/testing%20special%20chars%20%c3%a4%c3%b6%c3%bc");
        ATLASSERT(testPath.GetUIFileOrDirectoryName().CompareNoCase(L"testing special chars \344\366\374") == 0);
#endif
    }
Esempio n. 7
0
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;
}