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
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;
        }
    }
}
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;
}