Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
            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);
            }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        internal ClientDiffTreeViewItem(
            int id, int depth, ClientDiffInfo diff)
            : base(id, depth)
        {
            Difference = diff;

            displayName = diff.PathString;
        }
Exemplo n.º 7
0
 internal static string ForMetaDiff(
     ClientDiffInfo diff)
 {
     return(BuildCacheKey(
                GetMergeCategory(diff),
                GetChangeCategory(diff),
                MetaPath.GetMetaPath(diff.DiffWithMount.Difference.Path)));
 }
Exemplo n.º 8
0
            internal ClientDiffInfo GetExistingMeta(ClientDiffInfo diff)
            {
                ClientDiffInfo result;

                if (!mCache.TryGetValue(BuildKey.ForMetaDiff(diff), out result))
                {
                    return(null);
                }

                return(result);
            }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        void IDiffTreeViewMenuOperations.Diff()
        {
            ClientDiffInfo clientDiffInfo =
                DiffSelection.GetSelectedDiff(mDiffTreeView);

            DiffOperation.DiffClientDiff(
                mWkInfo,
                clientDiffInfo.DiffWithMount.Mount.Mount,
                clientDiffInfo.DiffWithMount.Difference,
                xDiffLauncher: null,
                imageDiffLauncher: null);
        }
Exemplo n.º 11
0
                internal static MergeCategory GetMergeCategory(ClientDiffInfo diff)
                {
                    ChangeCategory changeCategory = GetChangeCategory(diff);

                    ITreeViewNode mergeCategory = changeCategory.GetParent();

                    if (mergeCategory == null)
                    {
                        return(null);
                    }

                    return((MergeCategory)mergeCategory);
                }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        internal bool SelectionHasMeta()
        {
            if (!HasSelection())
            {
                return(false);
            }

            ClientDiffInfo selectedDiff = GetSelectedDiffs(false)[0];

            if (selectedDiff == null)
            {
                return(false);
            }

            return(mDiffTree.HasMeta(selectedDiff));
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
            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);
                }
            }
Exemplo n.º 16
0
            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);
            }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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");
        }
Exemplo n.º 19
0
        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");
        }
Exemplo n.º 20
0
        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();
 }
Exemplo n.º 23
0
 internal ClientDiffInfo GetMetaDiff(ClientDiffInfo diff)
 {
     return(mDiffTree.GetMetaDiff(diff));
 }
Exemplo n.º 24
0
 internal bool ContainsMeta(ClientDiffInfo diff)
 {
     return(mCache.ContainsKey(
                BuildKey.ForMetaDiff(diff)));
 }
Exemplo n.º 25
0
 internal ClientDiffInfo GetMetaDiff(ClientDiffInfo diff)
 {
     return(mMetaCache.GetExistingMeta(diff));
 }
Exemplo n.º 26
0
 internal bool HasMeta(ClientDiffInfo difference)
 {
     return(mMetaCache.ContainsMeta(difference));
 }
Exemplo n.º 27
0
 internal static ChangeCategory GetChangeCategory(ClientDiffInfo diff)
 {
     return((ChangeCategory)diff.GetParent());
 }