first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal class ChangeCategoryTreeViewItem : TreeViewItem
|
||||
{
|
||||
internal ChangeCategory Category { get; private set; }
|
||||
|
||||
internal ChangeCategoryTreeViewItem(
|
||||
int id, int depth, ChangeCategory category)
|
||||
: base(id, depth, category.GetHeaderText())
|
||||
{
|
||||
Category = category;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 156e16594aa6bd54cb77aa3f8eae5c82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,20 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal class ClientDiffTreeViewItem : TreeViewItem
|
||||
{
|
||||
internal ClientDiffInfo Difference { get; private set; }
|
||||
|
||||
internal ClientDiffTreeViewItem(
|
||||
int id, int depth, ClientDiffInfo diff)
|
||||
: base(id, depth)
|
||||
{
|
||||
Difference = diff;
|
||||
|
||||
displayName = diff.PathString;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fdd86a000d1ef04094416eefed53087
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ac250bc549a212428286f328779be0e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,249 @@
|
||||
using System.IO;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff.Dialogs
|
||||
{
|
||||
internal class GetRestorePathDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 600, 205);
|
||||
}
|
||||
}
|
||||
|
||||
internal static GetRestorePathData GetRestorePath(
|
||||
string wkPath,
|
||||
string restorePath,
|
||||
string explanation,
|
||||
bool isDirectory,
|
||||
bool showSkipButton,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
GetRestorePathDialog dialog = Create(
|
||||
new ProgressControlsForDialogs(),
|
||||
wkPath,
|
||||
GetProposedRestorePath.For(restorePath),
|
||||
explanation,
|
||||
isDirectory,
|
||||
showSkipButton);
|
||||
|
||||
ResponseType dialogResult = dialog.RunModal(parentWindow);
|
||||
|
||||
GetRestorePathData result = dialog.BuildGetRestorePathResult();
|
||||
|
||||
result.Result = GetRestorePathResultType(dialogResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Title(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.EnterRestorePathFormTitle));
|
||||
|
||||
Paragraph(mExplanation);
|
||||
|
||||
DoEntryArea();
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
DrawProgressForDialogs.For(
|
||||
mProgressControls.ProgressData);
|
||||
|
||||
DoButtonsArea();
|
||||
|
||||
mProgressControls.ForcedUpdateProgress(this);
|
||||
}
|
||||
|
||||
void DoEntryArea()
|
||||
{
|
||||
GUILayout.Label(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.EnterRestorePathFormTextBoxExplanation),
|
||||
EditorStyles.label);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
mRestorePath = GUILayout.TextField(
|
||||
mRestorePath, GUILayout.Width(TEXTBOX_WIDTH));
|
||||
|
||||
if (GUILayout.Button("...", EditorStyles.miniButton))
|
||||
{
|
||||
mRestorePath = (mIsDirectory) ?
|
||||
DoOpenFolderPanel(mRestorePath) :
|
||||
DoOpenFilePanel(mRestorePath);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.EnterRestorePathFormTitle);
|
||||
}
|
||||
|
||||
static string DoOpenFolderPanel(string actualPath)
|
||||
{
|
||||
string parentDirectory = null;
|
||||
string directoryName = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(actualPath))
|
||||
{
|
||||
parentDirectory = Path.GetDirectoryName(actualPath);
|
||||
directoryName = Path.GetFileName(actualPath);
|
||||
}
|
||||
|
||||
string result = EditorUtility.SaveFolderPanel(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.SelectPathToRestore),
|
||||
parentDirectory,
|
||||
directoryName);
|
||||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return actualPath;
|
||||
|
||||
return Path.GetFullPath(result);
|
||||
}
|
||||
|
||||
static string DoOpenFilePanel(string actualPath)
|
||||
{
|
||||
string parentDirectory = null;
|
||||
string fileName = null;
|
||||
string extension = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(actualPath))
|
||||
{
|
||||
parentDirectory = Path.GetDirectoryName(actualPath);
|
||||
fileName = Path.GetFileName(actualPath);
|
||||
extension = Path.GetExtension(actualPath);
|
||||
}
|
||||
|
||||
string result = EditorUtility.SaveFilePanel(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.SelectPathToRestore),
|
||||
parentDirectory,
|
||||
fileName,
|
||||
extension);
|
||||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return actualPath;
|
||||
|
||||
return Path.GetFullPath(result);
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoOkButton();
|
||||
DoSkipButton(mShowSkipButton);
|
||||
DoCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCancelButton();
|
||||
DoSkipButton(mShowSkipButton);
|
||||
DoOkButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoOkButton()
|
||||
{
|
||||
if (!AcceptButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.OkButton)))
|
||||
return;
|
||||
|
||||
OkButtonWithValidationAction();
|
||||
}
|
||||
|
||||
void DoSkipButton(bool showSkipButton)
|
||||
{
|
||||
if (!showSkipButton)
|
||||
return;
|
||||
|
||||
if (!NormalButton(PlasticLocalization.GetString(PlasticLocalization.Name.SkipRestoreButton)))
|
||||
return;
|
||||
|
||||
CloseButtonAction();
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CancelButton)))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void OkButtonWithValidationAction()
|
||||
{
|
||||
GetRestorePathValidation.Validation(
|
||||
mWkPath, BuildGetRestorePathResult(),
|
||||
this, mProgressControls);
|
||||
}
|
||||
|
||||
GetRestorePathData BuildGetRestorePathResult()
|
||||
{
|
||||
return new GetRestorePathData(mRestorePath);
|
||||
}
|
||||
|
||||
static GetRestorePathData.ResultType GetRestorePathResultType(
|
||||
ResponseType dialogResult)
|
||||
{
|
||||
switch (dialogResult)
|
||||
{
|
||||
case ResponseType.None:
|
||||
return GetRestorePathData.ResultType.Skip;
|
||||
case ResponseType.Ok:
|
||||
return GetRestorePathData.ResultType.OK;
|
||||
case ResponseType.Cancel:
|
||||
return GetRestorePathData.ResultType.Cancel;
|
||||
}
|
||||
|
||||
return GetRestorePathData.ResultType.Cancel;
|
||||
}
|
||||
|
||||
static GetRestorePathDialog Create(
|
||||
ProgressControlsForDialogs progressControls,
|
||||
string wkPath,
|
||||
string restorePath,
|
||||
string explanation,
|
||||
bool isDirectory,
|
||||
bool showSkipButton)
|
||||
{
|
||||
var instance = CreateInstance<GetRestorePathDialog>();
|
||||
instance.mWkPath = wkPath;
|
||||
instance.mRestorePath = restorePath;
|
||||
instance.mExplanation = explanation;
|
||||
instance.mIsDirectory = isDirectory;
|
||||
instance.mShowSkipButton = showSkipButton;
|
||||
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
|
||||
instance.mEscapeKeyAction = instance.CancelButtonAction;
|
||||
instance.mProgressControls = progressControls;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool mIsDirectory;
|
||||
bool mShowSkipButton;
|
||||
string mExplanation = string.Empty;
|
||||
string mRestorePath = string.Empty;
|
||||
string mWkPath = string.Empty;
|
||||
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
const float TEXTBOX_WIDTH = 520;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 281456381b1a4c742b0efbe305328c7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ee79162e06c6984a97600b7c0680611
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal static class DiffSelection
|
||||
{
|
||||
internal static List<ClientDiffInfo> GetSelectedDiffs(
|
||||
DiffTreeView treeView)
|
||||
{
|
||||
return treeView.GetSelectedDiffs(true);
|
||||
}
|
||||
|
||||
internal static List<ClientDiffInfo> GetSelectedDiffsWithoutMeta(
|
||||
DiffTreeView treeView)
|
||||
{
|
||||
return treeView.GetSelectedDiffs(false);
|
||||
}
|
||||
|
||||
internal static ClientDiffInfo GetSelectedDiff(
|
||||
DiffTreeView treeView)
|
||||
{
|
||||
if (!treeView.HasSelection())
|
||||
return null;
|
||||
|
||||
return treeView.GetSelectedDiffs(false)[0];
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ef5fb54cd29b40468eaf5a14e9845ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba4e6e12f66973142a87299287cb34dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,298 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.EventTracking;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.Tool;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal class DiffTreeViewMenu
|
||||
{
|
||||
internal interface IMetaMenuOperations
|
||||
{
|
||||
bool SelectionHasMeta();
|
||||
void DiffMeta();
|
||||
void HistoryMeta();
|
||||
}
|
||||
|
||||
internal DiffTreeViewMenu(
|
||||
IDiffTreeViewMenuOperations operations,
|
||||
IMetaMenuOperations metaMenuOperations)
|
||||
{
|
||||
mOperations = operations;
|
||||
mMetaMenuOperations = metaMenuOperations;
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
internal void Popup()
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
UpdateMenuItems(menu);
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
internal bool ProcessKeyActionIfNeeded(Event e)
|
||||
{
|
||||
DiffTreeViewMenuOperations operationToExecute = GetMenuOperation(e);
|
||||
|
||||
if (operationToExecute == DiffTreeViewMenuOperations.None)
|
||||
return false;
|
||||
|
||||
SelectedDiffsGroupInfo info =
|
||||
mOperations.GetSelectedDiffsGroupInfo();
|
||||
|
||||
DiffTreeViewMenuOperations operations =
|
||||
DiffTreeViewMenuUpdater.GetAvailableMenuOperations(info);
|
||||
|
||||
if (!operations.HasFlag(operationToExecute))
|
||||
return false;
|
||||
|
||||
ProcessMenuOperation(operationToExecute);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SaveRevisionAsMenuItem_Click()
|
||||
{
|
||||
mOperations.SaveRevisionAs();
|
||||
}
|
||||
|
||||
void DiffMenuItem_Click()
|
||||
{
|
||||
mOperations.Diff();
|
||||
}
|
||||
|
||||
void DiffMetaMenuItem_Click()
|
||||
{
|
||||
mMetaMenuOperations.DiffMeta();
|
||||
}
|
||||
|
||||
void HistoryMenuItem_Click()
|
||||
{
|
||||
mOperations.History();
|
||||
}
|
||||
|
||||
void HistoryMetaMenuItem_Click()
|
||||
{
|
||||
mMetaMenuOperations.HistoryMeta();
|
||||
}
|
||||
|
||||
void RevertMenuItem_Click()
|
||||
{
|
||||
mOperations.RevertChanges();
|
||||
}
|
||||
|
||||
void UndeleteMenuItem_Click()
|
||||
{
|
||||
mOperations.Undelete();
|
||||
}
|
||||
|
||||
void UndeleteToSpecifiedPathMenuItem_Click()
|
||||
{
|
||||
mOperations.UndeleteToSpecifiedPaths();
|
||||
}
|
||||
|
||||
void UpdateMenuItems(GenericMenu menu)
|
||||
{
|
||||
SelectedDiffsGroupInfo groupInfo =
|
||||
mOperations.GetSelectedDiffsGroupInfo();
|
||||
|
||||
DiffTreeViewMenuOperations operations =
|
||||
DiffTreeViewMenuUpdater.GetAvailableMenuOperations(groupInfo);
|
||||
|
||||
if (operations == DiffTreeViewMenuOperations.None)
|
||||
{
|
||||
menu.AddDisabledItem(GetNoActionMenuItemContent());
|
||||
return;
|
||||
}
|
||||
|
||||
bool isMultipleSelection = groupInfo.SelectedItemsCount > 1;
|
||||
bool selectionHasMeta = mMetaMenuOperations.SelectionHasMeta();
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.SaveAs))
|
||||
menu.AddItem(mSaveRevisionAsMenuItemContent, false, SaveRevisionAsMenuItem_Click);
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.Diff))
|
||||
menu.AddItem(mDiffMenuItemContent, false, DiffMenuItem_Click);
|
||||
else
|
||||
menu.AddDisabledItem(mDiffMenuItemContent, false);
|
||||
|
||||
if (mMetaMenuOperations.SelectionHasMeta())
|
||||
{
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.Diff))
|
||||
menu.AddItem(mDiffMetaMenuItemContent, false, DiffMetaMenuItem_Click);
|
||||
else
|
||||
menu.AddDisabledItem(mDiffMetaMenuItemContent);
|
||||
}
|
||||
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.History))
|
||||
menu.AddItem(mViewHistoryMenuItemContent, false, HistoryMenuItem_Click);
|
||||
else
|
||||
menu.AddDisabledItem(mViewHistoryMenuItemContent, false);
|
||||
|
||||
if (mMetaMenuOperations.SelectionHasMeta())
|
||||
{
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.History))
|
||||
menu.AddItem(mViewHistoryMetaMenuItemContent, false, HistoryMetaMenuItem_Click);
|
||||
else
|
||||
menu.AddDisabledItem(mViewHistoryMetaMenuItemContent, false);
|
||||
}
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.RevertChanges))
|
||||
{
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
mRevertMenuItemContent.text = GetRevertMenuItemText(
|
||||
isMultipleSelection,
|
||||
selectionHasMeta);
|
||||
|
||||
menu.AddItem(mRevertMenuItemContent, false, RevertMenuItem_Click);
|
||||
}
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.Undelete) ||
|
||||
operations.HasFlag(DiffTreeViewMenuOperations.UndeleteToSpecifiedPaths))
|
||||
{
|
||||
menu.AddSeparator(string.Empty);
|
||||
}
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.Undelete))
|
||||
{
|
||||
mUndeleteMenuItemContent.text = GetUndeleteMenuItemText(
|
||||
isMultipleSelection,
|
||||
selectionHasMeta);
|
||||
|
||||
menu.AddItem(mUndeleteMenuItemContent, false, UndeleteMenuItem_Click);
|
||||
}
|
||||
|
||||
if (operations.HasFlag(DiffTreeViewMenuOperations.UndeleteToSpecifiedPaths))
|
||||
{
|
||||
mUndeleteToSpecifiedPathMenuItemContent.text = GetUndeleteToSpecifiedPathMenuItemText(
|
||||
isMultipleSelection,
|
||||
selectionHasMeta);
|
||||
|
||||
menu.AddItem(mUndeleteToSpecifiedPathMenuItemContent, false, UndeleteToSpecifiedPathMenuItem_Click);
|
||||
}
|
||||
}
|
||||
|
||||
GUIContent GetNoActionMenuItemContent()
|
||||
{
|
||||
if (mNoActionMenuItemContent == null)
|
||||
{
|
||||
mNoActionMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.
|
||||
Name.NoActionMenuItem));
|
||||
}
|
||||
|
||||
return mNoActionMenuItemContent;
|
||||
}
|
||||
|
||||
static string GetRevertMenuItemText(
|
||||
bool isMultipleSelection,
|
||||
bool selectionHasMeta)
|
||||
{
|
||||
if (selectionHasMeta && !isMultipleSelection)
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.UndoThisChangePlusMeta);
|
||||
|
||||
return isMultipleSelection ?
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndoSelectedChanges) :
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndoThisChange);
|
||||
}
|
||||
|
||||
static string GetUndeleteMenuItemText(
|
||||
bool isMultipleSelection,
|
||||
bool selectionHasMeta)
|
||||
{
|
||||
if (selectionHasMeta && !isMultipleSelection)
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteRevisionPlusMeta);
|
||||
|
||||
return isMultipleSelection ?
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteSelectedRevisions) :
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteRevisions);
|
||||
}
|
||||
|
||||
static string GetUndeleteToSpecifiedPathMenuItemText(
|
||||
bool isMultipleSelection,
|
||||
bool selectionHasMeta)
|
||||
{
|
||||
if (selectionHasMeta && !isMultipleSelection)
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteRevisionPlusMetaPath);
|
||||
|
||||
return isMultipleSelection ?
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteSelectedRevisionsPaths) :
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.UndeleteRevisionPath);
|
||||
}
|
||||
|
||||
void ProcessMenuOperation(DiffTreeViewMenuOperations operationToExecute)
|
||||
{
|
||||
if (operationToExecute == DiffTreeViewMenuOperations.SaveAs)
|
||||
{
|
||||
SaveRevisionAsMenuItem_Click();
|
||||
return;
|
||||
}
|
||||
|
||||
if (operationToExecute == DiffTreeViewMenuOperations.Diff)
|
||||
{
|
||||
DiffMenuItem_Click();
|
||||
return;
|
||||
}
|
||||
|
||||
if (operationToExecute == DiffTreeViewMenuOperations.History)
|
||||
{
|
||||
HistoryMenuItem_Click();
|
||||
}
|
||||
}
|
||||
|
||||
static DiffTreeViewMenuOperations GetMenuOperation(Event e)
|
||||
{
|
||||
if (Keyboard.IsControlOrCommandKeyPressed(e) && Keyboard.IsKeyPressed(e, KeyCode.D))
|
||||
return DiffTreeViewMenuOperations.Diff;
|
||||
|
||||
if (Keyboard.IsControlOrCommandKeyPressed(e) && Keyboard.IsKeyPressed(e, KeyCode.H))
|
||||
return DiffTreeViewMenuOperations.History;
|
||||
|
||||
return DiffTreeViewMenuOperations.None;
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
mSaveRevisionAsMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.DiffMenuItemSaveRevisionAs));
|
||||
mDiffMenuItemContent = new GUIContent(
|
||||
string.Format("{0} {1}",
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.DiffMenuItem),
|
||||
GetPlasticShortcut.ForDiff()));
|
||||
mDiffMetaMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.DiffMetaMenuItem));
|
||||
mViewHistoryMenuItemContent = new GUIContent(
|
||||
string.Format("{0} {1}",
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.ViewHistoryMenuItem),
|
||||
GetPlasticShortcut.ForHistory()));
|
||||
mViewHistoryMetaMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.ViewHistoryMetaMenuItem));
|
||||
mRevertMenuItemContent = new GUIContent();
|
||||
mUndeleteMenuItemContent = new GUIContent();
|
||||
mUndeleteToSpecifiedPathMenuItemContent = new GUIContent();
|
||||
}
|
||||
|
||||
GUIContent mNoActionMenuItemContent;
|
||||
|
||||
GUIContent mSaveRevisionAsMenuItemContent;
|
||||
GUIContent mDiffMenuItemContent;
|
||||
GUIContent mDiffMetaMenuItemContent;
|
||||
GUIContent mViewHistoryMenuItemContent;
|
||||
GUIContent mViewHistoryMetaMenuItemContent;
|
||||
GUIContent mRevertMenuItemContent;
|
||||
GUIContent mUndeleteMenuItemContent;
|
||||
GUIContent mUndeleteToSpecifiedPathMenuItemContent;
|
||||
|
||||
readonly IDiffTreeViewMenuOperations mOperations;
|
||||
readonly IMetaMenuOperations mMetaMenuOperations;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c9c0041347ae4e4cb794a3da850fa79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice.Utils;
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal static class GetClientDiffInfos
|
||||
{
|
||||
internal static List<ClientDiffInfo> FromCategories(List<IDiffCategory> categories)
|
||||
{
|
||||
List<ClientDiffInfo> result = new List<ClientDiffInfo>();
|
||||
|
||||
foreach (ITreeViewNode node in categories)
|
||||
AddClientDiffInfos(node, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void AddClientDiffInfos(ITreeViewNode node, List<ClientDiffInfo> result)
|
||||
{
|
||||
if (node is ClientDiffInfo)
|
||||
{
|
||||
result.Add((ClientDiffInfo)node);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < node.GetChildrenCount(); i++)
|
||||
AddClientDiffInfos(node.GetChild(i), result);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ab43506dddfc244ab5b44585140c5a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,18 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal class MergeCategoryTreeViewItem : TreeViewItem
|
||||
{
|
||||
internal CategoryGroup Category { get; private set; }
|
||||
|
||||
internal MergeCategoryTreeViewItem(
|
||||
int id, int depth, CategoryGroup categoryGroup)
|
||||
: base(id, depth, categoryGroup.GetHeaderText())
|
||||
{
|
||||
Category = categoryGroup;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 923dacaaac477a941a4a5c7c1657a250
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,233 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice.Client.Commands;
|
||||
using Codice.Client.Common;
|
||||
using Codice.CM.Common;
|
||||
using Codice.Utils;
|
||||
using PlasticGui;
|
||||
using PlasticGui.Diff;
|
||||
using PlasticGui.WorkspaceWindow.Diff;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Diff
|
||||
{
|
||||
internal class UnityDiffTree
|
||||
{
|
||||
internal UnityDiffTree()
|
||||
{
|
||||
mInnerTree = new DiffTree();
|
||||
mMetaCache = new MetaCache();
|
||||
}
|
||||
|
||||
internal void BuildCategories(
|
||||
WorkspaceInfo wkInfo,
|
||||
List<ClientDiff> diffs,
|
||||
BranchResolver brResolver,
|
||||
bool skipMergeTracking)
|
||||
{
|
||||
mInnerTree.BuildCategories(
|
||||
RevisionInfoCodeReviewAdapter.CalculateCodeReviewEntries(
|
||||
wkInfo,
|
||||
diffs,
|
||||
brResolver,
|
||||
skipMergeTracking),
|
||||
brResolver);
|
||||
mMetaCache.Build(mInnerTree.GetNodes());
|
||||
}
|
||||
|
||||
internal List<IDiffCategory> GetNodes()
|
||||
{
|
||||
return mInnerTree.GetNodes();
|
||||
}
|
||||
|
||||
internal bool HasMeta(ClientDiffInfo difference)
|
||||
{
|
||||
return mMetaCache.ContainsMeta(difference);
|
||||
}
|
||||
|
||||
internal ClientDiffInfo GetMetaDiff(ClientDiffInfo diff)
|
||||
{
|
||||
return mMetaCache.GetExistingMeta(diff);
|
||||
}
|
||||
|
||||
internal void FillWithMeta(List<ClientDiffInfo> diffs)
|
||||
{
|
||||
diffs.AddRange(
|
||||
mMetaCache.GetExistingMeta(diffs));
|
||||
}
|
||||
|
||||
internal void Sort(string key, bool sortAscending)
|
||||
{
|
||||
mInnerTree.Sort(key, sortAscending);
|
||||
}
|
||||
|
||||
internal void Filter(Filter filter, List<string> columnNames)
|
||||
{
|
||||
mInnerTree.Filter(filter, columnNames);
|
||||
}
|
||||
|
||||
MetaCache mMetaCache = new MetaCache();
|
||||
DiffTree mInnerTree;
|
||||
|
||||
class MetaCache
|
||||
{
|
||||
internal void Build(List<IDiffCategory> categories)
|
||||
{
|
||||
mCache.Clear();
|
||||
|
||||
HashSet<string> indexedKeys = BuildIndexedKeys(
|
||||
GetClientDiffInfos.FromCategories(categories));
|
||||
|
||||
for (int i = 0; i < categories.Count; i++)
|
||||
{
|
||||
ExtractToMetaCache(
|
||||
(ITreeViewNode)categories[i],
|
||||
i,
|
||||
mCache,
|
||||
indexedKeys);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ContainsMeta(ClientDiffInfo diff)
|
||||
{
|
||||
return mCache.ContainsKey(
|
||||
BuildKey.ForMetaDiff(diff));
|
||||
}
|
||||
|
||||
internal ClientDiffInfo GetExistingMeta(ClientDiffInfo diff)
|
||||
{
|
||||
ClientDiffInfo result;
|
||||
|
||||
if (!mCache.TryGetValue(BuildKey.ForMetaDiff(diff), out result))
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal List<ClientDiffInfo> GetExistingMeta(List<ClientDiffInfo> diffs)
|
||||
{
|
||||
List<ClientDiffInfo> result = new List<ClientDiffInfo>();
|
||||
|
||||
foreach (ClientDiffInfo diff in diffs)
|
||||
{
|
||||
string key = BuildKey.ForMetaDiff(diff);
|
||||
|
||||
ClientDiffInfo metaDiff;
|
||||
if (!mCache.TryGetValue(key, out metaDiff))
|
||||
continue;
|
||||
|
||||
result.Add(metaDiff);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ExtractToMetaCache(
|
||||
ITreeViewNode node,
|
||||
int nodeIndex,
|
||||
Dictionary<string, ClientDiffInfo> cache,
|
||||
HashSet<string> indexedKeys)
|
||||
{
|
||||
if (node is ClientDiffInfo)
|
||||
{
|
||||
ClientDiffInfo diff = (ClientDiffInfo)node;
|
||||
|
||||
string path = diff.DiffWithMount.Difference.Path;
|
||||
|
||||
if (!MetaPath.IsMetaPath(path))
|
||||
return;
|
||||
|
||||
string realPath = MetaPath.GetPathFromMetaPath(path);
|
||||
|
||||
if (!indexedKeys.Contains(BuildKey.BuildCacheKey(
|
||||
BuildKey.GetCategoryGroup(diff),
|
||||
BuildKey.GetChangeCategory(diff),
|
||||
realPath)))
|
||||
return;
|
||||
|
||||
// found foo.c and foo.c.meta
|
||||
// with the same chage types - move .meta to cache
|
||||
cache.Add(BuildKey.ForDiff(diff), diff);
|
||||
((ChangeCategory)node.GetParent()).RemoveDiffAt(nodeIndex);
|
||||
}
|
||||
|
||||
for (int i = node.GetChildrenCount() - 1; i >= 0; i--)
|
||||
{
|
||||
ExtractToMetaCache(
|
||||
node.GetChild(i),
|
||||
i,
|
||||
cache,
|
||||
indexedKeys);
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<string> BuildIndexedKeys(List<ClientDiffInfo> diffs)
|
||||
{
|
||||
HashSet<string> result = new HashSet<string>();
|
||||
|
||||
foreach (ClientDiffInfo diff in diffs)
|
||||
{
|
||||
if (MetaPath.IsMetaPath(diff.DiffWithMount.Difference.Path))
|
||||
continue;
|
||||
|
||||
result.Add(BuildKey.ForDiff(diff));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Dictionary<string, ClientDiffInfo> mCache =
|
||||
new Dictionary<string, ClientDiffInfo>();
|
||||
|
||||
static class BuildKey
|
||||
{
|
||||
internal static string ForDiff(
|
||||
ClientDiffInfo diff)
|
||||
{
|
||||
return BuildCacheKey(
|
||||
GetCategoryGroup(diff),
|
||||
GetChangeCategory(diff),
|
||||
diff.DiffWithMount.Difference.Path);
|
||||
}
|
||||
|
||||
internal static string ForMetaDiff(
|
||||
ClientDiffInfo diff)
|
||||
{
|
||||
return BuildCacheKey(
|
||||
GetCategoryGroup(diff),
|
||||
GetChangeCategory(diff),
|
||||
MetaPath.GetMetaPath(diff.DiffWithMount.Difference.Path));
|
||||
}
|
||||
|
||||
internal static string BuildCacheKey(
|
||||
CategoryGroup categoryGroup,
|
||||
ChangeCategory changeCategory,
|
||||
string path)
|
||||
{
|
||||
string result = string.Concat(changeCategory.Type, ":", path);
|
||||
|
||||
if (categoryGroup == null)
|
||||
return result;
|
||||
|
||||
return string.Concat(categoryGroup.GetHeaderText(), ":", result);
|
||||
}
|
||||
|
||||
internal static ChangeCategory GetChangeCategory(ClientDiffInfo diff)
|
||||
{
|
||||
return (ChangeCategory)diff.GetParent();
|
||||
}
|
||||
|
||||
internal static CategoryGroup GetCategoryGroup(ClientDiffInfo diff)
|
||||
{
|
||||
ChangeCategory changeCategory = GetChangeCategory(diff);
|
||||
|
||||
ITreeViewNode categoryGroup = changeCategory.GetParent();
|
||||
|
||||
if (categoryGroup == null)
|
||||
return null;
|
||||
|
||||
return (CategoryGroup)categoryGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e89b1e9e9f1060b4f817977507831248
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user