internal void Build(List <string> paths) { HashSet <string> indexedKeys = BuildIndexedKeys(paths); for (int i = paths.Count - 1; i >= 0; i--) { string currentPath = paths[i]; if (!MetaPath.IsMetaPath(currentPath)) { continue; } string realPath = MetaPath.GetPathFromMetaPath(currentPath); if (!indexedKeys.Contains(realPath)) { continue; } // found foo.c and foo.c.meta // with the same chage types - move .meta to cache mCache.Add(currentPath); paths.RemoveAt(i); } }
static bool IsOpenForEdit(string assetPath, out string message) { message = string.Empty; if (!IsEnabled) { return(true); } if (assetPath.StartsWith("ProjectSettings/")) { return(true); } if (ForceCheckout) { return(true); } if (MetaPath.IsMetaPath(assetPath)) { assetPath = MetaPath.GetPathFromMetaPath(assetPath); } AssetStatus status = mAssetStatusCache.GetStatusForPath( Path.GetFullPath(assetPath)); if (ClassifyAssetStatus.IsAdded(status) || ClassifyAssetStatus.IsCheckedOut(status)) { return(true); } return(!ClassifyAssetStatus.IsControlled(status)); }
static void ExtractMetaToCache( List <ChangeInfo> changes, Dictionary <string, ChangeInfo> cache) { HashSet <string> indexedKeys = BuildIndexedKeys(changes); for (int i = changes.Count - 1; i >= 0; i--) { ChangeInfo currentChange = changes[i]; if (!MetaPath.IsMetaPath(currentChange.Path)) { continue; } string realPath = MetaPath.GetPathFromMetaPath(currentChange.Path); if (!indexedKeys.Contains(BuildKey.BuildCacheKey( currentChange.ChangeTypes, realPath))) { continue; } // found foo.c and foo.c.meta // with the same chage types - move .meta to cache cache.Add(BuildKey.ForChange(currentChange), currentChange); changes.RemoveAt(i); } }
internal static void MoveOnSourceControl(string srcPath, string dstPath) { mLog.DebugFormat("MoveOnSourceControl: {0} to {1}", srcPath, dstPath); try { string srcFullPath = Path.GetFullPath(srcPath); string dstFullPath = Path.GetFullPath(dstPath); MoveIfControlled( srcFullPath, dstFullPath, mPlasticAPI); MoveIfControlled( MetaPath.GetMetaPath(srcFullPath), MetaPath.GetMetaPath(dstFullPath), mPlasticAPI); } catch (Exception ex) { LogMoveException(srcPath, dstPath, ex); } finally { mCooldownAutorefreshAction.Ping(); } }
internal static void DeleteFromSourceControl(string path) { mLog.DebugFormat("DeleteFromSourceControl: {0}", path); try { string fullPath = Path.GetFullPath(path); DeleteIfControlled( fullPath, mPlasticAPI); DeleteIfControlled( MetaPath.GetMetaPath(fullPath), mPlasticAPI); } catch (Exception ex) { LogDeleteException(path, ex); } finally { mCooldownAutorefreshAction.Ping(); } }
static void ExtractMetaToCache( MergeChangesCategory category, Dictionary <string, MergeChangeInfo> cache) { List <MergeChangeInfo> changes = category.GetChanges(); HashSet <string> indexedKeys = BuildIndexedKeys( changes); for (int i = changes.Count - 1; i >= 0; i--) { MergeChangeInfo currentChange = changes[i]; string path = currentChange.GetPath(); if (!MetaPath.IsMetaPath(path)) { continue; } string realPath = MetaPath.GetPathFromMetaPath(path); if (!indexedKeys.Contains(BuildKey.BuildCacheKey( currentChange.CategoryType, realPath))) { continue; } // found foo.c and foo.c.meta - move .meta to cache cache.Add(BuildKey.ForChange(currentChange), currentChange); changes.RemoveAt(i); } }
internal static string ForMetaChange( MergeChangeInfo change) { return(BuildCacheKey( change.CategoryType, MetaPath.GetMetaPath(change.GetPath()))); }
static void CheckoutIfControlled(string[] paths, IPlasticAPI api) { List <string> fullPaths = new List <string>(); foreach (string path in paths) { string fullPath = Path.GetFullPath(path); string fullPathMeta = MetaPath.GetMetaPath(fullPath); if (api.GetWorkspaceTreeNode(fullPath) != null) { fullPaths.Add(fullPath); } if (api.GetWorkspaceTreeNode(fullPathMeta) != null) { fullPaths.Add(fullPathMeta); } } if (fullPaths.Count == 0) { return; } api.Checkout( fullPaths.ToArray(), CheckoutModifiers.None); }
internal static string ForMetaDiff( ClientDiffInfo diff) { return(BuildCacheKey( GetMergeCategory(diff), GetChangeCategory(diff), MetaPath.GetMetaPath(diff.DiffWithMount.Difference.Path))); }
internal static UnityEngine.Object FromChangeInfo(ChangeInfo changeInfo) { string changeFullPath = changeInfo.GetFullPath(); if (MetaPath.IsMetaPath(changeFullPath)) { changeFullPath = MetaPath.GetPathFromMetaPath(changeFullPath); } return(FromFullPath(changeFullPath)); }
static AssetStatus GetAssetStatus(Asset asset, IAssetStatusCache assetStatusCache) { string assetPath = Path.GetFullPath(asset.assetPath); if (MetaPath.IsMetaPath(assetPath)) { assetPath = MetaPath.GetPathFromMetaPath(assetPath); } return(assetStatusCache.GetStatusForPath(assetPath)); }
static HashSet<string> BuildIndexedKeys(List<string> paths) { HashSet<string> result = new HashSet<string>(); foreach (string path in paths) { if (MetaPath.IsMetaPath(path)) continue; result.Add(path); } return result; }
internal List<string> GetExistingMeta(List<string> paths) { List<string> result = new List<string>(); foreach (string path in paths) { string metaPath = MetaPath.GetMetaPath(path); if (!mCache.Contains(metaPath)) continue; result.Add(metaPath); } return result; }
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); }
void DoFileList( WorkspaceInfo wkInfo, List <string> paths, IAssetStatusCache assetStatusCache, MetaCache metaCache) { mFileListScrollPosition = GUILayout.BeginScrollView( mFileListScrollPosition, EditorStyles.helpBox, GUILayout.ExpandHeight(true)); foreach (string path in paths) { if (MetaPath.IsMetaPath(path)) { continue; } Texture fileIcon = Directory.Exists(path) ? Images.GetDirectoryIcon() : Images.GetFileIcon(path); string label = WorkspacePath.GetWorkspaceRelativePath( wkInfo.ClientPath, path); if (metaCache.HasMeta(path)) { label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL); } GUIContent content = new GUIContent( label, fileIcon); GUILayout.Label( content, GUILayout.Height(UnityConstants.TREEVIEW_ROW_HEIGHT)); Rect iconRect = GUILayoutUtility.GetLastRect(); DoStatusOverlays( iconRect, assetStatusCache, path); } GUILayout.EndScrollView(); }
static HashSet <string> BuildIndexedKeys( List <MergeChangeInfo> changes) { HashSet <string> result = new HashSet <string>(); foreach (MergeChangeInfo change in changes) { if (MetaPath.IsMetaPath(change.GetPath())) { continue; } result.Add(BuildKey.ForChange(change)); } return(result); }
static HashSet <string> BuildIndexedPathsForChanges( List <IncomingChangeInfo> changes) { HashSet <string> result = new HashSet <string>(); foreach (IncomingChangeInfo change in changes) { if (MetaPath.IsMetaPath(change.GetPath())) { continue; } result.Add(change.GetPath()); } return(result); }
static void AddIfNotControlled( string[] paths, IPlasticAPI api) { List <string> fullPaths = new List <string>(); IgnoredFilesFilter ignoredFilter = new IgnoredFilesFilter( GlobalConfig.Instance); foreach (string path in paths) { string fullPath = Path.GetFullPath(path); string fullPathMeta = MetaPath.GetMetaPath(fullPath); if (api.GetWorkspaceFromPath(fullPath) == null) { return; } if (api.GetWorkspaceTreeNode(fullPath) == null && !ignoredFilter.IsIgnored(fullPath)) { fullPaths.Add(fullPath); } if (File.Exists(fullPathMeta) && api.GetWorkspaceTreeNode(fullPathMeta) == null && !ignoredFilter.IsIgnored(fullPath)) { fullPaths.Add(fullPathMeta); } } if (fullPaths.Count == 0) { return; } IList checkouts; api.Add( fullPaths.ToArray(), GetDefaultAddOptions(), out checkouts); }
void ResolveDirectoryConflict(IncomingChangeInfo conflict) { ConflictResolutionState state; if (!mConflictResolutionStates.TryGetValue(conflict.DirectoryConflict, out state)) { return; } List <DirectoryConflictResolutionData> conflictResolutions = new List <DirectoryConflictResolutionData>(); AddConflictResolution( conflict, state.ResolveAction, state.RenameValue, conflictResolutions); IncomingChangeInfo metaConflict = mIncomingChangesTreeView.GetMetaChange(conflict); if (metaConflict != null) { AddConflictResolution( metaConflict, state.ResolveAction, MetaPath.GetMetaPath(state.RenameValue), conflictResolutions); } if (state.IsApplyActionsForNextConflictsChecked) { foreach (IncomingChangeInfo otherConflict in mIncomingChangesTreeView.GetSelectedIncomingChanges()) { AddConflictResolution( otherConflict, state.ResolveAction, state.RenameValue, conflictResolutions); } } mMergeViewLogic.ResolveDirectoryConflicts(conflictResolutions); }
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.GetMergeCategory(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); } }
internal static List<string> GetSelectedMetaPaths( PendingChangesTreeView treeView) { List<ChangeInfo> selectedChanges = PendingChangesSelection .GetSelectedChanges(treeView); List<string> result = new List<string>(); foreach (ChangeInfo change in selectedChanges) { string path = change.GetFullPath(); if (!MetaPath.IsMetaPath(path)) continue; result.Add(path); } return result; }
internal static List <string> ForOperation( IAssetSelection assetSelection, IAssetStatusCache assetStatusCache, AssetMenuOperations operation) { List <string> selectedPaths = AssetsSelection.GetSelectedPaths( assetSelection.GetSelectedAssets()); List <string> result = new List <string>(selectedPaths); foreach (string path in selectedPaths) { if (MetaPath.IsMetaPath(path)) { continue; } string metaPath = MetaPath.GetMetaPath(path); if (!File.Exists(metaPath)) { continue; } if (result.Contains(metaPath)) { continue; } if (!IsApplicableForOperation( metaPath, false, operation, assetStatusCache)) { continue; } result.Add(metaPath); } return(result); }
void DoFileList( WorkspaceInfo wkInfo, List <string> paths, IAssetStatusCache assetStatusCache, MetaCache metaCache) { mFileListScrollPosition = GUILayout.BeginScrollView( mFileListScrollPosition, EditorStyles.helpBox, GUILayout.ExpandHeight(true)); foreach (string path in paths) { if (MetaPath.IsMetaPath(path)) { continue; } Texture fileIcon = Directory.Exists(path) ? Images.GetDirectoryIcon() : Images.GetFileIcon(path); string label = WorkspacePath.GetWorkspaceRelativePath( wkInfo.ClientPath, path); if (metaCache.HasMeta(path)) { label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL); } AssetsOverlays.AssetStatus assetStatus = assetStatusCache.GetStatusForPath(path); Rect selectionRect = EditorGUILayout.GetControlRect(); DoListViewItem(selectionRect, fileIcon, label, assetStatus); } GUILayout.EndScrollView(); }
static void CheckoutIfControlledAndChanged(string[] paths, IPlasticAPI api) { List <string> fullPaths = new List <string>(); foreach (string path in paths) { string fullPath = Path.GetFullPath(path); string fullPathMeta = MetaPath.GetMetaPath(fullPath); WorkspaceTreeNode node = api.GetWorkspaceTreeNode(fullPath); WorkspaceTreeNode nodeMeta = api.GetWorkspaceTreeNode(fullPathMeta); if (node != null && ChangedFileChecker.IsChanged( node.LocalInfo, fullPath, false)) { fullPaths.Add(fullPath); } if (nodeMeta != null && ChangedFileChecker.IsChanged( nodeMeta.LocalInfo, fullPathMeta, false)) { fullPaths.Add(fullPathMeta); } } if (fullPaths.Count == 0) { return; } api.Checkout( fullPaths.ToArray(), CheckoutModifiers.None); }
internal static string ForMetaChange(ChangeInfo change) { return(BuildCacheKey( change.ChangeTypes, MetaPath.GetMetaPath(change.Path))); }
internal bool HasMeta(string path) { return mCache.Contains(MetaPath.GetMetaPath(path)); }