test
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays
|
||||
{
|
||||
[Flags]
|
||||
internal enum AssetStatus
|
||||
{
|
||||
None = 0,
|
||||
Private = 1 << 0,
|
||||
Ignored = 1 << 2,
|
||||
Added = 1 << 3,
|
||||
Checkout = 1 << 4,
|
||||
Controlled = 1 << 5,
|
||||
UpToDate = 1 << 6,
|
||||
OutOfDate = 1 << 7,
|
||||
Conflicted = 1 << 8,
|
||||
DeletedOnServer = 1 << 9,
|
||||
Locked = 1 << 10,
|
||||
LockedRemote = 1 << 11,
|
||||
Retained = 1 << 12,
|
||||
HiddenChanged = 1 << 13,
|
||||
}
|
||||
|
||||
internal class LockStatusData
|
||||
{
|
||||
internal readonly AssetStatus Status;
|
||||
internal readonly string LockedBy;
|
||||
internal readonly string HolderBranchName;
|
||||
|
||||
internal LockStatusData(
|
||||
AssetStatus status,
|
||||
string lockedBy,
|
||||
string holderBranchName)
|
||||
{
|
||||
Status = status;
|
||||
LockedBy = lockedBy;
|
||||
HolderBranchName = holderBranchName;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ClassifyAssetStatus
|
||||
{
|
||||
internal static bool IsPrivate(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Private);
|
||||
}
|
||||
|
||||
internal static bool IsIgnored(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Ignored);
|
||||
}
|
||||
|
||||
internal static bool IsControlled(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Controlled);
|
||||
}
|
||||
|
||||
internal static bool IsLocked(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Locked);
|
||||
}
|
||||
|
||||
internal static bool IsLockedRemote(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.LockedRemote);
|
||||
}
|
||||
|
||||
internal static bool IsRetained(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Retained);
|
||||
}
|
||||
|
||||
internal static bool IsOutOfDate(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.OutOfDate);
|
||||
}
|
||||
|
||||
internal static bool IsDeletedOnServer(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.DeletedOnServer);
|
||||
}
|
||||
|
||||
internal static bool IsConflicted(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Conflicted);
|
||||
}
|
||||
|
||||
internal static bool IsAdded(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Added);
|
||||
}
|
||||
|
||||
internal static bool IsCheckedOut(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.Checkout);
|
||||
}
|
||||
|
||||
internal static bool IsHiddenChanged(AssetStatus status)
|
||||
{
|
||||
return ContainsAny(status, AssetStatus.HiddenChanged);
|
||||
}
|
||||
|
||||
static bool ContainsAny(AssetStatus status, AssetStatus matchTo)
|
||||
{
|
||||
return (status & matchTo) != AssetStatus.None;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 062535eac3e5dd1409b6a50b0d043e2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a94a55dca335c547ac65bd4b85d2a55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,63 @@
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays.Cache
|
||||
{
|
||||
internal interface IAssetStatusCache
|
||||
{
|
||||
AssetStatus GetStatus(string fullPath);
|
||||
LockStatusData GetLockStatusData(string fullPath);
|
||||
void Clear();
|
||||
}
|
||||
|
||||
internal class AssetStatusCache : IAssetStatusCache
|
||||
{
|
||||
internal AssetStatusCache(
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
mLocalStatusCache = new LocalStatusCache(wkInfo);
|
||||
|
||||
mRemoteStatusCache = new RemoteStatusCache(
|
||||
wkInfo,
|
||||
isGluonMode,
|
||||
ProjectWindow.Repaint,
|
||||
RepaintInspector.All);
|
||||
|
||||
mLockStatusCache = new LockStatusCache(
|
||||
wkInfo,
|
||||
ProjectWindow.Repaint,
|
||||
RepaintInspector.All);
|
||||
}
|
||||
|
||||
AssetStatus IAssetStatusCache.GetStatus(string fullPath)
|
||||
{
|
||||
AssetStatus localStatus = mLocalStatusCache.GetStatus(fullPath);
|
||||
|
||||
if (!ClassifyAssetStatus.IsControlled(localStatus))
|
||||
return localStatus;
|
||||
|
||||
AssetStatus remoteStatus = mRemoteStatusCache.GetStatus(fullPath);
|
||||
|
||||
AssetStatus lockStatus = mLockStatusCache.GetStatus(fullPath);
|
||||
|
||||
return localStatus | remoteStatus | lockStatus;
|
||||
}
|
||||
|
||||
LockStatusData IAssetStatusCache.GetLockStatusData(string fullPath)
|
||||
{
|
||||
return mLockStatusCache.GetLockStatusData(fullPath);
|
||||
}
|
||||
|
||||
void IAssetStatusCache.Clear()
|
||||
{
|
||||
mLocalStatusCache.Clear();
|
||||
mRemoteStatusCache.Clear();
|
||||
mLockStatusCache.Clear();
|
||||
}
|
||||
|
||||
readonly LocalStatusCache mLocalStatusCache;
|
||||
readonly RemoteStatusCache mRemoteStatusCache;
|
||||
readonly LockStatusCache mLockStatusCache;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f227b28cf424364489edd67fce697bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice.Utils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays.Cache
|
||||
{
|
||||
internal static class BuildPathDictionary
|
||||
{
|
||||
internal static Dictionary<string, T> ForPlatform<T>()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return new Dictionary<string, T>(
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
return new Dictionary<string, T>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c963b5d17c74314eb7105e71377cdb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice;
|
||||
using Codice.Client.BaseCommands;
|
||||
using Codice.Client.Commands.WkTree;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays.Cache
|
||||
{
|
||||
internal class LocalStatusCache
|
||||
{
|
||||
internal LocalStatusCache(WorkspaceInfo wkInfo)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
}
|
||||
|
||||
internal AssetStatus GetStatus(string fullPath)
|
||||
{
|
||||
AssetStatus result;
|
||||
|
||||
if (mStatusByPathCache.TryGetValue(fullPath, out result))
|
||||
return result;
|
||||
|
||||
result = CalculateStatus(
|
||||
fullPath,
|
||||
mWkInfo.ClientPath,
|
||||
FilterManager.Get().GetIgnoredFilter(),
|
||||
FilterManager.Get().GetHiddenChangesFilter());
|
||||
|
||||
mStatusByPathCache.Add(fullPath, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
mStatusByPathCache.Clear();
|
||||
}
|
||||
|
||||
static AssetStatus CalculateStatus(
|
||||
string fullPath,
|
||||
string wkPath,
|
||||
IgnoredFilesFilter ignoredFilter,
|
||||
HiddenChangesFilesFilter hiddenChangesFilter)
|
||||
{
|
||||
WorkspaceTreeNode treeNode = PlasticGui.Plastic.API.GetWorkspaceTreeNode(fullPath);
|
||||
|
||||
if (CheckWorkspaceTreeNodeStatus.IsPrivate(treeNode))
|
||||
{
|
||||
return ignoredFilter.IsIgnored(fullPath) ?
|
||||
AssetStatus.Ignored : AssetStatus.Private;
|
||||
}
|
||||
|
||||
if (CheckWorkspaceTreeNodeStatus.IsAdded(treeNode))
|
||||
return AssetStatus.Added;
|
||||
|
||||
AssetStatus result = AssetStatus.Controlled;
|
||||
|
||||
if (CheckWorkspaceTreeNodeStatus.IsCheckedOut(treeNode) &&
|
||||
!CheckWorkspaceTreeNodeStatus.IsDirectory(treeNode))
|
||||
result |= AssetStatus.Checkout;
|
||||
|
||||
if (hiddenChangesFilter.IsHiddenChanged(fullPath))
|
||||
result |= AssetStatus.HiddenChanged;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Dictionary<string, AssetStatus> mStatusByPathCache =
|
||||
BuildPathDictionary.ForPlatform<AssetStatus>();
|
||||
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 226459a134855504d841db6b61519d2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice;
|
||||
using Codice.Client.Commands;
|
||||
using Codice.Client.Commands.WkTree;
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Locks;
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.Client.Common.WkTree;
|
||||
using Codice.CM.Common;
|
||||
using Codice.CM.Common.Mount;
|
||||
using Codice.Utils;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
using PlasticGui.WorkspaceWindow.Items.Locks;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays.Cache
|
||||
{
|
||||
internal class LockStatusCache
|
||||
{
|
||||
internal LockStatusCache(
|
||||
WorkspaceInfo wkInfo,
|
||||
Action repaintProjectWindow,
|
||||
Action repaintInspector)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mRepaintProjectWindow = repaintProjectWindow;
|
||||
mRepaintInspector = repaintInspector;
|
||||
}
|
||||
|
||||
internal AssetStatus GetStatus(string fullPath)
|
||||
{
|
||||
LockStatusData lockStatusData = GetLockStatusData(fullPath);
|
||||
|
||||
if (lockStatusData == null)
|
||||
return AssetStatus.None;
|
||||
|
||||
return lockStatusData.Status;
|
||||
}
|
||||
|
||||
internal LockStatusData GetLockStatusData(string fullPath)
|
||||
{
|
||||
lock (mLock)
|
||||
{
|
||||
if (mStatusByPathCache == null)
|
||||
{
|
||||
mStatusByPathCache = BuildPathDictionary.ForPlatform<LockStatusData>();
|
||||
|
||||
mCurrentCancelToken.Cancel();
|
||||
mCurrentCancelToken = new CancelToken();
|
||||
AsyncCalculateStatus(mCurrentCancelToken);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
LockStatusData result;
|
||||
|
||||
if (mStatusByPathCache.TryGetValue(fullPath, out result))
|
||||
return result;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
lock (mLock)
|
||||
{
|
||||
mCurrentCancelToken.Cancel();
|
||||
|
||||
mStatusByPathCache = null;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncCalculateStatus(CancelToken cancelToken)
|
||||
{
|
||||
Dictionary<string, LockStatusData> statusByPathCache = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
Dictionary<MountPointWithPath, List<WorkspaceTreeNode>> lockCandidates =
|
||||
new Dictionary<MountPointWithPath, List<WorkspaceTreeNode>>();
|
||||
|
||||
FillLockCandidates.ForTree(mWkInfo, lockCandidates);
|
||||
|
||||
if (cancelToken.IsCancelled())
|
||||
return;
|
||||
|
||||
Dictionary<WorkspaceTreeNode, LockInfo> lockInfoByNode =
|
||||
SearchLocks.GetLocksInfo(mWkInfo, lockCandidates);
|
||||
|
||||
if (cancelToken.IsCancelled())
|
||||
return;
|
||||
|
||||
statusByPathCache = BuildStatusByNodeCache.
|
||||
ForLocks(mWkInfo.ClientPath, lockInfoByNode);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
ExceptionsHandler.LogException(
|
||||
"LockStatusCache",
|
||||
waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cancelToken.IsCancelled())
|
||||
return;
|
||||
|
||||
lock (mLock)
|
||||
{
|
||||
mStatusByPathCache = statusByPathCache;
|
||||
}
|
||||
|
||||
mRepaintProjectWindow();
|
||||
mRepaintInspector();
|
||||
});
|
||||
}
|
||||
|
||||
static class BuildStatusByNodeCache
|
||||
{
|
||||
internal static Dictionary<string, LockStatusData> ForLocks(
|
||||
string wkPath,
|
||||
Dictionary<WorkspaceTreeNode, LockInfo> lockInfoByNode)
|
||||
{
|
||||
Dictionary<string, LockStatusData> result =
|
||||
BuildPathDictionary.ForPlatform<LockStatusData>();
|
||||
|
||||
LockOwnerNameResolver nameResolver = new LockOwnerNameResolver();
|
||||
|
||||
foreach (WorkspaceTreeNode node in lockInfoByNode.Keys)
|
||||
{
|
||||
LockStatusData lockStatusData = BuildLockStatusData(
|
||||
node, lockInfoByNode[node], nameResolver);
|
||||
|
||||
string nodeWkPath = WorkspacePath.GetWorkspacePathFromCmPath(
|
||||
wkPath,
|
||||
WorkspaceNodeOperations.GetCmPath(node),
|
||||
PathHelper.GetDirectorySeparatorChar(wkPath));
|
||||
|
||||
result.Add(nodeWkPath, lockStatusData);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static LockStatusData BuildLockStatusData(
|
||||
WorkspaceTreeNode node,
|
||||
LockInfo lockInfo,
|
||||
LockOwnerNameResolver nameResolver)
|
||||
{
|
||||
return new LockStatusData(
|
||||
GetAssetStatus(node, lockInfo),
|
||||
nameResolver.GetSeidName(lockInfo.SEIDData),
|
||||
BranchInfoCache.GetProtectedBranchName(
|
||||
node.RepSpec, lockInfo.HolderBranchId));
|
||||
}
|
||||
|
||||
static AssetStatus GetAssetStatus(
|
||||
WorkspaceTreeNode node,
|
||||
LockInfo lockInfo)
|
||||
{
|
||||
if (lockInfo.Status == LockInfo.LockStatus.Retained)
|
||||
return AssetStatus.Retained;
|
||||
|
||||
return CheckWorkspaceTreeNodeStatus.IsCheckedOut(node) ?
|
||||
AssetStatus.Locked : AssetStatus.LockedRemote;
|
||||
}
|
||||
}
|
||||
|
||||
CancelToken mCurrentCancelToken = new CancelToken();
|
||||
|
||||
Dictionary<string, LockStatusData> mStatusByPathCache;
|
||||
|
||||
readonly Action mRepaintInspector;
|
||||
readonly Action mRepaintProjectWindow;
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
|
||||
static object mLock = new object();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 953c29d2e0dece647a64940343c91547
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice.Client.BaseCommands;
|
||||
using Codice.Client.Commands;
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.Client.GameUI;
|
||||
using Codice.Client.GameUI.Update;
|
||||
using Codice.CM.Common;
|
||||
using Codice.CM.Common.Merge;
|
||||
using Codice.CM.Common.Mount;
|
||||
using Codice.CM.Common.Partial;
|
||||
using Codice.CM.Common.Update.Partial;
|
||||
using Codice.Utils;
|
||||
using GluonGui.WorkspaceWindow.Views;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays.Cache
|
||||
{
|
||||
internal class RemoteStatusCache
|
||||
{
|
||||
internal RemoteStatusCache(
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode,
|
||||
Action repaintProjectWindow,
|
||||
Action repaintInspector)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mIsGluonMode = isGluonMode;
|
||||
mRepaintProjectWindow = repaintProjectWindow;
|
||||
mRepaintInspector = repaintInspector;
|
||||
}
|
||||
|
||||
internal AssetStatus GetStatus(string fullPath)
|
||||
{
|
||||
if (!mIsGluonMode)
|
||||
return AssetStatus.UpToDate;
|
||||
|
||||
lock(mLock)
|
||||
{
|
||||
if (mStatusByPathCache == null)
|
||||
{
|
||||
mStatusByPathCache = BuildPathDictionary.ForPlatform<AssetStatus>();
|
||||
|
||||
mCurrentCancelToken.Cancel();
|
||||
mCurrentCancelToken = new CancelToken();
|
||||
AsyncCalculateStatus(mCurrentCancelToken);
|
||||
|
||||
return AssetStatus.UpToDate;
|
||||
}
|
||||
|
||||
AssetStatus result;
|
||||
if (mStatusByPathCache.TryGetValue(fullPath, out result))
|
||||
return result;
|
||||
|
||||
return AssetStatus.UpToDate;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
lock (mLock)
|
||||
{
|
||||
mCurrentCancelToken.Cancel();
|
||||
mStatusByPathCache = null;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncCalculateStatus(CancelToken cancelToken)
|
||||
{
|
||||
Dictionary<string, AssetStatus> statusByPathCache = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
OutOfDateItems outOfDateItems =
|
||||
OutOfDateUpdater.CalculateOutOfDateItems(
|
||||
mWkInfo, new List<ErrorMessage>(),
|
||||
OutOfDateCalculator.Options.IsIncomingChanges);
|
||||
|
||||
if (cancelToken.IsCancelled())
|
||||
return;
|
||||
|
||||
statusByPathCache = BuildStatusByPathCache.
|
||||
ForOutOfDateItems(outOfDateItems, mWkInfo.ClientPath);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
ExceptionsHandler.LogException(
|
||||
"RemoteStatusCache",
|
||||
waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cancelToken.IsCancelled())
|
||||
return;
|
||||
|
||||
lock (mLock)
|
||||
{
|
||||
mStatusByPathCache = statusByPathCache;
|
||||
}
|
||||
|
||||
mRepaintProjectWindow();
|
||||
mRepaintInspector();
|
||||
});
|
||||
}
|
||||
|
||||
static class BuildStatusByPathCache
|
||||
{
|
||||
internal static Dictionary<string, AssetStatus> ForOutOfDateItems(
|
||||
OutOfDateItems outOfDateItems,
|
||||
string wkPath)
|
||||
{
|
||||
Dictionary<string, AssetStatus> result =
|
||||
BuildPathDictionary.ForPlatform<AssetStatus>();
|
||||
|
||||
if (outOfDateItems == null)
|
||||
return result;
|
||||
|
||||
foreach (OutOfDateItemsByMount diffs in
|
||||
outOfDateItems.GetOutOfDateItemsByMountList(PathHelper.GetPathSorter()))
|
||||
{
|
||||
foreach (Difference diff in diffs.Changed)
|
||||
{
|
||||
if (diff is DiffXlinkChanged)
|
||||
continue;
|
||||
|
||||
string path = GetPathForDiff(wkPath, diffs.Mount, diff.Path);
|
||||
result.Add(path, AssetStatus.OutOfDate);
|
||||
}
|
||||
|
||||
foreach (Difference diff in diffs.Deleted)
|
||||
{
|
||||
string path = GetPathForDiff(wkPath, diffs.Mount, diff.Path);
|
||||
result.Add(path, AssetStatus.DeletedOnServer);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GluonFileConflict fileConflict in
|
||||
outOfDateItems.GetFileConflicts())
|
||||
{
|
||||
string path = GetPathForConflict(wkPath, fileConflict.CmPath);
|
||||
result.Add(path, AssetStatus.Conflicted);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static string GetPathForDiff(
|
||||
string wkPath,
|
||||
MountPointWithPath mountPoint,
|
||||
string cmSubPath)
|
||||
{
|
||||
return WorkspacePath.GetWorkspacePathFromCmPath(
|
||||
wkPath,
|
||||
WorkspacePath.ComposeMountPath(mountPoint.MountPath, cmSubPath),
|
||||
PathHelper.GetDirectorySeparatorChar(wkPath));
|
||||
}
|
||||
|
||||
static string GetPathForConflict(
|
||||
string wkPath,
|
||||
string cmPath)
|
||||
{
|
||||
return WorkspacePath.GetWorkspacePathFromCmPath(
|
||||
wkPath, cmPath,
|
||||
PathHelper.GetDirectorySeparatorChar(wkPath));
|
||||
}
|
||||
}
|
||||
|
||||
CancelToken mCurrentCancelToken = new CancelToken();
|
||||
|
||||
Dictionary<string, AssetStatus> mStatusByPathCache;
|
||||
|
||||
readonly Action mRepaintInspector;
|
||||
readonly Action mRepaintProjectWindow;
|
||||
readonly bool mIsGluonMode;
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
|
||||
static object mLock = new object();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9acb575a60d7e045ad7fadd3e3e137d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.LogWrapper;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.AssetsOverlays
|
||||
{
|
||||
internal static class DrawAssetOverlay
|
||||
{
|
||||
internal static void Enable(
|
||||
string wkPath,
|
||||
IAssetStatusCache assetStatusCache)
|
||||
{
|
||||
if (mIsEnabled)
|
||||
return;
|
||||
|
||||
mLog.Debug("Enable");
|
||||
|
||||
mWkPath = wkPath;
|
||||
mAssetStatusCache = assetStatusCache;
|
||||
|
||||
mIsEnabled = true;
|
||||
|
||||
mRepaintProjectWindow = ProjectWindow.Repaint;
|
||||
|
||||
EditorApplication.projectWindowItemOnGUI += OnProjectWindowItemGUI;
|
||||
|
||||
mRepaintProjectWindow();
|
||||
}
|
||||
|
||||
internal static void Disable()
|
||||
{
|
||||
mLog.Debug("Disable");
|
||||
|
||||
mIsEnabled = false;
|
||||
|
||||
EditorApplication.projectWindowItemOnGUI -= OnProjectWindowItemGUI;
|
||||
|
||||
mRepaintProjectWindow();
|
||||
|
||||
mWkPath = null;
|
||||
mAssetStatusCache = null;
|
||||
}
|
||||
|
||||
internal static string GetStatusString(AssetStatus assetStatus)
|
||||
{
|
||||
if (ClassifyAssetStatus.IsPrivate(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.Private);
|
||||
|
||||
if (ClassifyAssetStatus.IsIgnored(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusIgnored);
|
||||
|
||||
if (ClassifyAssetStatus.IsAdded(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusAdded);
|
||||
|
||||
if (ClassifyAssetStatus.IsConflicted(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusConflicted);
|
||||
|
||||
if (ClassifyAssetStatus.IsDeletedOnServer(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusDeletedOnServer);
|
||||
|
||||
if (ClassifyAssetStatus.IsLockedRemote(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusLockedRemote);
|
||||
|
||||
if (ClassifyAssetStatus.IsOutOfDate(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusOutOfDate);
|
||||
|
||||
if (ClassifyAssetStatus.IsLocked(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusLockedByMe);
|
||||
|
||||
if (ClassifyAssetStatus.IsRetained(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusRetained);
|
||||
|
||||
if (ClassifyAssetStatus.IsCheckedOut(assetStatus))
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.StatusCheckout);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string GetTooltipText(
|
||||
AssetStatus statusValue,
|
||||
LockStatusData lockStatusData)
|
||||
{
|
||||
string statusText = GetStatusString(statusValue);
|
||||
|
||||
if (lockStatusData == null)
|
||||
return statusText;
|
||||
|
||||
// example:
|
||||
// Changed by:
|
||||
// * dani_pen@hotmail.com
|
||||
// * workspace wkLocal"
|
||||
|
||||
char bulletCharacter = '\u25cf';
|
||||
|
||||
string line1 = ClassifyAssetStatus.IsLocked(statusValue) ?
|
||||
statusText + ":" :
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.AssetOverlayTooltipStatus,
|
||||
statusText);
|
||||
|
||||
string line2 = string.Format("{0} {1}",
|
||||
bulletCharacter,
|
||||
lockStatusData.LockedBy);
|
||||
|
||||
string line3 = string.Format("{0} {1}",
|
||||
bulletCharacter,
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.AssetOverlayTooltipOn,
|
||||
lockStatusData.HolderBranchName));
|
||||
|
||||
return string.Format(
|
||||
"{0}" + Environment.NewLine +
|
||||
"{1}" + Environment.NewLine +
|
||||
"{2}",
|
||||
line1,
|
||||
line2,
|
||||
line3);
|
||||
}
|
||||
|
||||
static void OnProjectWindowItemGUI(string guid, Rect selectionRect)
|
||||
{
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
return;
|
||||
|
||||
if (Event.current.type != EventType.Repaint)
|
||||
return;
|
||||
|
||||
string fullPath = AssetsPath.GetFullPathUnderWorkspace.
|
||||
ForGuid(mWkPath, guid);
|
||||
|
||||
if (fullPath == null)
|
||||
return;
|
||||
|
||||
AssetStatus assetStatus = mAssetStatusCache.GetStatus(fullPath);
|
||||
|
||||
string tooltipText = GetTooltipText(
|
||||
assetStatus,
|
||||
mAssetStatusCache.GetLockStatusData(fullPath));
|
||||
|
||||
DrawOverlayIcon.ForStatus(
|
||||
selectionRect,
|
||||
assetStatus,
|
||||
tooltipText);
|
||||
}
|
||||
|
||||
internal static class DrawOverlayIcon
|
||||
{
|
||||
internal static void ForStatus(
|
||||
Rect selectionRect,
|
||||
AssetStatus status,
|
||||
string tooltipText)
|
||||
{
|
||||
Texture overlayIcon = GetOverlayIcon(status);
|
||||
|
||||
if (overlayIcon == null)
|
||||
return;
|
||||
|
||||
Rect overlayRect = OverlayRect.GetOverlayRect(
|
||||
selectionRect,
|
||||
OVERLAY_ICON_OFFSET);
|
||||
|
||||
GUI.DrawTexture(
|
||||
overlayRect, overlayIcon, ScaleMode.ScaleToFit);
|
||||
|
||||
Rect tooltipRect = GetTooltipRect(selectionRect, overlayRect);
|
||||
|
||||
GUI.Label(tooltipRect, new GUIContent(string.Empty, tooltipText));
|
||||
}
|
||||
|
||||
internal static Texture GetOverlayIcon(AssetStatus assetStatus)
|
||||
{
|
||||
if (ClassifyAssetStatus.IsPrivate(assetStatus))
|
||||
return Images.GetPrivatedOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsIgnored(assetStatus))
|
||||
return Images.GetIgnoredOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsAdded(assetStatus))
|
||||
return Images.GetAddedOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsConflicted(assetStatus))
|
||||
return Images.GetConflictedOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsDeletedOnServer(assetStatus))
|
||||
return Images.GetDeletedRemoteOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsLockedRemote(assetStatus))
|
||||
return Images.GetLockedRemoteOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsOutOfDate(assetStatus))
|
||||
return Images.GetOutOfSyncOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsLocked(assetStatus))
|
||||
return Images.GetLockedLocalOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsRetained(assetStatus))
|
||||
return Images.GetRetainedOverlayIcon();
|
||||
|
||||
if (ClassifyAssetStatus.IsCheckedOut(assetStatus))
|
||||
return Images.GetCheckedOutOverlayIcon();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Rect Inflate(Rect rect, float width, float height)
|
||||
{
|
||||
return new Rect(
|
||||
rect.x - width,
|
||||
rect.y - height,
|
||||
rect.width + 2f * width,
|
||||
rect.height + 2f * height);
|
||||
}
|
||||
|
||||
static Rect GetTooltipRect(
|
||||
Rect selectionRect,
|
||||
Rect overlayRect)
|
||||
{
|
||||
if (selectionRect.width > selectionRect.height)
|
||||
{
|
||||
return overlayRect;
|
||||
}
|
||||
|
||||
return Inflate(overlayRect, 3f, 3f);
|
||||
}
|
||||
}
|
||||
|
||||
static Action mRepaintProjectWindow;
|
||||
|
||||
static bool mIsEnabled;
|
||||
static IAssetStatusCache mAssetStatusCache;
|
||||
static string mWkPath;
|
||||
|
||||
const float OVERLAY_ICON_OFFSET = 20f;
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("DrawAssetOverlay");
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d30dfeb72257204458e1e8e1576b84ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user