Esempio n. 1
0
VOID GetAnswerToRequest(const TSVNCacheRequest* pRequest, TSVNCacheResponse* pReply, DWORD* pResponseLength)
{
    CTSVNPath path;
    *pResponseLength = 0;
    if(pRequest->flags & TSVNCACHE_FLAGS_FOLDERISKNOWN)
    {
        path.SetFromWin(pRequest->path, !!(pRequest->flags & TSVNCACHE_FLAGS_ISFOLDER));
    }
    else
    {
        path.SetFromWin(pRequest->path);
    }

    CAutoReadWeakLock readLock(CSVNStatusCache::Instance().GetGuard(), 2000);

    if (readLock.IsAcquired())
    {
        CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": app asked for status of %s\n", pRequest->path);
        CSVNStatusCache::Instance().GetStatusForPath(path, pRequest->flags, false).BuildCacheResponse(*pReply, *pResponseLength);
    }
    else
    {
        CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": timeout for asked status of %s\n", pRequest->path);
        CStatusCacheEntry entry;
        entry.BuildCacheResponse(*pReply, *pResponseLength);
    }
}
void CEditPropExternalsValue::OnBnClickedShowLog()
{
    UpdateData(TRUE);
    if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible()))
        return;
    CString urlString = m_URLCombo.GetString();
    CTSVNPath logUrl = m_URL;
    if (urlString.GetLength()>1)
    {
        logUrl = CTSVNPath(SVNExternals::GetFullExternalUrl(urlString, m_RepoRoot.GetSVNPathString(), m_URL.GetSVNPathString()));
    }
    else
    {
        logUrl = m_RepoRoot;
        logUrl.AppendPathString(urlString);
    }

    if (!logUrl.IsEmpty())
    {
        delete m_pLogDlg;
        m_pLogDlg = new CLogDlg();
        m_pLogDlg->SetSelect(true);
        m_pLogDlg->m_pNotifyWindow = this;
        m_pLogDlg->m_wParam = 0;
        m_pLogDlg->SetParams(CTSVNPath(logUrl), SVNRev::REV_HEAD, SVNRev::REV_HEAD, 1, TRUE);
        m_pLogDlg->ContinuousSelection(true);
        m_pLogDlg->Create(IDD_LOGMESSAGE, this);
        m_pLogDlg->ShowWindow(SW_SHOW);
    }
    AfxGetApp()->DoWaitCursor(-1);
}
Esempio n. 3
0
void CHooks::AddErrorParam(CString& sCmd, const CString& error)
{
    CTSVNPath tempPath;
    tempPath = CTempFiles::Instance().GetTempFilePath(true);
    CStringUtils::WriteStringToTextFile(tempPath.GetWinPath(), (LPCTSTR)error);
    AddParam(sCmd, tempPath.GetWinPathString());
}
Esempio n. 4
0
BOOL ShellCache::IsVersioned(LPCTSTR path, bool bIsDir, bool mustbeok)
{
    tstring folder (path);
    if (! bIsDir)
    {
        size_t pos = folder.rfind ('\\');
        if (pos != tstring::npos)
            folder.erase (pos);
    }
    std::map<tstring, BoolTimeout>::iterator iter;
    if ((iter = admindircache.find(folder)) != admindircache.end())
    {
        if ((GetTickCount64() - iter->second.timeout) < ADMINDIRTIMEOUT)
            return iter->second.bBool;
    }

    BoolTimeout bt;
    CTSVNPath p;
    p.SetFromWin(folder.c_str());
    bt.bBool = SVNHelper::IsVersioned(p, mustbeok);
    bt.timeout = GetTickCount64();
    Locker lock(m_critSec);
    admindircache[folder] = bt;
    return bt.bBool;
}
Esempio n. 5
0
bool CSVNStatusCache::BlockPath(const CTSVNPath& path, bool specific, ULONGLONG timeout /* = 0 */)
{
    if (timeout == 0)
        timeout = BLOCK_PATH_DEFAULT_TIMEOUT;

    if (timeout > BLOCK_PATH_MAX_TIMEOUT)
        timeout = BLOCK_PATH_MAX_TIMEOUT;

    timeout = GetTickCount64() + (timeout * 1000);    // timeout is in seconds, but we need the milliseconds

    if (!specific)
    {
        CTSVNPath p(path);
        do
        {
            CTSVNPath dbPath(p);
            dbPath.AppendPathString(g_SVNAdminDir.GetAdminDirName() + L"\\wc.db");
            if (!dbPath.Exists())
                p = p.GetContainingDirectory();
            else
            {
                CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": block path %s\n", p.GetWinPath());
                AutoLocker lock(m_NoWatchPathCritSec);
                m_NoWatchPaths[p] = timeout;
                return true;
            }
        } while (!p.IsEmpty());
    }

    CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": block path %s\n", path.GetWinPath());
    AutoLocker lock(m_NoWatchPathCritSec);
    m_NoWatchPaths[path.GetDirectory()] = timeout;

    return true;
}
Esempio n. 6
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. 7
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. 8
0
// Update our composite status and deal with things if it's changed
void CCachedDirectory::UpdateCurrentStatus()
{
    svn_wc_status_kind newStatus = CalculateRecursiveStatus();

    if ((newStatus != m_currentFullStatus)&&(m_ownStatus.IsVersioned()))
    {
        if ((m_currentFullStatus != svn_wc_status_none)&&(m_ownStatus.GetEffectiveStatus() != svn_wc_status_ignored))
        {
            // Our status has changed - tell the shell
            CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": Dir %s, status change from %d to %d\n"), m_directoryPath.GetWinPath(), m_currentFullStatus, newStatus);
            CSVNStatusCache::Instance().UpdateShell(m_directoryPath);
        }
        if (m_ownStatus.GetEffectiveStatus() != svn_wc_status_ignored)
            m_currentFullStatus = newStatus;
        else
            m_currentFullStatus = svn_wc_status_ignored;
    }
    // And tell our parent, if we've got one...
    // we tell our parent *always* about our status, even if it hasn't
    // changed. This is to make sure that the parent has really our current
    // status - the parent can decide itself if our status has changed
    // or not.
    CTSVNPath parentPath = m_directoryPath.GetContainingDirectory();
    if(!parentPath.IsEmpty())
    {
        CCachedDirectory * cachedDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(parentPath);
        if (cachedDir)
            cachedDir->UpdateChildDirectoryStatus(m_directoryPath, m_currentFullStatus);
    }
}
Esempio n. 9
0
void CHooks::AddCWDParam(CString& sCmd, const CTSVNPathList& pathList)
{
    CTSVNPath curDir = pathList.GetCommonRoot().GetDirectory();
    while (!curDir.IsEmpty() && !curDir.Exists())
        curDir = curDir.GetContainingDirectory();

    AddParam(sCmd, curDir.GetWinPathString());
}
Esempio n. 10
0
CTSVNPath CHooks::AddMessageFileParam(CString& sCmd, const CString& message)
{
    CTSVNPath tempPath;
    tempPath = CTempFiles::Instance().GetTempFilePath(true);
    CStringUtils::WriteStringToTextFile(tempPath.GetWinPath(), (LPCTSTR)message);
    AddParam(sCmd, tempPath.GetWinPathString());
    return tempPath;
}
void CTreeConflictEditorDlg::OnBnClickedShowlog()
{
    CString sFile;
    CTSVNPath logPath = m_path;
    if (SVNHelper::IsVersioned(logPath.GetContainingDirectory(), true))
    {
        sFile = logPath.GetFilename();
        logPath = logPath.GetContainingDirectory();
    }
    CAppUtils::RunTortoiseProc(GetShowLogCmd(logPath, sFile));
}
Esempio n. 12
0
CCachedDirectory::CCachedDirectory(const CTSVNPath& directoryPath)
    : m_wcDbFileTime(0)
    , m_bCurrentFullStatusValid(false)
    , m_currentFullStatus(svn_wc_status_none)
    , m_mostImportantFileStatus(svn_wc_status_none)
    , m_pCtx(NULL)
    , m_FetchingStatus(FALSE)
{
    ATLASSERT(directoryPath.IsDirectory() || !PathFileExists(directoryPath.GetWinPath()));

    m_directoryPath = directoryPath;
}
Esempio n. 13
0
LRESULT CLockDlg::OnFileDropped(WPARAM, LPARAM lParam)
{
    BringWindowToTop();
    SetForegroundWindow();
    SetActiveWindow();
    // if multiple files/folders are dropped
    // this handler is called for every single item
    // separately.
    // To avoid creating multiple refresh threads and
    // causing crashes, we only add the items to the
    // list control and start a timer.
    // When the timer expires, we start the refresh thread,
    // but only if it isn't already running - otherwise we
    // restart the timer.
    CTSVNPath path;
    path.SetFromWin((LPCTSTR)lParam);

    if (!m_cFileList.HasPath(path))
    {
        if (m_pathList.AreAllPathsFiles())
        {
            m_pathList.AddPath(path);
            m_pathList.RemoveDuplicates();
        }
        else
        {
            // if the path list contains folders, we have to check whether
            // our just (maybe) added path is a child of one of those. If it is
            // a child of a folder already in the list, we must not add it. Otherwise
            // that path could show up twice in the list.
            bool bHasParentInList = false;
            for (int i=0; i<m_pathList.GetCount(); ++i)
            {
                if (m_pathList[i].IsAncestorOf(path))
                {
                    bHasParentInList = true;
                    break;
                }
            }
            if (!bHasParentInList)
            {
                m_pathList.AddPath(path);
                m_pathList.RemoveDuplicates();
            }
        }
    }

    // Always start the timer, since the status of an existing item might have changed
    SetTimer(REFRESHTIMER, 200, NULL);
    CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": Item %s dropped, timer started\n", path.GetWinPath());
    return 0;
}
Esempio n. 14
0
CString PasteMoveCommand::Validate( const int /*nID*/, const CString& input )
{
    CString sError;

    CTSVNPath p = m_renPath.GetContainingDirectory();
    p.AppendPathString(input);
    if (input.IsEmpty())
        sError.LoadString(IDS_ERR_NOVALIDPATH);
    else if (PathFileExists(p.GetWinPath()))
        sError.LoadString(IDS_ERR_FILEEXISTS);

    return sError;
}
Esempio n. 15
0
bool CLogFile::Open(const CTSVNPath& logfile)
{
    if (m_maxlines == 0)
        return false;   // do nothing if no log lines should be used.
    m_newLines.clear();
    m_logfile = logfile;
    if (!logfile.Exists())
    {
        CPathUtils::MakeSureDirectoryPathExists(logfile.GetContainingDirectory().GetWinPath());
    }

    return true;
}
Esempio n. 16
0
bool CSVNStatusCache::RemoveCacheForDirectory(CCachedDirectory * cdir)
{
    if (cdir == NULL)
        return false;
    CAutoWriteLock writeLock(m_guard);
    if (!cdir->m_childDirectories.empty())
    {
        auto it = cdir->m_childDirectories.begin();
        for (; it != cdir->m_childDirectories.end(); )
        {
            CTSVNPath path;
            CString winPath = CUnicodeUtils::GetUnicode (it->first);
            path.SetFromWin (winPath, true);

            CCachedDirectory * childdir = CSVNStatusCache::Instance().GetDirectoryCacheEntryNoCreate(path);
            if ((childdir)&&(!cdir->m_directoryPath.IsEquivalentTo(childdir->m_directoryPath))&&(cdir->m_directoryPath.GetFileOrDirectoryName()!=L".."))
                RemoveCacheForDirectory(childdir);
            cdir->m_childDirectories.erase(it->first);
            it = cdir->m_childDirectories.begin();
        }
    }
    cdir->m_childDirectories.clear();
    m_directoryCache.erase(cdir->m_directoryPath);

    // we could have entries versioned and/or stored in our cache which are
    // children of the specified directory, but not in the m_childDirectories
    // member: this can happen for nested layouts or if we fetched the status
    // while e.g., an update/checkout was in progress
    CCachedDirectory::ItDir itMap = m_directoryCache.lower_bound(cdir->m_directoryPath);
    do
    {
        if (itMap != m_directoryCache.end())
        {
            if (cdir->m_directoryPath.IsAncestorOf(itMap->first))
            {
                // just in case (see issue #255)
                if (itMap->second == cdir)
                {
                    m_directoryCache.erase(itMap);
                }
                else
                    RemoveCacheForDirectory(itMap->second);
            }
        }
        itMap = m_directoryCache.lower_bound(cdir->m_directoryPath);
    } while (itMap != m_directoryCache.end() && cdir->m_directoryPath.IsAncestorOf(itMap->first));

    CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": removed from cache %s\n", cdir->m_directoryPath.GetWinPath());
    delete cdir;
    return true;
}
Esempio n. 17
0
int CSysImageList::GetPathIconIndex(const CTSVNPath& filePath)
{
    CString strExtension = filePath.GetFileExtension();
    strExtension.MakeUpper();
    auto it = m_indexCache.lower_bound(strExtension);
    if (it == m_indexCache.end() || strExtension < it->first)
    {
        // We don't have this extension in the map
        int iconIndex = GetFileIconIndex(filePath.GetFilename());
        it = m_indexCache.emplace_hint(it, strExtension, iconIndex);
    }
    // We must have found it
    return it->second;
}
Esempio n. 18
0
int SVNBase::ShowErrorDialog( HWND hParent, const CTSVNPath& wcPath, const CString& sErr)
{
    UNREFERENCED_PARAMETER(wcPath);
    int ret = -1;

    CString sError = Err ? GetErrorString(Err) : PostCommitErr;
    if (!sErr.IsEmpty())
        sError = sErr;

    CString sCleanup = CString(MAKEINTRESOURCE(IDS_RUNCLEANUPNOW));
    CString sClose = CString(MAKEINTRESOURCE(IDS_CLOSE));
    CString sInstruction = CString(MAKEINTRESOURCE(IDS_SVNREPORTEDANERROR));

    TASKDIALOGCONFIG tconfig = { 0 };
    tconfig.cbSize = sizeof(TASKDIALOGCONFIG);
    tconfig.hwndParent = hParent;
    tconfig.dwFlags = TDF_ENABLE_HYPERLINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT;
    tconfig.dwCommonButtons = TDCBF_CLOSE_BUTTON;
    tconfig.pszWindowTitle = L"TortoiseSVN";
    tconfig.pszMainIcon = TD_ERROR_ICON;
    tconfig.pszMainInstruction = sInstruction;
    tconfig.pszContent = (LPCTSTR)sError;
#ifdef HAVE_APPUTILS
    TASKDIALOG_BUTTON aCustomButtons[2];
    aCustomButtons[0].nButtonID = 1000;
    aCustomButtons[0].pszButtonText = sCleanup;
    aCustomButtons[1].nButtonID = IDOK;
    aCustomButtons[1].pszButtonText = sClose;
    if (Err && (Err->apr_err == SVN_ERR_WC_CLEANUP_REQUIRED) && (!wcPath.IsEmpty()))
    {
        tconfig.dwCommonButtons = 0;
        tconfig.dwFlags |= TDF_USE_COMMAND_LINKS;
        tconfig.pButtons = aCustomButtons;
        tconfig.cButtons = _countof(aCustomButtons);
    }
#endif
    TaskDialogIndirect(&tconfig, &ret, NULL, NULL);
#ifdef HAVE_APPUTILS
    if (ret == 1000)
    {
        // run cleanup
        CString sCmd;
        sCmd.Format(L"/command:cleanup /path:\"%s\" /cleanup /nodlg /hwnd:%p",
                    wcPath.GetDirectory().GetWinPath(), (void*)hParent);
        CAppUtils::RunTortoiseProc(sCmd);
    }
#endif
    return ret;
}
Esempio n. 19
0
bool CTSVNPath::IsAncestorOf(const CTSVNPath& possibleDescendant) const
{
    possibleDescendant.EnsureBackslashPathSet();
    EnsureBackslashPathSet();

    bool bPathStringsEqual = ArePathStringsEqual(m_sBackslashPath, possibleDescendant.m_sBackslashPath.Left(m_sBackslashPath.GetLength()));
    if (m_sBackslashPath.GetLength() >= possibleDescendant.GetWinPathString().GetLength())
    {
        return bPathStringsEqual;
    }

    return (bPathStringsEqual &&
            ((possibleDescendant.m_sBackslashPath[m_sBackslashPath.GetLength()] == '\\')||
            (m_sBackslashPath.GetLength()==3 && m_sBackslashPath[1]==':')));
}
void CTreeConflictEditorDlg::OnBnClickedBranchlog()
{
    CString sTemp;
    sTemp.Format(L"%s/%s", (LPCTSTR)src_left_version_url, (LPCTSTR)src_left_version_path);

    CString sFile;
    CTSVNPath logPath = CTSVNPath(sTemp);
    if (src_left_version_kind != svn_node_dir)
    {
        sFile = logPath.GetFilename();
        logPath = logPath.GetContainingDirectory();
    }

    CAppUtils::RunTortoiseProc(GetShowLogCmd(logPath, sFile));
}
Esempio n. 21
0
CStatusCacheEntry CSVNStatusCache::GetStatusForPath(const CTSVNPath& path, DWORD flags,  bool bFetch /* = true */)
{
	bool bRecursive = !!(flags & TSVNCACHE_FLAGS_RECUSIVE_STATUS);

	// Check a very short-lived 'mini-cache' of the last thing we were asked for.
	long now = (long)GetTickCount();
	if(now-m_mostRecentExpiresAt < 0)
	{
		if(path.IsEquivalentToWithoutCase(m_mostRecentAskedPath))
		{
			return m_mostRecentStatus;
		}
	}
	{
		AutoLocker lock(m_critSec);
		m_mostRecentAskedPath = path;
		m_mostRecentExpiresAt = now+1000;
	}

	if (IsPathGood(path) && m_shellCache.IsPathAllowed(path.GetWinPath()))
	{
		// Stop the crawler starting on a new folder while we're doing this much more important task...
		// Please note, that this may be a second "lock" used concurrently to the one in RemoveCacheForPath().
		CCrawlInhibitor crawlInhibit(&m_folderCrawler);

		CTSVNPath dirpath = path.GetContainingDirectory();
		if (dirpath.IsEmpty())
			dirpath = path.GetDirectory();
		CCachedDirectory * cachedDir = GetDirectoryCacheEntry(dirpath);
		if (cachedDir != NULL)
		{
			CStatusCacheEntry entry = cachedDir->GetStatusForMember(path, bRecursive, bFetch);
			{
				AutoLocker lock(m_critSec);
				m_mostRecentStatus = entry;
				return m_mostRecentStatus;
			}
		}
		cachedDir = GetDirectoryCacheEntry(path.GetDirectory());
		if (cachedDir != NULL)
		{
			CStatusCacheEntry entry = cachedDir->GetStatusForMember(path, bRecursive, bFetch);
			{
				AutoLocker lock(m_critSec);
				m_mostRecentStatus = entry;
				return m_mostRecentStatus;
			}
		}

	}
	AutoLocker lock(m_critSec);
	m_mostRecentStatus = CStatusCacheEntry();
	if (m_shellCache.ShowExcludedAsNormal() && path.IsDirectory() && m_shellCache.HasSVNAdminDir(path.GetWinPath(), true))
	{
		m_mostRecentStatus.ForceStatus(svn_wc_status_normal);
	}
	return m_mostRecentStatus;
}
Esempio n. 22
0
bool CRemoteCacheLink::ReleaseLockForPath(const CTSVNPath& path)
{
    EnsureCommandPipeOpen();
    if (m_hCommandPipe)
    {
        DWORD cbWritten;
        TSVNCacheCommand cmd;
        SecureZeroMemory(&cmd, sizeof(TSVNCacheCommand));
        cmd.command = TSVNCACHECOMMAND_RELEASE;
        wcsncpy_s(cmd.path, path.GetDirectory().GetWinPath(), MAX_PATH);
        BOOL fSuccess = WriteFile(
            m_hCommandPipe, // handle to pipe
            &cmd,           // buffer to write from
            sizeof(cmd),    // number of bytes to write
            &cbWritten,     // number of bytes written
            NULL);          // not overlapped I/O
        if (! fSuccess || sizeof(cmd) != cbWritten)
        {
            CloseCommandPipe();
            return false;
        }
        return true;
    }
    return false;
}
void CNewTreeConflictEditorDlg::DoModal(HWND parent)
{
    CTSVNPath path = m_conflictInfo->GetPath();
    CString sDialogTitle;
    sDialogTitle.LoadString(IDS_PROC_EDIT_TREE_CONFLICTS);
    sDialogTitle = CCommonAppUtils::FormatWindowTitle(path.GetUIPathString(), sDialogTitle);

    if (!m_conflictInfo->GetTreeResolutionOptions(m_options))
    {
        m_conflictInfo->ShowErrorDialog(parent);
    }

    CString sMainInstruction = m_conflictInfo->GetIncomingChangeSummary();
    CString sContent = m_conflictInfo->GetLocalChangeSummary();

    int button;

    for (SVNConflictOptions::const_iterator it = m_options.begin(); it != m_options.end(); ++it)
    {
        svn_client_conflict_option_id_t id = (*it)->GetId();

        CString optLabel = (*it)->GetLabel();

        CString optDescription((*it)->GetDescription());
        optDescription.SetAt(0, towupper(optDescription[0]));

        AddCommandButton(100 + id, optLabel + L"\n" + optDescription);
    }

    TASKDIALOGCONFIG taskConfig = {0};
    taskConfig.cbSize = sizeof(taskConfig);
    taskConfig.hwndParent = parent;
    taskConfig.dwFlags = TDF_USE_COMMAND_LINKS;
    taskConfig.lpCallbackData = (LONG_PTR) this;
    taskConfig.pfCallback = TaskDialogCallback;
    taskConfig.pszWindowTitle = sDialogTitle;
    taskConfig.pszMainInstruction = sMainInstruction;
    taskConfig.pszContent = sContent;
    taskConfig.pButtons = &m_buttons.front();
    taskConfig.cButtons = (int) m_buttons.size();
    taskConfig.dwCommonButtons = TDCBF_CANCEL_BUTTON;
    TaskDialogIndirect(&taskConfig, &button, NULL, NULL);
    if (button == IDCANCEL)
    {
        m_bCancelled = true;
    }
}
Esempio n. 24
0
// Test if both paths refer to the same item
// Ignores case and slash direction
bool CTSVNPath::IsEquivalentToWithoutCase(const CTSVNPath& rhs) const
{
    // Try and find a slash direction which avoids having to convert
    // both filenames
    if(!m_sBackslashPath.IsEmpty())
    {
        // *We've* got a \ path - make sure that the RHS also has a \ path
        rhs.EnsureBackslashPathSet();
        return ArePathStringsEqual(m_sBackslashPath, rhs.m_sBackslashPath);
    }
    else
    {
        // Assume we've got a fwdslash path and make sure that the RHS has one
        rhs.EnsureFwdslashPathSet();
        return ArePathStringsEqual(m_sFwdslashPath, rhs.m_sFwdslashPath);
    }
}
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();
}
Esempio n. 26
0
bool SVNDiff::ShowUnifiedDiff(const CTSVNPath& url1, const SVNRev& rev1,
                              const CTSVNPath& url2, const SVNRev& rev2,
                              SVNRev peg,
                              const CString& options,
                              bool bIgnoreAncestry /* = false */,
                              bool /*blame*/,
                              bool bIgnoreProperties /* = true */)
{
    CTSVNPath tempfile;
    if (UnifiedDiff(tempfile, url1, rev1, url2, rev2, peg, options, bIgnoreAncestry, bIgnoreProperties))
    {
        CString title;
        CTSVNPathList list;
        list.AddPath(url1);
        list.AddPath(url2);
        if (url1.IsEquivalentTo(url2))
            title.FormatMessage(IDS_SVNDIFF_ONEURL, (LPCTSTR)rev1.ToString(), (LPCTSTR)rev2.ToString(), (LPCTSTR)url1.GetUIFileOrDirectoryName());
        else
        {
            CTSVNPath root = list.GetCommonRoot();
            CString u1 = url1.GetUIPathString().Mid(root.GetUIPathString().GetLength());
            CString u2 = url2.GetUIPathString().Mid(root.GetUIPathString().GetLength());
            title.FormatMessage(IDS_SVNDIFF_TWOURLS, (LPCTSTR)rev1.ToString(), (LPCTSTR)u1, (LPCTSTR)rev2.ToString(), (LPCTSTR)u2);
        }
        return !!CAppUtils::StartUnifiedDiffViewer(tempfile.GetWinPathString(), title);
    }
    return false;
}
Esempio n. 27
0
CStringA
CCachedDirectory::GetCacheKey(const CTSVNPath& path)
{
    // All we put into the cache as a key is just the end portion of the pathname
    // There's no point storing the path of the containing directory for every item
    CString lastElement
        = path.GetWinPathString().Mid(m_directoryPath.GetWinPathString().GetLength());
    return CUnicodeUtils::GetUTF8 (lastElement);
}
Esempio n. 28
0
bool CHooks::ManualPreCommit( HWND hWnd, const CTSVNPathList& pathList, CString& message, DWORD& exitcode, CString& error )
{
    hookiterator it = FindItem(manual_precommit, pathList);
    if (it == end())
        return false;
    if (!ApproveHook(hWnd, it))
        return false;
    CString sCmd = it->second.commandline;
    AddPathParam(sCmd, pathList);
    CTSVNPath temppath = AddMessageFileParam(sCmd, message);
    AddCWDParam(sCmd, pathList);
    exitcode = RunScript(sCmd, pathList, error, it->second.bWait, it->second.bShow);
    if (!exitcode && !temppath.IsEmpty())
    {
        CStringUtils::ReadStringFromTextFile(temppath.GetWinPathString(), message);
    }
    return true;
}
Esempio n. 29
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. 30
0
void
CCachedDirectory::AddEntry(const CTSVNPath& path, const svn_client_status_t* pSVNStatus, bool needsLock, bool forceNormal)
{
    svn_wc_status_kind nodestatus = forceNormal ? svn_wc_status_normal : (pSVNStatus ? pSVNStatus->node_status : svn_wc_status_none);
    if(path.IsDirectory())
    {
        // no lock here:
        // AutoLocker lock(m_critSec);
        // because GetDirectoryCacheEntry() can try to obtain a write lock
        CCachedDirectory * childDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(path);
        if (childDir)
        {
            if ((childDir->GetCurrentFullStatus() != svn_wc_status_ignored)||(pSVNStatus==NULL)||(nodestatus != svn_wc_status_unversioned))
                childDir->m_ownStatus.SetStatus(pSVNStatus, needsLock, forceNormal);
            childDir->m_ownStatus.SetKind(svn_node_dir);
        }
    }
    else
    {
        AutoLocker lock(m_critSec);
        CStringA cachekey = GetCacheKey(path);
        CacheEntryMap::iterator entry_it = m_entryCache.lower_bound(cachekey);
        if (entry_it != m_entryCache.end() && entry_it->first == cachekey)
        {
            if (pSVNStatus)
            {
                if (entry_it->second.GetEffectiveStatus() > svn_wc_status_none &&
                    entry_it->second.GetEffectiveStatus() != nodestatus)
                {
                    CSVNStatusCache::Instance().UpdateShell(path);
                    CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": shell update for %s\n"), path.GetWinPath());
                }
            }
        }
        else
        {
            entry_it = m_entryCache.insert(entry_it, std::make_pair(cachekey, CStatusCacheEntry()));
        }
        entry_it->second = CStatusCacheEntry(pSVNStatus, needsLock, path.GetLastWriteTime(), forceNormal);
    }
}