示例#1
0
 static void GUITest_BadCommand()
 {
     if (VersionControl.versionControlType == VersionControlType.Git)
     {
         UVCProcessPopup.Init(Git.RunGit("notarealcommand", CommandLine.EmptyHandler), false, true, null, false);
     }
     else
     {
         UVCProcessPopup.Init(Hg.RunHg("notarealcommand", CommandLine.EmptyHandler), false, true, null, false);
     }
 }
        /// <summary>
        /// Raises the Reset Button event.
        /// </summary>
        /// TODO: Implement button
        public static void OnButton_Reset(UVCBrowser browser)
        {
            string confirmation = mAnyFileSelected ? "This will undo all changes to the selected files and reset them to the last commit." : "This will undo all changes and reset to the last commit.";

            if (EditorUtility.DisplayDialog(
                    "Confirm Reset?",
                    confirmation, "Ok", "Cancel"))
            {
                browser.DisableGUI();
                UVCProcessPopup.Init(VersionControl.ResetLast(CommandLine.EmptyHandler, mSelectedFileCache), true, true, browser.OnProcessStop, true);
            }
        }
        /// <summary>
        /// Raises the Remove Button event.
        /// </summary>
        /// TODO: <<IMPORTANT>> Implement confirmation before removing modified files from the index
        public static void OnButton_Remove(UVCBrowser browser)
        {
            browser.DisableGUI();
            if (VersionControl.versionControlType == VersionControlType.Git && mStagedFileSelected)
            {
                // Git only - Clicking the remove button for a staged file will unstage it
                UVCProcessPopup.Init(VersionControl.Reset(CommandLine.EmptyHandler, "HEAD", mSelectedFileCache), true, true, browser.OnProcessStop, true);
            }
            else
            {
                bool dialog   = false;
                var  modFiles = new System.Text.StringBuilder();

                foreach (var file in mSelectedFileCache)
                {
                    if (file.fileState2 == FileState.Modified || file.fileState2 == FileState.Untracked)
                    {
                        dialog = true;
                        if (string.IsNullOrEmpty(file.path2))
                        {
                            modFiles.Append(file.path1).Append('\n');
                        }
                        else
                        {
                            modFiles.Append(file.path2).Append('\n');
                        }
                    }
                }

                if (dialog)
                {
                    if (EditorUtility.DisplayDialog(
                            "Confirm Remove Modified or Untracked Files?",
                            "The following files contain changes or information which is not in source control, and will be irretrievably lost if you remove them:\n" +
                            modFiles.ToString(0, modFiles.Length - 1), "Ok", "Cancel"))
                    {
                        UVCProcessPopup.Init(VersionControl.Remove(CommandLine.EmptyHandler, true, mSelectedFileCache), true, true, browser.OnProcessStop, true);
                    }
                    else
                    {
                        browser.OnProcessStop(-9999, null, null);
                    }
                }
                else
                {
                    UVCProcessPopup.Init(VersionControl.Remove(CommandLine.EmptyHandler, false, mSelectedFileCache), true, true, browser.OnProcessStop, true);
                }
            }
        }
    void OnGUI()
    {
        if (browser != null)
        {
            int i = EditorGUILayout.Popup("Pull from", currentRemoteIndex, BrowserUtility.remoteNames);
            if (i != currentRemoteIndex)
            {
                currentRemoteIndex = i;
                RefreshBranches();
                SetCurrentBranch();
            }

            currentBranchIndex = EditorGUILayout.Popup("Remote branch to pull", currentBranchIndex, currentBranches);

            GUILayout.Label("Pulling into local branch: " + BrowserUtility.localBranchNames[BrowserUtility.localBranchIndex]);

            GUILayout.Space(12);

            commit             = GUILayout.Toggle(commit, "Commit merged changes immediately");
            includeOldMessages = GUILayout.Toggle(includeOldMessages, "Include messages from commits being merged in merge commit");
            commitFastForward  = GUILayout.Toggle(commitFastForward, "Create new commit even if fast-forward merge");
            rebase             = GUILayout.Toggle(rebase, "Rebase instead of merge (WARNING: Make sure you haven't pushed your changes)");
            showOutput         = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                this.Close();

                UVCProcessPopup.Init(VersionControl.Pull(CommandLine.EmptyHandler, BrowserUtility.remoteNames[currentRemoteIndex], currentBranches[currentBranchIndex], commit, includeOldMessages, commitFastForward, rebase), !showOutput, true, browser.OnProcessStop, true);
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }
    void OnGUI()
    {
        if (browser != null)
        {
            allRemotes = GUILayout.Toggle(allRemotes, "Fetch from all remotes");

            GUI.enabled = !allRemotes;

            currentRemoteIndex = EditorGUILayout.Popup("Fetch from", currentRemoteIndex, BrowserUtility.remoteNames);

            GUI.enabled = true;

            prune      = GUILayout.Toggle(prune, "Prune tracking branches no longer present on remote(s)");
            showOutput = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                this.Close();

                if (allRemotes)
                {
                    UVCProcessPopup.Init(VersionControl.Fetch(CommandLine.EmptyHandler, "--all", prune), !showOutput, true, browser.OnProcessStop, true);
                }
                else
                {
                    UVCProcessPopup.Init(VersionControl.Fetch(CommandLine.EmptyHandler, BrowserUtility.remoteNames[currentRemoteIndex], prune), !showOutput, true, browser.OnProcessStop, true);
                }
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }
示例#6
0
 static void GUITest_BranchList()
 {
     UVCProcessPopup.Init(VersionControl.FindBranches(CommandLine.EmptyHandler), false, true, OnFindBranches_GUI, false);
 }
示例#7
0
 static void GUITest_Init()
 {
     UVCProcessPopup.Init(VersionControl.Initialize(CommandLine.EmptyHandler), false, true, null, false);
 }
 /// <summary>
 /// Raises the Add Button event.
 /// </summary>
 public static void OnButton_Add(UVCBrowser browser)
 {
     browser.DisableGUI();
     UVCProcessPopup.Init(VersionControl.Add(CommandLine.EmptyHandler, mSelectedFileCache), true, true, browser.OnProcessStop, true);
 }
 /// <summary>
 /// Raises the Checkout Branch Button event.
 /// </summary>
 public static void OnButton_CheckoutBranch(UVCBrowser browser)
 {
     browser.DisableGUI();
     UVCProcessPopup.Init(VersionControl.Checkout(CommandLine.EmptyHandler, mLocalBranchNames[mLocalBranchIndex], true), false, true, OnCheckoutBranch, true);
 }
 /// <summary>
 /// Raises the Init Button event.
 /// </summary>
 /// TODO: Implement button
 public static void OnButton_Init(UVCBrowser browser)
 {
     browser.DisableGUI();
     UVCProcessPopup.Init(VersionControl.Initialize(CommandLine.EmptyHandler), true, true, browser.OnProcessStop, true);
 }
示例#11
0
    void OnGUI()
    {
        if (browser != null)
        {
            GUILayout.Label("Commit Message:");

            commitMessage = EditorGUILayout.TextArea(commitMessage, GUILayout.ExpandHeight(true));

            oldCommits[0] = commitMessage;

            GUI.SetNextControlName("Selection");
            int selection = EditorGUILayout.Popup(oldCommitSelection, oldCommits, GUILayout.ExpandWidth(true));

            if (selection != oldCommitSelection)
            {
                oldCommitSelection = selection;
                commitMessage      = oldCommits[oldCommitSelection];
                GUI.FocusControl("Selection");
            }

            GUILayout.Space(6);

            amend      = GUILayout.Toggle(amend, "Amend previous commit");
            showOutput = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                if (oldCommits.Length > oldCommitsMaxLength)
                {
                    string[] temp = new string[30];
                    System.Array.ConstrainedCopy(oldCommits, 0, temp, 0, 30);
                    string str = string.Join(System.Convert.ToChar(0x0).ToString(), temp);
                    EditorPrefs.SetString("UnityVersionControl.OldCommitMessages", StringHelpers.UnicodeToHexString(str));
                }
                else
                {
                    string str = string.Join(System.Convert.ToChar(0x0).ToString(), oldCommits);
                    EditorPrefs.SetString("UnityVersionControl.OldCommitMessages", StringHelpers.UnicodeToHexString(str));
                }

                this.Close();

                if (amend)
                {
                    if (EditorUtility.DisplayDialog(
                            "Warning - changing history",
                            "You have chosen to amend the previous commit - this alters history and will cause problems if you have already pushed the previous commit to a remote. Are you sure you want to continue?", "Ok", "Cancel"))
                    {
                        UVCProcessPopup.Init(VersionControl.Commit(CommandLine.EmptyHandler, commitMessage.ToLiteral(), true, BrowserUtility.selectedFileCache), !showOutput, true, browser.OnProcessStop, true);
                    }
                }
                else
                {
                    UVCProcessPopup.Init(VersionControl.Commit(CommandLine.EmptyHandler, commitMessage.ToLiteral(), false, BrowserUtility.selectedFileCache), !showOutput, true, browser.OnProcessStop, true);
                }
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }
示例#12
0
    void OnGUI()
    {
        if (browser != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true));
            int sel = GUILayout.SelectionGrid(selectionGrid, selectionText, 3, EditorStyles.toolbarButton);
            GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            if (sel != selectionGrid)
            {
                selectionGrid = sel;
                if (sel == 0)
                {
                    this.minSize = new Vector2(600, 160);
                    this.maxSize = new Vector2(600, 160);
                    Repaint();
                }
                else
                {
                    this.minSize = new Vector2(600, 200);
                    this.maxSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
                    Repaint();
                }
            }
            if (selectionGrid == 0)
            {
                EditorGUILayout.LabelField("Current Branch:", BrowserUtility.localBranchNames[BrowserUtility.localBranchIndex]);
                newBranch         = EditorGUILayout.TextField("New Branch:", newBranch);
                checkoutNewBranch = EditorGUILayout.Toggle("Checkout new branch", checkoutNewBranch);

                GUILayout.Space(6);
            }
            else
            {
                if (selectionGrid == 2)
                {
                    int index = EditorGUILayout.Popup("Delete from:", currentRemoteIndex, BrowserUtility.remoteNames);
                    if (index != currentRemoteIndex)
                    {
                        currentRemoteIndex = index;
                        RefreshBranches();
                    }
                }
                GUILayout.Label("Branches to delete:");

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.Width(54));
                GUILayout.Label("Branch Name", EditorStyles.toolbarButton, GUILayout.MinWidth(154));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                scrollVector = GUILayout.BeginScrollView(scrollVector, GUILayout.MinWidth(250), GUILayout.ExpandHeight(true));
                GUILayout.BeginVertical();

                int ii = selectionGrid == 1 ? branchToggles.Length : remoteBranchToggles.Length;

                for (int i = 0; i < ii; i++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();

                    GUILayout.Space(20);

                    if (selectionGrid == 1)
                    {
                        branchToggles[i] = GUILayout.Toggle(branchToggles[i], "", GUILayout.Width(30));
                    }
                    else
                    {
                        remoteBranchToggles[i] = GUILayout.Toggle(remoteBranchToggles[i], "", GUILayout.Width(30));
                    }

                    string n = selectionGrid == 1 ? BrowserUtility.localBranchNames[i] : remoteBranches[i];

                    GUILayout.Label(n, GUILayout.MinWidth(150));

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Space(12);

                if (selectionGrid == 1)
                {
                    forceDelete = GUILayout.Toggle(forceDelete, "Force delete regardless of merge status");
                }
            }

            showOutput = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                this.Close();

                if (selectionGrid == 0)
                {
                    UVCProcessPopup.Init(VersionControl.CreateBranch(CommandLine.EmptyHandler, newBranch, checkoutNewBranch), !showOutput, true, browser.OnProcessStop, true);
                }
                else if (selectionGrid == 1)
                {
                    branchList.Clear();

                    for (int i = 0; i < branchToggles.Length; i++)
                    {
                        if (branchToggles[i])
                        {
                            branchList.Add(BrowserUtility.localBranchNames[i]);
                        }
                    }

                    UVCProcessPopup.Init(VersionControl.DeleteLocalBranches(CommandLine.EmptyHandler, branchList.ToArray(), forceDelete), !showOutput, true, browser.OnProcessStop, true);
                }
                else
                {
                    branchList.Clear();

                    for (int i = 0; i < remoteBranchToggles.Length; i++)
                    {
                        if (remoteBranchToggles[i])
                        {
                            branchList.Add(remoteBranches[i]);
                        }
                    }

                    string[] blanks = new string[branchList.Count];

                    for (int i = 0; i < blanks.Length; i++)
                    {
                        blanks[i] = string.Empty;
                    }

                    UVCProcessPopup.Init(VersionControl.Push(CommandLine.EmptyHandler, BrowserUtility.remoteNames[currentRemoteIndex], blanks, branchList.ToArray(), false), !showOutput, true, browser.OnProcessStop, true);
                }
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }
    void OnGUI()
    {
        if (browser != null)
        {
            int index = EditorGUILayout.Popup("Push to:", currentRemoteIndex, BrowserUtility.remoteNames);
            if (index != currentRemoteIndex)
            {
                currentRemoteIndex = index;
                RefreshBranches();
                SetCurrentBranches();
            }

            GUILayout.Space(12);

            GUILayout.Label("Branches to push:");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Push", EditorStyles.toolbarButton, GUILayout.Width(54));
            GUILayout.Label("Local Branch", EditorStyles.toolbarButton, GUILayout.Width(254));
            GUILayout.Label("Remote Branch", EditorStyles.toolbarButton, GUILayout.Width(254));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            scrollVector = GUILayout.BeginScrollView(scrollVector, GUILayout.ExpandHeight(true));
            GUILayout.BeginVertical();
            for (int i = 0; i < remoteBranchIndices.Length; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Space(20);
                pushToggles[i] = GUILayout.Toggle(pushToggles[i], "", GUILayout.Width(30));
                GUILayout.Label(BrowserUtility.localBranchNames[i], GUILayout.Width(250));
                GUILayout.Space(10);
                remoteBranchIndices[i] = EditorGUILayout.Popup(remoteBranchIndices[i], remoteBranches, GUILayout.Width(240));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(12);

            bool sel = GUILayout.Toggle(selectAll, "Select All");

            if (sel != selectAll)
            {
                selectAll = sel;
                for (int j = 0; j < pushToggles.Length; j++)
                {
                    pushToggles[j] = selectAll;
                }
            }

            pushAllTags = GUILayout.Toggle(pushAllTags, "Push all tags");

            showOutput = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                this.Close();

                var localNameList  = new List <string>();
                var remoteNameList = new List <string>();

                for (int i = 0; i < BrowserUtility.localBranchNames.Length; i++)
                {
                    if (pushToggles[i])
                    {
                        localNameList.Add(BrowserUtility.localBranchNames[i]);
                        remoteNameList.Add(remoteBranches[remoteBranchIndices[i]]);
                    }
                }

                UVCProcessPopup.Init(VersionControl.Push(CommandLine.EmptyHandler, BrowserUtility.remoteNames[currentRemoteIndex], localNameList.ToArray(), remoteNameList.ToArray(), pushAllTags), !showOutput, true, browser.OnProcessStop, true);
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }