Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
LRESULT CMergeWizardRevRange::OnWizardNext()
{
    StopWCCheckThread();

    UpdateData();

    if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible()))
    {
        m_pLogDlg->SendMessage(WM_CLOSE);
        return -1;
    }
    if (::IsWindow(m_pLogDlg2->GetSafeHwnd())&&(m_pLogDlg2->IsWindowVisible()))
    {
        m_pLogDlg2->SendMessage(WM_CLOSE);
        return -1;
    }

    CString sUrl;
    m_URLCombo.GetWindowText(sUrl);
    // check if the url has a revision appended to it and remove it if there is one
    auto atposurl = sUrl.ReverseFind('@');
    if (atposurl >= 0)
    {
        CString sRev = sUrl.Mid(atposurl+1);
        SVNRev rev(sRev);
        if (rev.IsValid())
        {
            ((CMergeWizard*)GetParent())->pegRev = rev;
            sUrl = sUrl.Left(atposurl);
        }
    }
    CTSVNPath url(sUrl);
    if (!url.IsUrl())
    {
        ShowComboBalloon(&m_URLCombo, IDS_ERR_MUSTBEURL, IDS_ERR_ERROR, TTI_ERROR);
        return -1;
    }

    m_URLCombo.SaveHistory();

    CString sRegKey = L"Software\\TortoiseSVN\\History\\repoURLS\\MergeURLFor" + ((CMergeWizard*)GetParent())->wcPath.GetSVNPathString();
    CRegString regMergeUrlForWC(sRegKey);
    regMergeUrlForWC = sUrl;

    ((CMergeWizard*)GetParent())->URL1 = sUrl;
    ((CMergeWizard*)GetParent())->URL2 = sUrl;

    if (GetCheckedRadioButton(IDC_MERGERADIO_ALL, IDC_MERGERADIO_SPECIFIC)==IDC_MERGERADIO_ALL)
        m_sRevRange.Empty();

    // if the revision range has HEAD as a revision specified, we have to
    // ask the server what the HEAD revision is: the SVNRevList can only deal
    // with numerical revisions because we have to sort the list to get the
    // ranges correctly
    if (m_sRevRange.Find(L"HEAD") >= 0)
    {
        if (!m_HEAD.IsValid())
        {
            SVN svn;
            m_HEAD = svn.GetHEADRevision(CTSVNPath(((CMergeWizard*)GetParent())->URL1));
        }
        m_sRevRange.Replace(L"HEAD", m_HEAD.ToString());
    }
    int atpos = -1;
    if ((atpos = m_sRevRange.ReverseFind('@')) >= 0)
    {
        ((CMergeWizard*)GetParent())->pegRev = SVNRev(m_sRevRange.Mid(atpos+1));
        m_sRevRange = m_sRevRange.Left(atpos);
    }
    if (!((CMergeWizard*)GetParent())->revRangeArray.FromListString(m_sRevRange))
    {
        ShowEditBalloon(IDC_REVISION_RANGE, IDS_ERR_INVALIDREVRANGE, IDS_ERR_ERROR, TTI_ERROR);
        return -1;
    }
    return IDD_MERGEWIZARD_OPTIONS;
}
Ejemplo n.º 3
0
void CEditPropExternals::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
    int selIndex = m_ExtList.GetSelectionMark();
    if (selIndex < 0)
        return; // nothing selected, nothing to do with a context menu
    int selCount = m_ExtList.GetSelectedCount();
    if (selCount <= 0)
        return; // nothing selected, nothing to do with a context menu

    // if the context menu is invoked through the keyboard, we have to use
    // a calculated position on where to anchor the menu on
    if ((point.x == -1) && (point.y == -1))
    {
        CRect rect;
        m_ExtList.GetItemRect(selIndex, &rect, LVIR_LABEL);
        m_ExtList.ClientToScreen(&rect);
        point = rect.CenterPoint();
    }

    bool haveHead = true;

    POSITION pos = m_ExtList.GetFirstSelectedItemPosition();
    while (pos)
    {
        int index = m_ExtList.GetNextSelectedItem(pos);
        if ((index >= 0)&&(index < (int)m_externals.size()))
        {
            if (m_externals[index].headrev == SVN_INVALID_REVNUM)
            {
                haveHead = false;
                break;
            }
        }
    }

    CIconMenu popup;
    if (popup.CreatePopupMenu())
    {
        if (haveHead)
            popup.AppendMenuIcon(CMD_ADJUST, IDS_EDITPROPS_ADJUST_TO_HEAD);
        else
            popup.AppendMenuIcon(CMD_FETCH_AND_ADJUST, IDS_EDITPROPS_FETCH_AND_ADJUST_TO_HEAD);

        int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON, point.x, point.y, this, 0);

        switch (cmd)
        {
        case CMD_FETCH_AND_ADJUST:
            {
                SVN svn;
                svn.SetPromptParentWindow(m_hWnd);
                SVNInfo svnInfo;
                svnInfo.SetPromptParentWindow(m_hWnd);
                SVNLogHelper logHelper;
                CProgressDlg progDlg;
                progDlg.ShowModal(m_hWnd, TRUE);
                progDlg.SetTitle(IDS_EDITPROPS_PROG_FINDHEADTITLE);
                progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_EDITPROPS_PROG_FINDHEADREVS)));
                DWORD count = 0;
                DWORD total = m_ExtList.GetSelectedCount();
                POSITION p = m_ExtList.GetFirstSelectedItemPosition();
                while (p)
                {
                    int index = m_ExtList.GetNextSelectedItem(p);
                    progDlg.SetProgress(count++, total);
                    if ((index >= 0)&&(index < (int)m_externals.size()))
                    {
                        progDlg.SetLine(2, m_externals[index].url, true);
                        if (m_externals[index].headrev == SVN_INVALID_REVNUM)
                        {
                            if (m_externals[index].root.IsEmpty())
                            {
                                CTSVNPath path_ = m_externals[index].path;
                                path_.AppendPathString(m_externals[index].targetDir);
                                m_externals[index].root = svn.GetRepositoryRoot(path_);
                            }
                            auto fullurl = CTSVNPath(m_externals[index].fullurl);
                            auto youngestRev = logHelper.GetYoungestRev(fullurl);
                            if (!youngestRev.IsValid())
                                m_externals[index].headrev = svn.GetHEADRevision(fullurl, true);
                            else
                                m_externals[index].headrev = youngestRev;
                        }
                    }
                }
                progDlg.Stop();
            }
            // intentional fall through
        case CMD_ADJUST:
            {
                POSITION p = m_ExtList.GetFirstSelectedItemPosition();
                while (p)
                {
                    int index = m_ExtList.GetNextSelectedItem(p);
                    if ((index >= 0)&&(index < (int)m_externals.size()))
                    {
                        if (m_externals[index].headrev != SVN_INVALID_REVNUM)
                        {
                            if (m_externals[index].revision.kind == svn_opt_revision_number)
                            {
                                m_externals[index].revision.value.number = -1;
                                m_externals[index].revision.kind = svn_opt_revision_unspecified;
                            }
                            m_externals[index].pegrevision.value.number = m_externals[index].headrev;
                            m_externals[index].pegrevision.kind = svn_opt_revision_number;
                        }
                    }
                }
                m_ExtList.Invalidate();
            }
            break;
        }
    }
}