Esempio n. 1
0
        public void TestGetDeletions()
        {
            StatusCache cache = new StatusCache();
            this.Client.Delete(Path.Combine( this.WcPath, "Class1.cs" ));
            this.Client.Delete(Path.Combine( this.WcPath, "WindowsApplication.sln" ));

            // should be two deletions now
            cache.Status(this.WcPath, SvnDepth.Infinity);
            IList deletions = cache.GetDeletions( this.WcPath );
            Assert.AreEqual( 2, deletions.Count );

            // undelete one
            this.Client.Revert(Path.Combine( this.WcPath, "Class1.cs" ));
            deletions = cache.GetDeletions( this.WcPath );
            Assert.AreEqual( 1, deletions.Count );

            // this one should still be deleted
            Assert.AreEqual( Path.Combine( this.WcPath, "WindowsApplication.sln" ),
                ((SvnItem)deletions[0]).Path);

            // undelete all
            SvnRevertArgs a = new SvnRevertArgs();
            a.Depth = SvnDepth.Infinity;
            this.Client.Revert(this.WcPath, a);
            deletions = cache.GetDeletions( this.WcPath );
            Assert.AreEqual( 0, deletions.Count );
        }
Esempio n. 2
0
        /// <summary>
        /// Called by ProjectDocumentTracker when a solution is closed
        /// </summary>
        protected override void OnSolutionClosed()
        {
            Debug.Assert(ProjectMap.ProjectCount == 0);
            Debug.Assert(ProjectMap.UniqueFileCount == 0);

            try
            {
                ProjectMap.Clear();
                _unreloadable.Clear();
                StatusCache.ClearCache();

                // Clear status for reopening solution
                _managedSolution = false;
                _isDirty         = false;
                Translate_ClearState();

                IPendingChangesManager mgr = GetService <IPendingChangesManager>();
                if (mgr != null)
                {
                    mgr.Clear();
                }
            }
            finally
            {
                base.OnSolutionClosed();
            }
        }
Esempio n. 3
0
        public void TestGetDeletions()
        {
            StatusCache cache = new StatusCache();

            this.Client.Delete(Path.Combine(this.WcPath, "Class1.cs"));
            this.Client.Delete(Path.Combine(this.WcPath, "WindowsApplication.sln"));

            // should be two deletions now
            cache.Status(this.WcPath, SvnDepth.Infinity);
            IList deletions = cache.GetDeletions(this.WcPath);

            Assert.AreEqual(2, deletions.Count);

            // undelete one
            this.Client.Revert(Path.Combine(this.WcPath, "Class1.cs"));
            deletions = cache.GetDeletions(this.WcPath);
            Assert.AreEqual(1, deletions.Count);

            // this one should still be deleted
            Assert.AreEqual(Path.Combine(this.WcPath, "WindowsApplication.sln"),
                            ((SvnItem)deletions[0]).Path);

            // undelete all
            SvnRevertArgs a = new SvnRevertArgs();

            a.Depth = SvnDepth.Infinity;
            this.Client.Revert(this.WcPath, a);
            deletions = cache.GetDeletions(this.WcPath);
            Assert.AreEqual(0, deletions.Count);
        }
        protected override void ExcludeItems(string projectFile, string[] itemNames)
        {
            List <string> changed = null;

            foreach (string item in itemNames)
            {
                if (!IsSafeSccPath(item))
                {
                    continue;
                }

                string path = SvnTools.GetNormalizedFullPath(item);

                if (!ProjectMap.IsSccExcluded(path))
                {
                    ProjectMap.SccExclude(path);

                    if (changed == null)
                    {
                        changed = new List <string>();
                    }
                    changed.Add(path);

                    StatusCache.SetSolutionContained(path, ProjectMap.ContainsFile(path), true);
                }
            }

            if (changed != null)
            {
                PendingChanges.Refresh(changed);
            }
        }
Esempio n. 5
0
        public void TestGetUnversionedItem()
        {
            StatusCache cache = new StatusCache();

            string  path = Path.GetTempFileName();
            SvnItem item = cache[path];

            Assert.IsFalse(item.IsVersionable);
        }
Esempio n. 6
0
        public void UpdateWCRoot()
        {
            if (IsDirectory && IsVersioned)
            {
                StatusCache.RefreshWCRoot(this);
                return;
            }

            SetState(SvnItemState.None, SvnItemState.IsWCRoot);
        }
Esempio n. 7
0
        public void TestGetPathNotInInitialStatus()
        {
            StatusCache cache = new StatusCache();
            cache.Status(Path.Combine(this.WcPath, "doc"), SvnDepth.Infinity);
            using( StreamWriter w = new StreamWriter(Path.Combine(this.WcPath, "Form1.cs")) )
                w.WriteLine( "Foo" );

            SvnItem item = cache[Path.Combine(this.WcPath, "Form1.cs")];
            Assert.AreEqual( SvnStatus.Modified, item.Status.LocalContentStatus );
        }
Esempio n. 8
0
        public async Task StatusCache_GetNonExistent_Test()
        {
            var logger      = CommonUtils.CreateLogger <StatusCache>();
            var cache       = CommonUtils.CreateMemoryCache();
            var statusCache = new StatusCache(cache, logger);

            var result = await statusCache.Get("1");

            result.ShouldNotBeNull();
            result.Id.ShouldBe("1");
            result.Status.ShouldBe(VehicleStatus.Unknown);
        }
Esempio n. 9
0
        public void TestGetPathNotInInitialStatus()
        {
            StatusCache cache = new StatusCache();

            cache.Status(Path.Combine(this.WcPath, "doc"), SvnDepth.Infinity);
            using (StreamWriter w = new StreamWriter(Path.Combine(this.WcPath, "Form1.cs")))
                w.WriteLine("Foo");

            SvnItem item = cache[Path.Combine(this.WcPath, "Form1.cs")];

            Assert.AreEqual(SvnStatus.Modified, item.Status.LocalContentStatus);
        }
        public async Task GetCachedModel()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            BlobAsyncDistributedCache <ResponseModel> dc = new BlobAsyncDistributedCache <ResponseModel>(
                config);

            StatusCache cache = new StatusCache(dc);

            ResponseModel model = await cache.GetAsync("999");
        }
Esempio n. 11
0
        public OverlayUiOperator Show <T>() where T : IOverlayUiCanvas
        {
            if (StatusCache <T> .Cache == null)
            {
                StatusCache <T> .SetCache(new OverlayUiStatus <T>(idGenerator));

                sceneLoader.Load <T>();
            }

            OverlayUiStatus <T> status = StatusCache <T> .Cache;

            return(status.GetChecker());
        }
Esempio n. 12
0
        public async Task StatusCache_UpdateGet_Test()
        {
            var logger      = CommonUtils.CreateLogger <StatusCache>();
            var cache       = CommonUtils.CreateMemoryCache();
            var statusCache = new StatusCache(cache, logger);

            await statusCache.Update("1", new VehicleStatusMessage("1", VehicleStatus.Connected));

            var result = await statusCache.Get("1");

            result.ShouldNotBeNull();
            result.Id.ShouldBe("1");
            result.Status.ShouldBe(VehicleStatus.Connected);
        }
Esempio n. 13
0
        protected override void RefreshCore(bool rescan)
        {
            if (SvnItem == null)
            {
                return;
            }

            if (rescan)
            {
                StatusCache.MarkDirtyRecursive(SvnItem.FullPath);
            }

            if (TreeNode != null)
            {
                TreeNode.Refresh();
            }
        }
        public async Task SetCachedModel()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            BlobAsyncDistributedCache <ResponseModel> dc = new BlobAsyncDistributedCache <ResponseModel>(
                config);

            StatusCache cache = new StatusCache(dc);

            ResponseModel model = new ResponseModel();

            model.Id      = "999";
            model.Percent = 50;

            await cache.SetAsync(model);
        }
Esempio n. 15
0
        public void TestVariousPathVariations()
        {
            StatusCache cache = new StatusCache();

            cache.Status(this.WcPath, SvnDepth.Infinity);

            string formPath = Path.Combine(this.WcPath, "Form1.cs");

            SvnItem item = cache[formPath];

            Assert.AreEqual(SvnStatus.Normal, item.Status.LocalContentStatus);

            item = cache[formPath.ToLower()];
            Assert.AreEqual(SvnStatus.Normal, item.Status.LocalContentStatus);

            item = cache[formPath.ToUpper()];
            Assert.AreEqual(SvnStatus.Normal, item.Status.LocalContentStatus);
        }
Esempio n. 16
0
 internal void RemovedFromSolution(string fullPath)
 {
     StatusCache.SetSolutionContained(fullPath, false, false);
     PendingChanges.Refresh(fullPath);
 }
Esempio n. 17
0
        public override void OnExecute(CommandEventArgs e)
        {
            HybridCollection <string> dirs = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

            foreach (SvnItem i in e.Selection.GetSelectedSvnItems(true))
            {
                SvnDirectory dir = i.ParentDirectory;
                if (dir != null && dir.NeedsWorkingCopyUpgrade && !dirs.Contains(dir.FullPath))
                {
                    dirs.Add(dir.FullPath);
                }
                else if (i.IsDirectory && i.AsDirectory().NeedsWorkingCopyUpgrade&& !dirs.Contains(i.FullPath))
                {
                    dirs.Add(i.FullPath);
                }
            }

            e.GetService <IProgressRunner>().RunModal(CommandStrings.UpgradingWorkingCopy,
                                                      delegate(object sender, ProgressWorkerArgs a)
            {
                HybridCollection <string> done = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
                foreach (string dir in dirs)
                {
                    SvnInfoArgs ia  = new SvnInfoArgs();
                    ia.ThrowOnError = false;

                    if (done.Contains(dir))
                    {
                        continue;
                    }

                    if (a.Client.Info(dir, ia, null) || ia.LastException.SvnErrorCode != SvnErrorCode.SVN_ERR_WC_UPGRADE_REQUIRED)
                    {
                        continue;
                    }

                    SvnUpgradeArgs ua = new SvnUpgradeArgs();
                    ua.ThrowOnError   = false;

                    /* Capture the already upgraded directories to avoid a lot of work */
                    ua.Notify += delegate(object sender2, SvnNotifyEventArgs n)
                    {
                        if (n.Action == SvnNotifyAction.UpgradedDirectory)
                        {
                            if (!done.Contains(n.FullPath))
                            {
                                done.Add(n.FullPath);
                            }
                        }
                    };

                    string tryDir = dir;
                    while (true)
                    {
                        if (a.Client.Upgrade(tryDir, ua) ||
                            ua.LastException.SvnErrorCode != SvnErrorCode.SVN_ERR_WC_INVALID_OP_ON_CWD)
                        {
                            break;
                        }

                        string pd = SvnTools.GetNormalizedDirectoryName(tryDir);

                        if (pd == tryDir || string.IsNullOrEmpty(pd))
                        {
                            break;
                        }

                        tryDir = pd;
                    }
                }
            });

            if (dirs.Count > 0)
            {
                StatusCache.ResetUpgradeWarning();
            }
        }
Esempio n. 18
0
 internal void AddedToSolution(string path)
 {
     // Force an initial status into the SvnItem
     StatusCache.SetSolutionContained(path, true, ProjectMap.IsSccExcluded(path));
 }
Esempio n. 19
0
        public void TestVariousPathVariations()
        {
            StatusCache cache = new StatusCache();
            cache.Status(this.WcPath, SvnDepth.Infinity);

            string formPath = Path.Combine(this.WcPath, "Form1.cs");

            SvnItem item = cache[formPath];
            Assert.AreEqual( SvnStatus.Normal, item.Status.LocalContentStatus );

            item = cache[formPath.ToLower()];
            Assert.AreEqual(SvnStatus.Normal, item.Status.LocalContentStatus);

            item = cache[formPath.ToUpper()];
            Assert.AreEqual(SvnStatus.Normal, item.Status.LocalContentStatus);
        }
Esempio n. 20
0
        public void TestGetUnversionedItem()
        {
            StatusCache cache = new StatusCache();

            string path = Path.GetTempFileName();
            SvnItem item = cache[path];
            Assert.IsFalse( item.IsVersionable );
        }