Exemple #1
0
    void HandleConflicts()
    {
        var svnKeysWithConflict = (
            from keys in mSVNStatusDatabase.Keys
            where mSVNStatusDatabase[keys].fileStatus == ESVNFileStatus.Conflicted
            select keys).ToList();

        foreach (var svnStatusKeyIt in svnKeysWithConflict)
        {
            int result = EditorUtility.DisplayDialogComplex("SVN Conflict", "There is a conflict in the file '" + svnStatusKeyIt + "'. Use 'Theirs' or 'Mine'?", "Theirs", "Mine", "Cancel");
            if (result == 0 || result == 1)
            {
                SVNCommands.SVNResolve(new string[] { svnStatusKeyIt }, false, result == 0);
            }
        }
        if (svnKeysWithConflict.Count > 0)
        {
            AssetDatabase.Refresh();
            SVNCommands.UpdateSVNStatusSync();
        }
    }
    void DrawPrefabGUI()
    {
        var prefabType   = EditorUtility.GetPrefabType(mGameObject);
        var prefabParent = EditorUtility.GetPrefabParent(mGameObject) as GameObject;

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUIStyle buttonStyle    = EditorStyles.toolbarButton;
        bool     showAddCommit  = SVNUtility.IsPrefab(mGameObject, true, false, false);
        bool     showLockByPass = SVNUtility.IsPrefab(mGameObject, true, false, false);
        bool     showRevert     = SVNUtility.IsPrefab(mGameObject) && SVNUtility.HaveAssetControl(mSVNStatus);

        SVNGUIControls.SVNStatusGUI(buttonStyle, mSVNStatus, mGameObject, showAddCommit, showLockByPass, showRevert);
        if (!SVNUtility.IsPrefabParent(mGameObject))
        {
            if (SVNUtility.IsPrefab(mGameObject, true, false, true)) // non-model prefabs
            {
                if (GUILayout.Button("Apply", buttonStyle))
                {
                    SVNUtility.ApplyPrefab(mGameObject);
                    SVNCommands.UpdateLocalSVNStatus();
                }
            }
            if (SVNUtility.IsPrefab(mGameObject, true, false, true)) // non-model prefabs
            {
                if (GUILayout.Button("Disconnect", buttonStyle))
                {
                    SVNUtility.DisconnectPrefab(mGameObject);
                }
            }
            if (prefabParent != null) // has a prefab parent (prefab on disk)
            {
                if (GUILayout.Button("Select", buttonStyle))
                {
                    SVNUtility.SelectPrefab(mGameObject);
                }
            }
        }
        EditorGUILayout.EndHorizontal();
    }
 public static void SVNBypassLockProjectContext()
 {
     SVNCommands.SVNBypassRevision(GetAssetPathsOfSelected().ToArray());
 }
 public static void SVNBypassLockGameobjectContext(MenuCommand command)
 {
     SVNCommands.SVNBypassRevision(new[] { SVNUtility.GetAssetPath(command.context) });
 }
 public static void SVNUpdate()
 {
     SVNCommands.SVNUpdate();
 }
Exemple #6
0
 public static void SetBypass(Object obj)
 {
     SVNCommands.SVNBypassRevision(new[] { GetAssetPath(obj) });
 }
Exemple #7
0
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        GUILayoutOption[] buttonLayout = { GUILayout.MaxWidth(50) };
        {// Buttons at top
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            using (new PushState <bool>(GUI.enabled, !mSVNBusy, v => GUI.enabled = v))
            {
                if (GUILayout.Button(SVNTerminoligy.status, EditorStyles.toolbarButton, buttonLayout) || Event.current.keyCode == KeyCode.F5)
                {
                    EditorApplication.SaveAssets();
                    SVNCommands.instance.UpdateSVNStatus();
                }
                if (GUILayout.Button(SVNTerminoligy.update, EditorStyles.toolbarButton, buttonLayout))
                {
                    SVNCommands.SVNUpdate();
                }
                if (GUILayout.Button(SVNTerminoligy.revert, EditorStyles.toolbarButton, buttonLayout))
                {
                    EditorApplication.SaveAssets();
                    SVNCommands.instance.SVNRevert(GetSelectedAssets().ToArray());
                }
                if (GUILayout.Button(SVNTerminoligy.delete, EditorStyles.toolbarButton, buttonLayout))
                {
                    SVNCommands.instance.SVNDelete(GetSelectedAssets().ToArray());
                }
                if (GUILayout.Button(SVNTerminoligy.unlock, EditorStyles.toolbarButton, buttonLayout))
                {
                    SVNCommands.instance.SVNReleaseLock(GetSelectedAssets().ToArray());
                }
                if (GUILayout.Button(SVNTerminoligy.commit, EditorStyles.toolbarButton, buttonLayout))
                {
                    var assetsToBeCommited = GetSelectedAssets();
                    SVNCommands.instance.SVNCommit(assetsToBeCommited, mCommitMessage.Length == 0 ? "Commit from Unity" : mCommitMessage);
                }
            }

            mCommitMessage = GUILayout.TextField(mCommitMessage, EditorStyles.toolbarTextField, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));
            bool newShowUnversioned = GUILayout.Toggle(mShowUnversioned, "Unversioned", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.MaxWidth(80) });

            if (newShowUnversioned != mShowUnversioned)
            {
                mShowUnversioned = newShowUnversioned;
                UpdateFilteringOfKeys();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Separator();
        }

        {// SVN elements on scrollable list
            const int columnSpacing = 20;

            GUILayoutOption[] propertyLayout  = { GUILayout.MaxWidth(75), GUILayout.Width(75) };
            GUILayoutOption[] assetPathLayout = { GUILayout.MaxWidth(600), GUILayout.Width(600) };

            var headingStyle = new GUIStyle(GUI.skin.label);
            var labelStyle   = new GUIStyle(GUI.skin.label);
            //labelStyle.normal.textColor = GUI.skin.label.normal new Color(0.2f, 0.2f, 0.2f);

            var selectedLabelStyle = new GUIStyle(labelStyle);
            //selectedLabelStyle.normal.textColor = new Color(0.0f, 0.0f, 0.0f);

            { // Header
                EditorGUILayout.BeginHorizontal();
                headingStyle.fontStyle = FontStyle.Bold;
                if (GUILayout.Button("\tAsset Path", headingStyle, assetPathLayout))
                {
                    if (mSortbyColumn == ColumnTypeEnum.AssetPath)
                    {
                        mReverseColumnSort = !mReverseColumnSort;
                    }
                    else
                    {
                        mReverseColumnSort = false;
                    }
                    mSortbyColumn = ColumnTypeEnum.AssetPath;
                    UpdateFilteringOfKeys();
                }
                GUILayout.Space(columnSpacing);

                //(reverseColumnSort ? "△" : "▽")
                if (GUILayout.Button("File Type", headingStyle, propertyLayout))
                {
                    if (mSortbyColumn == ColumnTypeEnum.FileType)
                    {
                        mReverseColumnSort = !mReverseColumnSort;
                    }
                    else
                    {
                        mReverseColumnSort = false;
                    }
                    mSortbyColumn = ColumnTypeEnum.FileType;
                    UpdateFilteringOfKeys();
                }
                GUILayout.Space(columnSpacing);


                if (GUILayout.Button("File Status", headingStyle, propertyLayout))
                {
                    if (mSortbyColumn == ColumnTypeEnum.FileStatus)
                    {
                        mReverseColumnSort = !mReverseColumnSort;
                    }
                    else
                    {
                        mReverseColumnSort = false;
                    }
                    mSortbyColumn = ColumnTypeEnum.FileStatus;
                    UpdateFilteringOfKeys();
                }
                GUILayout.Space(columnSpacing);


                if (GUILayout.Button("Locked By", headingStyle, propertyLayout))
                {
                    if (mSortbyColumn == ColumnTypeEnum.LockedBy)
                    {
                        mReverseColumnSort = !mReverseColumnSort;
                    }
                    else
                    {
                        mReverseColumnSort = false;
                    }
                    mSortbyColumn = ColumnTypeEnum.LockedBy;
                    UpdateFilteringOfKeys();
                }

                headingStyle.fontStyle = FontStyle.Normal;
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Separator();
            }
            mScrollViewVectorEntries = EditorGUILayout.BeginScrollView(mScrollViewVectorEntries, false, false);

            // List content
            if (mFilteredKeysOfInterrest != null && mFilteredKeysOfInterrest.Count() != 0)
            {
                foreach (SVNKeyValuePair svnStatusKeyIt in mFilteredKeysOfInterrest)
                {
                    if (!mSelectedAssets.ContainsKey(svnStatusKeyIt))
                    {
                        mSelectedAssets[svnStatusKeyIt] = false;
                    }
                    SVNStatus svnStatusValueIt = svnStatusKeyIt.svnStatus;
                    EditorGUILayout.BeginHorizontal();
                    Color previousColor = labelStyle.normal.textColor;
                    var   metaStatus    = mSVNStatusDatabase.GetMetaStatus(svnStatusKeyIt.key);
                    //if (metaStatus == null) Debug.Log("Missing meta file: " + svnStatusKeyIt.key);
                    bool metaModified = metaStatus != null &&
                                        metaStatus.fileStatus != ESVNFileStatus.Normal &&
                                        (metaStatus.fileStatus != ESVNFileStatus.Unversioned || metaStatus.fileStatus != svnStatusValueIt.fileStatus);
                    var tooltip = Path.GetFileName(svnStatusKeyIt.key) + ":\nsvn status :\t[" + svnStatusValueIt.fileStatus + "]";
                    if (metaStatus != null)
                    {
                        tooltip += "\nmeta status:\t[" + metaStatus.fileStatus + "]";
                    }

                    // AssetPath •
                    if (svnStatusValueIt.treeConflictStatus == ESVNTreeConflictStatus.TreeConflict)
                    {
                        labelStyle.normal.textColor = Color.red;
                    }
                    string assetPathText    = (mSelectedAssets[svnStatusKeyIt] ? "+\t" : "\t") + svnStatusKeyIt.key;
                    var    assetPathContent = new GUIContent(assetPathText);
                    if (GUILayout.Button(assetPathContent, (mSelectedAssets[svnStatusKeyIt] ? selectedLabelStyle : labelStyle), assetPathLayout))
                    {
                        mSelectedAssets[svnStatusKeyIt] = !mSelectedAssets[svnStatusKeyIt];
                    }
                    GUILayout.Space(columnSpacing);

                    // FileType
                    GUILayout.Label(GetFileType(svnStatusKeyIt.key), labelStyle, propertyLayout); GUILayout.Space(columnSpacing);
                    labelStyle.normal.textColor = GetStatusColorCode(svnStatusValueIt);

                    // FileStatus
                    var filestatusText    = svnStatusValueIt.fileStatus + (metaModified ? "(m)" : "") + (svnStatusValueIt.bypassRevisionControl ? "*" : "");
                    var filestatusContent = new GUIContent(filestatusText, tooltip);
                    GUILayout.Label(filestatusContent, labelStyle, propertyLayout); GUILayout.Space(columnSpacing);
                    labelStyle.normal.textColor = previousColor;

                    // LockedBy
                    GUILayout.Label(svnStatusValueIt.owner, labelStyle, propertyLayout);

                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.EndScrollView();
        }
        { // SVN message box
            //Debug.Log(messageHistory.Count);
            string allEntries = "";
            if (mCurrentSVNOperation != null)
            {
                allEntries = "Currently executing following command:\n" + mCurrentSVNOperation;
            }
            else
            {
                for (int i = svnCommandHistory.Count - 1; i >= 0; i--)
                {
                    if (!svnCommandHistory[i].arguments.Contains("status --non-interactive --xml"))
                    {
                        allEntries += svnCommandHistory[i].command + " " + svnCommandHistory[i].arguments + ":\n" + svnCommandHistory[i].outputStr + "-----------------------\n";
                    }
                }
            }
            EditorGUILayout.BeginVertical(GUILayout.Height(135));
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("SVN Output"));
            EditorGUILayout.EndHorizontal();
            mScrollViewVectorLog = EditorGUILayout.BeginScrollView(mScrollViewVectorLog, false, false);
            float heightOfLogInPixles = Mathf.Max(100.0f, GUI.skin.window.CalcSize(new GUIContent(allEntries)).y);

            GUI.skin.box.alignment = TextAnchor.UpperLeft;
            GUILayout.Box(allEntries, GUILayout.MinHeight(heightOfLogInPixles), GUILayout.ExpandWidth(true));
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndVertical();
    }