public void TestMovedNoMeta() { ClientDiff moved = Build.Moved("/foo/bar.src.c", "/foo/bar.c"); List <ClientDiff> diffs = new List <ClientDiff>(); diffs.Add(moved); UnityDiffTree diffTree = new UnityDiffTree(); diffTree.BuildCategories(diffs, false); ClientDiffInfo clientDiffInfo = FindClientDiffInfo.FromClientDiff( moved, ChangeCategoryType.Moved, diffTree); Assert.IsNotNull( clientDiffInfo, "Moved not found"); Assert.IsFalse( diffTree.HasMeta(clientDiffInfo), "Meta exists"); }
public void TestFsPermissionsNoMeta() { ClientDiff changedFsPermissions = Build.ChangedFsPermissions("/foo/bar.c"); List <ClientDiff> diffs = new List <ClientDiff>(); diffs.Add(changedFsPermissions); UnityDiffTree diffTree = new UnityDiffTree(); diffTree.BuildCategories(diffs, false); ClientDiffInfo clientDiffInfo = FindClientDiffInfo.FromClientDiff( changedFsPermissions, ChangeCategoryType.FSProtection, diffTree); Assert.IsNotNull( clientDiffInfo, "Changed fs protection not found"); Assert.IsFalse( diffTree.HasMeta(clientDiffInfo), "Meta exists"); }
static ClientDiffInfo FindClientDiffOfType( string path, ChangeCategoryType type, ITreeViewNode node) { if (node is ClientDiffInfo) { ClientDiffInfo clientDiffInfo = (ClientDiffInfo)node; ChangeCategory category = (ChangeCategory)node.GetParent(); if (category.Type == type && clientDiffInfo.DiffWithMount.Difference.Path == path) { return((ClientDiffInfo)node); } } for (int i = 0; i < node.GetChildrenCount(); i++) { ClientDiffInfo result = FindClientDiffOfType(path, type, node.GetChild(i)); if (result != null) { return(result); } } return(null); }
void DiffTreeViewMenu.IMetaMenuOperations.DiffMeta() { if (LaunchTool.ShowDownloadPlasticExeWindow( mWkInfo, mIsGluonMode, TrackFeatureUseEvent.Features.InstallPlasticCloudFromDiffRevision, TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromDiffRevision, TrackFeatureUseEvent.Features.CancelPlasticInstallationFromDiffRevision)) { return; } ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); ClientDiffInfo clientDiffInfoMeta = mDiffTreeView.GetMetaDiff(clientDiffInfo); DiffOperation.DiffClientDiff( mWkInfo, clientDiffInfoMeta.DiffWithMount.Mount.Mount, clientDiffInfoMeta.DiffWithMount.Difference, xDiffLauncher: null, imageDiffLauncher: null); }
void IDiffTreeViewMenuOperations.SaveRevisionAs() { TrackFeatureUseEvent.For( PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo), TrackFeatureUseEvent.Features.SaveRevisionFromDiff); ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); RepositorySpec repSpec = clientDiffInfo.DiffWithMount.Mount.RepSpec; RevisionInfo revision = clientDiffInfo.DiffWithMount.Difference.RevInfo; string defaultFileName = DefaultRevisionName.Get( Path.GetFileName(clientDiffInfo.DiffWithMount.Difference.Path), revision.Changeset); string destinationPath = SaveAction.GetDestinationPath( mWkInfo.ClientPath, clientDiffInfo.DiffWithMount.Difference.Path, defaultFileName); if (string.IsNullOrEmpty(destinationPath)) { return; } SaveRevisionOperation.SaveRevision( repSpec, destinationPath, revision, mProgressControls); }
internal ClientDiffTreeViewItem( int id, int depth, ClientDiffInfo diff) : base(id, depth) { Difference = diff; displayName = diff.PathString; }
internal static string ForMetaDiff( ClientDiffInfo diff) { return(BuildCacheKey( GetMergeCategory(diff), GetChangeCategory(diff), MetaPath.GetMetaPath(diff.DiffWithMount.Difference.Path))); }
internal ClientDiffInfo GetExistingMeta(ClientDiffInfo diff) { ClientDiffInfo result; if (!mCache.TryGetValue(BuildKey.ForMetaDiff(diff), out result)) { return(null); } return(result); }
void IDiffTreeViewMenuOperations.History() { ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); mHistoryViewLauncher.ShowHistoryView( clientDiffInfo.DiffWithMount.Mount.RepSpec, clientDiffInfo.DiffWithMount.Difference.RevInfo.ItemId, clientDiffInfo.DiffWithMount.Difference.Path, clientDiffInfo.DiffWithMount.Difference.IsDirectory); }
void IDiffTreeViewMenuOperations.Diff() { ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); DiffOperation.DiffClientDiff( mWkInfo, clientDiffInfo.DiffWithMount.Mount.Mount, clientDiffInfo.DiffWithMount.Difference, xDiffLauncher: null, imageDiffLauncher: null); }
internal static MergeCategory GetMergeCategory(ClientDiffInfo diff) { ChangeCategory changeCategory = GetChangeCategory(diff); ITreeViewNode mergeCategory = changeCategory.GetParent(); if (mergeCategory == null) { return(null); } return((MergeCategory)mergeCategory); }
void DiffTreeViewMenu.IMetaMenuOperations.DiffMeta() { ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); ClientDiffInfo clientDiffInfoMeta = mDiffTreeView.GetMetaDiff(clientDiffInfo); DiffOperation.DiffClientDiff( mWkInfo, clientDiffInfoMeta.DiffWithMount.Mount.Mount, clientDiffInfoMeta.DiffWithMount.Difference, xDiffLauncher: null, imageDiffLauncher: null); }
internal bool SelectionHasMeta() { if (!HasSelection()) { return(false); } ClientDiffInfo selectedDiff = GetSelectedDiffs(false)[0]; if (selectedDiff == null) { return(false); } return(mDiffTree.HasMeta(selectedDiff)); }
void IDiffTreeViewMenuOperations.Diff() { if (LaunchTool.ShowDownloadPlasticExeWindow(mIsGluonMode)) { return; } ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); DiffOperation.DiffClientDiff( mWkInfo, clientDiffInfo.DiffWithMount.Mount.Mount, clientDiffInfo.DiffWithMount.Difference, xDiffLauncher: null, imageDiffLauncher: null); }
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 ClientDiffInfo FromClientDiff( ClientDiff clientDiff, ChangeCategoryType type, UnityDiffTree diffTree) { foreach (ITreeViewNode node in diffTree.GetNodes()) { ClientDiffInfo result = FindClientDiffOfType( clientDiff.Diff.Path, type, node); if (result != null) { return(result); } } return(null); }
void IDiffTreeViewMenuOperations.History() { if (LaunchTool.ShowDownloadPlasticExeWindow( mWkInfo, mIsGluonMode, TrackFeatureUseEvent.Features.InstallPlasticCloudFromShowHistory, TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromShowHistory, TrackFeatureUseEvent.Features.CancelPlasticInstallationFromShowHistory)) { return; } ClientDiffInfo clientDiffInfo = DiffSelection.GetSelectedDiff(mDiffTreeView); mHistoryViewLauncher.ShowHistoryView( clientDiffInfo.DiffWithMount.Mount.RepSpec, clientDiffInfo.DiffWithMount.Difference.RevInfo.ItemId, clientDiffInfo.DiffWithMount.Difference.Path, clientDiffInfo.DiffWithMount.Difference.IsDirectory); }
public void TestFsPermissionsWithMeta() { ClientDiff fsPermissionsChange = Build.ChangedFsPermissions("/foo/bar.c"); ClientDiff fsPermissionsChangeMeta = Build.ChangedFsPermissions("/foo/bar.c.meta"); List <ClientDiff> diffs = new List <ClientDiff>(); diffs.Add(fsPermissionsChange); diffs.Add(fsPermissionsChangeMeta); UnityDiffTree diffTree = new UnityDiffTree(); diffTree.BuildCategories(diffs, false); ClientDiffInfo clientDiffInfo = FindClientDiffInfo.FromClientDiff( fsPermissionsChange, ChangeCategoryType.FSProtection, diffTree); ClientDiffInfo clientDiffInfoMeta = FindClientDiffInfo.FromClientDiff( fsPermissionsChangeMeta, ChangeCategoryType.FSProtection, diffTree); Assert.IsNotNull( clientDiffInfo, "Change fs permissions not found"); Assert.IsNull( clientDiffInfoMeta, "Change fs permissions meta found"); Assert.IsTrue( diffTree.HasMeta(clientDiffInfo), "Meta does not exist"); }
public void TestMergedWithMeta() { ClientDiff merged = Build.Merged("/foo/bar.c"); ClientDiff mergedMeta = Build.Merged("/foo/bar.c.meta"); List <ClientDiff> diffs = new List <ClientDiff>(); diffs.Add(merged); diffs.Add(mergedMeta); UnityDiffTree diffTree = new UnityDiffTree(); diffTree.BuildCategories(diffs, false); ClientDiffInfo clientDiffInfo = FindClientDiffInfo.FromClientDiff( merged, ChangeCategoryType.Merged, diffTree); ClientDiffInfo clientDiffInfoMeta = FindClientDiffInfo.FromClientDiff( mergedMeta, ChangeCategoryType.Merged, diffTree); Assert.IsNotNull( clientDiffInfo, "Merged not found"); Assert.IsNull( clientDiffInfoMeta, "Merged meta found"); Assert.IsTrue( diffTree.HasMeta(clientDiffInfo), "Meta does not exist"); }
public void TestChangeWithDeletedMeta() { ClientDiff changed = Build.Changed("/foo/bar.c"); ClientDiff deletedMeta = Build.Deleted("/foo/bar.c.meta"); List <ClientDiff> diffs = new List <ClientDiff>(); diffs.Add(changed); diffs.Add(deletedMeta); UnityDiffTree diffTree = new UnityDiffTree(); diffTree.BuildCategories(diffs, false); ClientDiffInfo clientDiffInfo = FindClientDiffInfo.FromClientDiff( changed, ChangeCategoryType.Changed, diffTree); ClientDiffInfo clientDiffInfoMeta = FindClientDiffInfo.FromClientDiff( deletedMeta, ChangeCategoryType.Deleted, diffTree); Assert.IsNotNull( clientDiffInfo, "Changed not found"); Assert.IsNotNull( clientDiffInfoMeta, "Deleted meta not found"); Assert.IsFalse( diffTree.HasMeta(clientDiffInfo), "Meta exists"); }
void IPlasticAPI.UndeleteClientDiff(ClientDiffInfo diff, string restorePath) { throw new NotImplementedException(); }
void IPlasticAPI.RevertToClientDiffRevisions(WorkspaceInfo wkInfo, ClientDiffInfo clientDiff, WorkspaceTreeNode wkNode, string workspacePath) { throw new NotImplementedException(); }
internal ClientDiffInfo GetMetaDiff(ClientDiffInfo diff) { return(mDiffTree.GetMetaDiff(diff)); }
internal bool ContainsMeta(ClientDiffInfo diff) { return(mCache.ContainsKey( BuildKey.ForMetaDiff(diff))); }
internal ClientDiffInfo GetMetaDiff(ClientDiffInfo diff) { return(mMetaCache.GetExistingMeta(diff)); }
internal bool HasMeta(ClientDiffInfo difference) { return(mMetaCache.ContainsMeta(difference)); }
internal static ChangeCategory GetChangeCategory(ClientDiffInfo diff) { return((ChangeCategory)diff.GetParent()); }