Exemplo n.º 1
0
        public void Copy_ReposCopy()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = sbox.CreateRepository(SandBoxRepository.Default);
            Uri        trunk    = new Uri(reposUri, "trunk/");
            Uri        branch   = new Uri(reposUri, "my-branches/new-branch");

            SvnCopyArgs ca = new SvnCopyArgs();

            ca.LogMessage    = "Message";
            ca.CreateParents = true;
            Client.RemoteCopy(trunk, branch, ca);

            int n = 0;

            Client.List(branch, delegate(object sender, SvnListEventArgs e)
            {
                if (e.Entry.NodeKind == SvnNodeKind.File)
                {
                    n++;
                }
            });

            Assert.That(n, Is.GreaterThan(0), "Copied files");
        }
Exemplo n.º 2
0
        public void Lock_CommitTest()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string wc1   = sbox.Wc;
            string wc2   = sbox.GetTempDir("WC2");
            Uri    repos = new Uri(CollabReposUri, "trunk/");

            Client.CheckOut(repos, wc1);
            Client.CheckOut(repos, wc2);

            string index1 = Path.Combine(wc1, "index.html");
            string index2 = Path.Combine(wc2, "index.html");

            Client.Lock(index1, "q!");
            File.WriteAllText(index2, "QQQQQ");

            try
            {
                Client.Commit(index2);

                Assert.Fail("Commit should have failed");
            }
            catch (SvnException e)
            {
                Assert.That(e.GetCause <SvnFileSystemLockException>(), Is.Not.Null, "Caused by lock error");
            }
        }
Exemplo n.º 3
0
        public void TestHasBinaryProp()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            SvnWorkingCopyState     state;
            SvnWorkingCopyStateArgs a = new SvnWorkingCopyStateArgs();

            a.RetrieveFileData = true;

            SvnWorkingCopyClient wcc = new SvnWorkingCopyClient();

            wcc.GetState(Path.Combine(WcPath, "Form.cs"), out state);

            // first on a file
            Assert.That(state.IsTextFile);

            wcc.GetState(Path.Combine(WcPath, "App.ico"), out state);

            Assert.That(state.IsTextFile, Is.False);


            wcc.GetState(WcPath, out state);

            // check what happens for a dir
            //Assert.IsFalse(state.IsTextFile);
        }
Exemplo n.º 4
0
        public void UpdateInUse()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk"), 1), dir);

            using (File.OpenRead(Path.Combine(dir, "index.html")))
                using (new Implementation.SvnFsOperationRetryOverride(0))
                {
                    SvnSystemException se = null;
                    try
                    {
                        Client.Update(Path.Combine(dir, "index.html"));
                        Assert.Fail("Should have failed");
                    }
                    catch (SvnWorkingCopyException e)
                    {
                        Assert.That(e.Message, Does.StartWith("Failed to run the WC DB"));
                        se = e.GetCause <SvnSystemException>();
                    }


                    Assert.That(se, Is.Not.Null, "Have system exception");
                    Assert.That(se.Message, Does.Contain("Can't move"));
                }
        }
Exemplo n.º 5
0
        public void ChangeInfo_GetInfo12()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs      ia = new SvnChangeInfoArgs();

                SvnLookOrigin origin = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath, 12);
                //ia.RetrieveChangedPaths = false; // Will fail if true

                Assert.That(cl.GetChangeInfo(origin, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(12L));
                Assert.That(r.BaseRevision, Is.EqualTo(11L));
                Assert.That(r.LogMessage, Is.EqualTo("Merge branch a - product roadmap"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 2, 26, 567, DateTimeKind.Utc).AddTicks(6830);

                Assert.That(r.Time, Is.EqualTo(shouldBe));
            }
        }
Exemplo n.º 6
0
        public void Commit_CommitWithNonAnsiCharsInLogMessage()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string filepath = Path.Combine(WcPath, "Form.cs");

            using (StreamWriter w = new StreamWriter(filepath))
                w.Write("Moo");

            SvnCommitArgs a = new SvnCommitArgs();

            a.LogMessage = " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯";

            Assert.That(Client.Commit(WcPath, a));

            SvnLogArgs la = new SvnLogArgs();

            la.Start = SvnRevision.Head;
            la.End   = SvnRevision.Head;

            Collection <SvnLogEventArgs> logList;

            Client.GetLog(WcPath, la, out logList);

            Assert.That(logList, Is.Not.Null);
            Assert.That(logList.Count, Is.EqualTo(1));
            Assert.That(logList[0].LogMessage, Is.EqualTo(a.LogMessage));
        }
Exemplo n.º 7
0
        public void TestChangeAdministrativeDirectoryName()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);

            string       newAdminDir = "_svn";
            PropertyInfo pi          = typeof(SvnClient).GetProperty("AdministrativeDirectoryName", BindingFlags.SetProperty | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

            Assert.That(pi, Is.Not.Null);

            pi.SetValue(null, newAdminDir, null);
            try
            {
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(newAdminDir),
                            "Admin directory name should now be " + newAdminDir);

                string newwc = sbox.GetTempDir();
                this.Client.CheckOut(sbox.RepositoryUri, newwc);

                Assert.That(Directory.Exists(Path.Combine(newwc, newAdminDir)),
                            "Admin directory with new name not found");

                Assert.That(Directory.Exists(Path.Combine(newwc, ".svn")), Is.False,
                            "Admin directory with old name found");
            }
            finally
            {
                pi.SetValue(null, ".svn", null);
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(".svn"), "Settings original admin dir failed");
            }
        }
Exemplo n.º 8
0
        public void CreateDirectory_CreateTrunk()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty);

            using (SvnClient client = NewSvnClient(true, false))
            {
                Uri trunkUri = new Uri(ReposUrl, "trunk/");
                client.RemoteCreateDirectory(trunkUri);

                string trunkPath = sbox.Wc;

                client.CheckOut(trunkUri, trunkPath);

                TouchFile(Path.Combine(trunkPath, "test.txt"));

                Assert.That(SvnTools.IsManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(Path.Combine(trunkPath, "q/r/s/t/u/v/test.txt")));

                client.Add(Path.Combine(trunkPath, "test.txt"));

                Directory.CreateDirectory(Path.Combine(trunkPath, "dir"));
                TouchFile(Path.Combine(trunkPath, "dir/test.txt"));

                SvnAddArgs aa = new SvnAddArgs();
                aa.AddParents = true;
                client.Add(Path.Combine(trunkPath, "dir/test.txt"), aa);

                client.Commit(trunkPath);

                client.RemoteDelete(trunkUri, new SvnDeleteArgs());
            }
        }
Exemplo n.º 9
0
        public void Delete_AllFiles()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);
            Uri uri = sbox.RepositoryUri;
            string wc = sbox.Wc;

            for (int i = 0; i < 10; i++)
            {
                string file = Path.Combine(wc, string.Format("file{0}.txt", i));

                File.WriteAllText(file, "");

                Client.Add(file);
            }
            SvnCommitArgs ca = new SvnCommitArgs();
            ca.LogMessage = "Message";
            Client.Commit(wc, ca);

            foreach (FileInfo f in new DirectoryInfo(wc).GetFiles())
            {
                Client.Delete(f.FullName);
            }

            Client.Commit(wc, ca);
            Client.Update(wc);

            foreach (FileInfo f in new DirectoryInfo(wc).GetFiles())
            {
                Assert.That(false, "No files should exist at this point");
            }
        }
Exemplo n.º 10
0
        public void Resolve_RepeatedEventHookUp_SOC_411()
        {
            SvnSandBox sbox        = new SvnSandBox(this);
            Uri        projectRoot = new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/scripts");

            using (var svnClient = NewSvnClient(false, false))
            {
                for (int i = 0; i < 3; i++)
                {
                    string workingcopy = sbox.GetTempDir();
                    Directory.CreateDirectory(workingcopy);

                    svnClient.Authentication.UserNamePasswordHandlers += DoNowt;
                    try
                    {
                        SvnUpdateResult svnUpdateResult;
                        SvnCheckOutArgs ca = new SvnCheckOutArgs()
                        {
                            Depth = SvnDepth.Files
                        };
                        Assert.IsTrue(svnClient.CheckOut(projectRoot, workingcopy, ca, out svnUpdateResult));
                        Assert.IsNotNull(svnUpdateResult);
                        Assert.IsTrue(svnUpdateResult.HasRevision);
                    }
                    finally
                    {
                        svnClient.Authentication.UserNamePasswordHandlers -= DoNowt;
                    }
                }
            }
        }
Exemplo n.º 11
0
        public void Commit_CanceledCommit()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string path = Path.Combine(WcPath, "Form.cs");
            string path2 = Path.Combine(WcPath, "Form2.cs");
            File.WriteAllText(path, "MOO");
            File.WriteAllText(path2, "MOO2");
            Client.Add(path2);

            this.Client.Committing += delegate(object sender, SvnCommittingEventArgs e)
            {
                e.LogMessage = null;
                e.Cancel = true;
            };

            SvnCommitResult info;
            SvnCommitArgs a = new SvnCommitArgs();
            a.ThrowOnCancel = false;
            a.RunTortoiseHooks = true;

            Assert.That(this.Client.Commit(new string[] { path, path2 }, a, out info), Is.False);

            Assert.That(info, Is.Null, "info should be Invalid for a canceled commit");

            Collection<SvnStatusEventArgs> statee;
            Client.GetStatus(path, out statee);
            Assert.That(statee.Count, Is.EqualTo(1));
            Assert.That(statee[0].LocalNodeStatus, Is.EqualTo(SvnStatus.Modified), "File committed even for a canceled log message");
        }
Exemplo n.º 12
0
        public void Dump_DumpDb()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string repos = sbox.GetTempDir();

            using (SvnRepositoryClient cl = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs ra = new SvnCreateRepositoryArgs();
                ra.RepositoryType = SvnRepositoryFileSystem.BerkeleyDB;
                ra.RepositoryCompatibility = SvnRepositoryCompatibility.Subversion10;

                cl.CreateRepository(repos, ra);

                string file = GetTempFile();
                using(FileStream s = File.Create(file))
                {
                    SvnDumpRepositoryArgs da = new SvnDumpRepositoryArgs();
                    da.Start = new SvnRevision(0);
                    da.End = new SvnRevision(SvnRevisionType.Head);
                    cl.DumpRepository(repos, s, da);
                }

                Assert.That(new FileInfo(file).Length, Is.GreaterThan(12));
            }
        }
Exemplo n.º 13
0
        public void Blame_TestMore()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string reposPath = sbox.CreateRepository(SandBoxRepository.MergeScenario).AbsolutePath;
            Uri reposUri = SvnTools.LocalPathToUri(reposPath, true);

            Uri uri = new Uri(reposUri, "trunk/index.html");

            int n = 0;
            SvnBlameArgs ba = new SvnBlameArgs();
            ba.Notify += delegate(object sender, SvnNotifyEventArgs e)
            {
                Assert.That(e.Uri, Is.EqualTo(uri));
                Assert.That(e.RevisionProperties, Is.Not.Null);
                n++;
            };

            int lines = 0;
            Client.Blame(uri, ba,
            delegate(object sender, SvnBlameEventArgs e)
            {
                Assert.That(e.Author, Is.Not.Null);
                Assert.That(e.RevisionProperties, Is.Not.Null);
                Assert.That(e.RevisionProperties.Contains(SvnPropertyNames.SvnAuthor));
                Assert.That(e.RevisionProperties.Contains(SvnPropertyNames.SvnLog));
                Assert.That(e.RevisionProperties[SvnPropertyNames.SvnAuthor].StringValue, Is.Not.Null);
                Assert.That(e.RevisionProperties[SvnPropertyNames.SvnLog].StringValue, Is.Not.Null);
                Assert.That(e.MergedAuthor, Is.Null);
                Assert.That(e.MergedRevisionProperties, Is.Null);
                lines++;
            });

            Assert.That(n, Is.EqualTo(3));
            Assert.That(lines, Is.EqualTo(32));
        }
Exemplo n.º 14
0
        public void IsBelowAdmin()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string dir = sbox.GetTempDir();

            Assert.That(!SvnTools.IsBelowManagedPath(dir), "Temp is not managed");

            string sd = Path.Combine(dir, "w");
            Directory.CreateDirectory(sd);

            Assert.That(!SvnTools.IsBelowManagedPath(sd), "sd not managed");

            string sdsvn = Path.Combine(sd, ".svn");
            Directory.CreateDirectory(sdsvn);

            Assert.That(SvnTools.IsBelowManagedPath(sd), "sd managed");
            Assert.That(!SvnTools.IsBelowManagedPath(sdsvn), "sdsvn not managed");

            string format = Path.Combine(sdsvn, "format");
            File.WriteAllText(format, "-1");
            Assert.That(!SvnTools.IsBelowManagedPath(format), "format not managed");

            string sdsvnsvn = Path.Combine(sd, ".svn");
            Directory.CreateDirectory(sdsvnsvn);
            Assert.That(!SvnTools.IsBelowManagedPath(format), "format not managed");

            string sdsvnd = Path.Combine(sdsvn, "d");
            Directory.CreateDirectory(sdsvnd);
            Assert.That(!SvnTools.IsBelowManagedPath(sdsvnd), "d not managed");
            Directory.CreateDirectory(Path.Combine(sdsvnd, ".svn"));
            Assert.That(SvnTools.IsBelowManagedPath(sdsvnd), "d managed");
        }
Exemplo n.º 15
0
        public void Log_LogFromFile()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            Uri        repos = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.CheckOut(new Uri(repos, "trunk/"), dir);

                int n = 0;
                client.Log(Path.Combine(dir, "index.html"),
                           delegate(object sender, SvnLogEventArgs e)
                {
                    switch (n++)
                    {
                    case 0:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch b - product roadmap and update about page"));
                        break;

                    case 1:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch a.  Added medium product"));
                        break;

                    case 2:
                        Assert.That(e.LogMessage, Is.EqualTo("Create initial product structure"));
                        break;
                    }
                });
                Assert.That(n, Is.EqualTo(3));
            }
        }
Exemplo n.º 16
0
        public void TestNotify()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            int           n  = 0;;
            SvnUpdateArgs ua = new SvnUpdateArgs();

            ua.Notify += delegate(object sender, SvnNotifyEventArgs e)
            {
                Assert.That(e.FullPath, Is.EqualTo(WcPath));
                switch (n++)
                {
                case 0:
                    Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.UpdateStarted));
                    break;

                case 1:
                    Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.UpdateCompleted));
                    break;
                }
            };

            Client.Update(WcPath, ua);
            Assert.That(n, Is.EqualTo(2));

            n = 0;

            Client.Update(new string[] { WcPath }, ua);
            Assert.That(n, Is.EqualTo(2));
        }
Exemplo n.º 17
0
        public void Delete_ForceDelete()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string path = Path.Combine(WcPath, "Form.cs");

            // modify the file
            using (StreamWriter writer = new StreamWriter(path, true))
            {
                writer.WriteLine("Hi ho");
            }

            // this will throw if force doesn't work
            SvnDeleteArgs a = new SvnDeleteArgs();
            a.ThrowOnError = false;

            Assert.That(Client.Delete(path, a), Is.False);

            a.ThrowOnError = true;
            a.Force = true;

            Assert.That(Client.Delete(path, a), Is.True, "Delete failed");
        }
Exemplo n.º 18
0
        public void Move_MultiMove()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string ren1 = Path.Combine(WcPath, "ren-1");

                using (StreamWriter sw = File.CreateText(ren1))
                {
                    sw.WriteLine("ToRename");
                }
                client.Add(ren1);
                client.Commit(WcPath);
                client.Update(WcPath);

                using (StreamWriter sw = File.AppendText(ren1))
                {
                    sw.WriteLine("AddedLine");
                }
                client.Move(ren1, ren1 + ".ren1");

                client.Commit(WcPath);

                client.Move(ren1 + ".ren1", ren1 + ".ren2");
                SvnMoveArgs ma = new SvnMoveArgs();
                ma.Force = true;
                client.Move(ren1 + ".ren2", ren1 + ".ren3", ma);
                client.Commit(WcPath);
            }
        }
Exemplo n.º 19
0
        public void Capabilities_Local()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri emptyUri = sbox.CreateRepository(SandBoxRepository.Empty);
            Uri emptyNoMergeUri = sbox.CreateRepository(SandBoxRepository.EmptyNoMerge);

            using (SvnClient client = new SvnClient())
            {
                Collection<SvnCapability> caps;
                SvnGetCapabilitiesArgs aa = new SvnGetCapabilitiesArgs();
                aa.RetrieveAllCapabilities = true;

                IEnumerable<SvnCapability> rCaps = new SvnCapability[] { SvnCapability.MergeInfo };
                Assert.That(client.GetCapabilities(emptyUri, rCaps, out caps));

                Assert.That(caps.Contains(SvnCapability.MergeInfo));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, rCaps, out caps));

                Assert.That(!caps.Contains(SvnCapability.MergeInfo));
                Assert.That(caps.Count, Is.EqualTo(0));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(5));

                Assert.That(client.GetCapabilities(emptyUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(6));
            }
        }
Exemplo n.º 20
0
        public void List_ReadDash()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            Client.CheckOut(new Uri(CollabReposUri, "trunk"), dir);

            string file = Path.Combine(dir, "File#Dash");

            File.WriteAllText(file, "######");
            Client.Add(file);
            Client.Commit(dir);

            bool touched = false;

            Client.List(file,
                        delegate(object sender, SvnListEventArgs e)
            {
                touched = true;
                Assert.That(e.RepositoryRoot, Is.Null);
                Assert.That(e.BasePath.EndsWith("/File#Dash"));
                Assert.That(e.Name, Is.EqualTo("File#Dash"));
            });

            Assert.That(touched);
        }
Exemplo n.º 21
0
        public void Resolve_RepeatedEventHookUp_SOC_411()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri projectRoot = new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/scripts");

            using (var svnClient = new SvnClient())
            {
                for (int i = 0; i < 3; i++)
                {
                    string workingcopy = sbox.GetTempDir();
                    Directory.CreateDirectory(workingcopy);

                    svnClient.Authentication.UserNamePasswordHandlers += DoNowt;
                    try
                    {
                        SvnUpdateResult svnUpdateResult;
                        SvnCheckOutArgs ca = new SvnCheckOutArgs() { Depth = SvnDepth.Files };
                        Assert.IsTrue(svnClient.CheckOut(projectRoot, workingcopy, ca, out svnUpdateResult));
                        Assert.IsNotNull(svnUpdateResult);
                        Assert.IsTrue(svnUpdateResult.HasRevision);
                    }
                    finally
                    {
                        svnClient.Authentication.UserNamePasswordHandlers -= DoNowt;
                    }
                }
            }
        }
Exemplo n.º 22
0
        public void List_TestLowerDrive()
        {
            SvnSandBox sbox   = new SvnSandBox(this);
            string     tmpDir = sbox.GetTempDir();

            if (tmpDir.Contains(":"))
            {
                return; // Testing on UNC share
            }
            Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Greek);

            using (SvnClient client = NewSvnClient(false, false))
            {
                Uri          origUri   = ReposUrl;
                string       uriString = origUri.AbsoluteUri;
                SvnUriTarget target    = new SvnUriTarget("file:///" + char.ToLower(uriString[8]) + uriString.Substring(9));

                client.List(target, delegate(object sender, SvnListEventArgs e)
                {
                });

                target = new SvnUriTarget("file://localhost/" + char.ToLower(uriString[8]) + uriString.Substring(9));

                client.List(target, delegate(object sender, SvnListEventArgs e)
                {
                });
            }
        }
Exemplo n.º 23
0
        public void UpdateInUseWrite()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir           = sbox.Wc;
            bool   skippedDenied = false;

            Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk"), 1), dir);
            Client.Notify += delegate(object sender, SvnNotifyEventArgs e)
            {
                if (e.Action == SvnNotifyAction.UpdateSkipAccessDenied)
                {
                    skippedDenied = true;
                }
            };

            using (File.Create(Path.Combine(dir, "index.html")))
                using (new Implementation.SvnFsOperationRetryOverride(0))
                {
                    Client.Update(Path.Combine(dir, "index.html"));
                }

            Assert.That(skippedDenied);
        }
Exemplo n.º 24
0
        public void WcDirMissing()
        {
            SvnSandBox      sbox           = new SvnSandBox(this);
            Uri             CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string          dir            = sbox.Wc;
            SvnUpdateResult r;

            Assert.That(Client.CheckOut(CollabReposUri, dir, out r));

            Directory.Move(Path.Combine(dir, "trunk"), Path.Combine(dir, "banaan"));

            SvnInfoEventArgs iaParent;
            SvnInfoEventArgs iaTrunk;

            Client.GetInfo(dir, out iaParent);
            Client.GetInfo(Path.Combine(dir, "trunk"), out iaTrunk);

            Assert.That(iaParent.FullPath, Is.EqualTo(dir));
            Assert.That(iaTrunk.FullPath, Is.Not.EqualTo(dir));
            //Assert.That(iaParent.Uri, Is.EqualTo(iaTrunk.Uri));

            SvnWorkingCopyVersion ver;
            SvnWorkingCopyClient  wcC = new SvnWorkingCopyClient();

            Assert.That(wcC.GetVersion(dir, out ver));
            Assert.That(ver, Is.Not.Null);

            Assert.That(ver.Modified, Is.True);
            Assert.That(ver.Switched, Is.False);
            Assert.That(ver.Start, Is.EqualTo(17));
            Assert.That(ver.End, Is.EqualTo(17));
            Assert.That(ver.IncompleteWorkingCopy, Is.False);
        }
Exemplo n.º 25
0
        public void Remote_CompareRanges()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            using (SvnRemoteSession rc = new SvnRemoteSession())
            {
                rc.Open(CollabReposUri);
                Collection <SvnRemoteLocationSegmentEventArgs> c;
                rc.GetLocationSegments("branches/c/products/medium.html", out c);
                List <long> revs = new List <long>();

                foreach (SvnRemoteLocationSegmentEventArgs e in c)
                {
                    revs.Add(e.StartRevision);
                    revs.Add(e.EndRevision);
                    System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1}", e.Uri, e.Range));
                }

                SvnRevisionLocationMap revMap;
                rc.GetLocations("branches/c/products/medium.html", revs, out revMap);

                foreach (SvnRemoteLocationSegmentEventArgs e in c)
                {
                    Assert.That(revMap.Contains(e.StartRevision));
                    Assert.That(revMap[e.StartRevision].Uri, Is.EqualTo(e.Uri));
                    Assert.That(revMap.Contains(e.EndRevision));
                    Assert.That(revMap[e.EndRevision].Uri, Is.EqualTo(e.Uri));
                }
            }
        }
Exemplo n.º 26
0
        public void ChangeInfo_GetInfoCompare()
        {
            SvnSandBox sbox      = new SvnSandBox(this);
            Uri        reposUri  = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string     reposPath = reposUri.LocalPath;

            using (SvnClient cl = new SvnClient())
            {
                SvnSetPropertyArgs sa = new SvnSetPropertyArgs();
                sa.BaseRevision = 17;
                sa.LogMessage   = "Message";
                cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa);
            }

            for (long ii = 1; ii < 19; ii++)
            {
                using (SvnLookClient lcl = new SvnLookClient())
                    using (SvnClient cl = new SvnClient())
                    {
                        SvnChangeInfoEventArgs r;
                        SvnChangeInfoArgs      ia     = new SvnChangeInfoArgs();
                        SvnLookOrigin          origin = new SvnLookOrigin(reposPath, ii);

                        SvnLogArgs la = new SvnLogArgs();
                        la.Start = la.End = ii;

                        Collection <SvnLogEventArgs> lrc;
                        //ia.RetrieveChangedPaths = false; // Will fail if true
                        Assert.That(lcl.GetChangeInfo(origin, ia, out r));
                        Assert.That(cl.GetLog(reposUri, la, out lrc));

                        Assert.That(r, Is.Not.Null);
                        Assert.That(lrc.Count, Is.EqualTo(1));

                        SvnLogEventArgs lr = lrc[0];

                        Assert.That(r.Author, Is.EqualTo(lr.Author));
                        Assert.That(r.Revision, Is.EqualTo(lr.Revision));
                        Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1));
                        Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage));
                        Assert.That(r.Time, Is.EqualTo(lr.Time));

                        Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii);
                        Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii);

                        Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count));

                        for (int i = 0; i < r.ChangedPaths.Count; i++)
                        {
                            SvnChangeItem c  = r.ChangedPaths[i];
                            SvnChangeItem lc = lr.ChangedPaths[c.Path];

                            Assert.That(c.Path, Is.EqualTo(lc.Path));
                            Assert.That(c.Action, Is.EqualTo(lc.Action));
                            Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath));
                            Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision));
                        }
                    }
            }
        }
Exemplo n.º 27
0
        public void CreateDirectory_CreateTrunk()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty);
            using (SvnClient client = NewSvnClient(true, false))
            {
                Uri trunkUri = new Uri(ReposUrl, "trunk/");
                client.RemoteCreateDirectory(trunkUri);

                string trunkPath = sbox.Wc;

                client.CheckOut(trunkUri, trunkPath);

                TouchFile(Path.Combine(trunkPath, "test.txt"));

                Assert.That(SvnTools.IsManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(Path.Combine(trunkPath, "q/r/s/t/u/v/test.txt")));

                client.Add(Path.Combine(trunkPath, "test.txt"));

                Directory.CreateDirectory(Path.Combine(trunkPath, "dir"));
                TouchFile(Path.Combine(trunkPath, "dir/test.txt"));

                SvnAddArgs aa = new SvnAddArgs();
                aa.AddParents = true;
                client.Add(Path.Combine(trunkPath, "dir/test.txt"), aa);

                client.Commit(trunkPath);

                client.RemoteDelete(trunkUri, new SvnDeleteArgs());
            }
        }
Exemplo n.º 28
0
        public void Commit_WithAlternateUser()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string user = Guid.NewGuid().ToString();

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.Authentication.Clear();
                client.Configuration.LogMessageRequired = false;

                client.Authentication.UserNameHandlers +=
                    delegate(object sender, SvnUserNameEventArgs e)
                {
                    e.UserName = user;
                };

                client.SetProperty(dir, "a", "b");

                SvnCommitResult cr;
                client.Commit(dir, out cr);

                Collection <SvnLogEventArgs> la;
                client.GetLog(dir, out la);

                Assert.That(la.Count, Is.EqualTo(2));
                Assert.That(la[0].Revision, Is.EqualTo(cr.Revision));
                Assert.That(la[0].Author, Is.EqualTo(user));
                Assert.That(la[0].LogMessage, Is.EqualTo(""));
            }
        }
Exemplo n.º 29
0
        public void List_ParallelLocalList()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            Uri reposUri = new Uri(CollabReposUri, "trunk/");
            List <IAsyncResult> handlers = new List <IAsyncResult>();

            for (int i = 0; i < 128; i++)
            {
                int          n  = i;
                EventHandler eh = delegate
                {
                    Trace.WriteLine("Starting job" + n.ToString());
                    new SvnClient().List(reposUri,
                                         delegate { });
                };

                handlers.Add(eh.BeginInvoke(null, EventArgs.Empty, null, eh));
            }

            foreach (IAsyncResult ar in handlers)
            {
                ((EventHandler)ar.AsyncState).EndInvoke(ar);
            }
        }
Exemplo n.º 30
0
        public void Diff_ReposDiff()
        {
            SvnSandBox sbox       = new SvnSandBox(this);
            Uri        ReposUrl   = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases);
            string     clientDiff = this.RunCommand("svn", "diff -r 1:5 " + ReposUrl);

            MemoryStream outstream = new MemoryStream();
            MemoryStream errstream = new MemoryStream();

            SvnDiffArgs a = new SvnDiffArgs();

            a.ErrorStream = errstream;
            Client.Diff(ReposUrl, new SvnRevisionRange(1, 5), a, outstream);

            string err = Encoding.Default.GetString(errstream.ToArray());

            Assert.That(err, Is.EqualTo(string.Empty), "Error in diff: " + err);

            string apiDiff = Encoding.Default.GetString(outstream.ToArray());

            string[] clientLines = clientDiff.Split('\n');
            string[] apiLines    = apiDiff.Split('\n');
            Array.Sort <string>(clientLines);
            Array.Sort <string>(apiLines);

            Assert.That(apiLines, Is.EqualTo(clientLines), "Diffs differ");
        }
Exemplo n.º 31
0
        public void Diff_LocalDiff()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string form = Path.Combine(WcPath, "Form.cs");


            using (StreamWriter w = new StreamWriter(form, false))
                w.Write("Moo moo moo moo moo\r\nmon\r\nmooo moo moo \r\nssdgo");

            //Necessary to fix up headers

            string clientDiff = this.RunCommand("svn", "diff \"" + form + "\"");

            MemoryStream outstream = new MemoryStream();
            MemoryStream errstream = new MemoryStream();

            SvnDiffArgs a = new SvnDiffArgs();

            a.ErrorStream = errstream;
            this.Client.Diff(
                new SvnPathTarget(form, SvnRevision.Base),
                new SvnPathTarget(form, SvnRevision.Working),
                a, outstream);

            string err = Encoding.Default.GetString(errstream.ToArray());

            Assert.That(err, Is.EqualTo(""), "Error in diff: " + err);
            string apiDiff = Encoding.Default.GetString(outstream.ToArray());

            Assert.That(apiDiff, Is.EqualTo(clientDiff), "Client diff differs");
        }
Exemplo n.º 32
0
        public void RepositoryOperation_ViaSvnClient()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            Uri uri = sbox.CreateRepository(SandBoxRepository.Empty);

            using (SvnClient svn = new SvnClient())
            {
                SvnCommitResult cr;

                Assert.That(svn.RepositoryOperation(uri,
                                                    delegate(SvnMultiCommandClient mucc)
                {
                    //mucc.
                }, out cr));

                Assert.That(cr, Is.Null);

                svn.Configuration.LogMessageRequired = false;

                Assert.That(svn.RepositoryOperation(uri,
                                                    delegate(SvnMultiCommandClient mucc)
                {
                    mucc.SetProperty("", "A", "B");
                }, out cr));

                Assert.That(cr, Is.Not.Null);
                Assert.That(cr.Revision, Is.EqualTo(1));
            }
        }
Exemplo n.º 33
0
        public void PegTests()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            SvnUpdateResult result;

            Assert.That(Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk")), dir, out result));

            long head = result.Revision;

            Assert.That(result.Revision, Is.EqualTo(head));

            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/a")), out result));
            Assert.That(result.Revision, Is.EqualTo(head));

            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/c"), head - 3), out result));
            Assert.That(result.Revision, Is.EqualTo(head - 3));

            SvnSwitchArgs sa = new SvnSwitchArgs();

            sa.Revision = head - 4;
            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/b"), head - 5), sa, out result));
            Assert.That(result.Revision, Is.EqualTo(head - 4));

            sa          = new SvnSwitchArgs();
            sa.Revision = head - 7;
            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/a")), sa, out result));
            Assert.That(result.Revision, Is.EqualTo(head - 7));
        }
Exemplo n.º 34
0
        public void Dump_DumpDb()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            string     repos = sbox.GetTempDir();

            using (SvnRepositoryClient cl = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs ra = new SvnCreateRepositoryArgs();
                ra.RepositoryType          = SvnRepositoryFileSystem.BerkeleyDB;
                ra.RepositoryCompatibility = SvnRepositoryCompatibility.Subversion10;

                cl.CreateRepository(repos, ra);

                string file = GetTempFile();
                using (FileStream s = File.Create(file))
                {
                    SvnDumpRepositoryArgs da = new SvnDumpRepositoryArgs();
                    da.Start = new SvnRevision(0);
                    da.End   = new SvnRevision(SvnRevisionType.Head);
                    cl.DumpRepository(repos, s, da);
                }

                Assert.That(new FileInfo(file).Length, Is.GreaterThan(12));
            }
        }
Exemplo n.º 35
0
        public void TestPropGetOnFile()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            string path = Path.Combine(WcPath, "Form.cs");

            TouchFile(path);
            Client.Add(path);
            Client.SetProperty(path, "foo", "bar");

            string value;

            Assert.That(Client.GetProperty(new SvnPathTarget(path), "foo", out value));

            Assert.That(value, Is.EqualTo("bar"));

            SvnPropertyValue pval;

            Assert.That(Client.GetProperty(new SvnPathTarget(path), "foo", out pval));

            Assert.That(pval.StringValue, Is.EqualTo("bar"));
            Assert.That(pval.Key, Is.EqualTo("foo"));
            Assert.That(pval.Target.TargetName, Is.EqualTo(path));
        }
        public void Capabilities_Local()
        {
            SvnSandBox sbox            = new SvnSandBox(this);
            Uri        emptyUri        = sbox.CreateRepository(SandBoxRepository.Empty);
            Uri        emptyNoMergeUri = sbox.CreateRepository(SandBoxRepository.EmptyNoMerge);


            using (SvnClient client = new SvnClient())
            {
                Collection <SvnCapability> caps;
                SvnGetCapabilitiesArgs     aa = new SvnGetCapabilitiesArgs();
                aa.RetrieveAllCapabilities = true;

                IEnumerable <SvnCapability> rCaps = new SvnCapability[] { SvnCapability.MergeInfo };
                Assert.That(client.GetCapabilities(emptyUri, rCaps, out caps));

                Assert.That(caps.Contains(SvnCapability.MergeInfo));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, rCaps, out caps));

                Assert.That(!caps.Contains(SvnCapability.MergeInfo));
                Assert.That(caps.Count, Is.EqualTo(0));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(5));

                Assert.That(client.GetCapabilities(emptyUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(6));
            }
        }
Exemplo n.º 37
0
        public void TestGetOnCwd()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string wc = sbox.Wc;

            Client.CheckOut(new Uri(CollabReposUri, "trunk"), wc);

            string dir = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(wc);
            try
            {
                string v;
                Assert.That(Client.TryGetProperty(".", SvnPropertyNames.SvnMergeInfo, out v));
                Assert.That(v, Is.Not.Null);

                Assert.That(Client.TryGetProperty(SvnTarget.FromString("."), SvnPropertyNames.SvnMergeInfo, out v));
                Assert.That(v, Is.Not.Null);
            }
            finally
            {
                Directory.SetCurrentDirectory(wc);
            }
        }
Exemplo n.º 38
0
        public void TestCatPeg()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = new Uri(sbox.CreateRepository(SandBoxRepository.AnkhSvnCases), "trunk/");

            Uri path   = new Uri(reposUri, "Form.cs");
            Uri toPath = new Uri(reposUri, "Moo.cs");

            SvnCommitResult ci;

            this.Client.RemoteMove(path, toPath, out ci);

            string clientOutput = this.RunCommand("svn",
                                                  string.Format("cat {0}@{1} -r {2}", toPath, ci.Revision, ci.Revision - 1));

            MemoryStream stream = new MemoryStream();
            SvnWriteArgs a      = new SvnWriteArgs();

            a.Revision = ci.Revision - 1;
            this.Client.Write(new SvnUriTarget(toPath, ci.Revision), stream);

            string wrapperOutput = Encoding.ASCII.GetString(stream.ToArray());

            Assert.That(wrapperOutput, Is.EqualTo(clientOutput),
                        "String from wrapper not the same as string from client");
        }
Exemplo n.º 39
0
        public void WriteProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            string data = Guid.NewGuid().ToString();

            using (SvnClient client = NewSvnClient(true, false))
            {
                string file = Path.Combine(WcPath, "WriteTest");
                using (StreamWriter sw = File.CreateText(file))
                {
                    sw.WriteLine(data);
                }

                client.Add(file);
                client.SetProperty(file, "A", "B");
                client.Commit(file);

                using (MemoryStream ms = new MemoryStream())
                {
                    SvnPropertyCollection pc;
                    client.Write(new SvnPathTarget(file, SvnRevision.Head), ms, out pc);

                    Assert.That(pc, Is.Not.Empty);
                    Assert.That(pc["A"].StringValue, Is.EqualTo("B"));
                }
            }
        }
Exemplo n.º 40
0
        public void Replay_ReplayCollabTrunk()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            MyEditor edit = new MyEditor(false, sbox.GetTempDir());
            SvnReplayRevisionArgs ra = new SvnReplayRevisionArgs();
            Client.ReplayRevisions(new Uri(CollabReposUri, "trunk/"), new SvnRevisionRange(0, 10), edit, ra);
        }
Exemplo n.º 41
0
        public void Cleanup_Basic()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);

            using (SvnClient client = NewSvnClient(false, false))
            {
                client.CleanUp(sbox.Wc);
            }
        }
Exemplo n.º 42
0
        public void Replay_ReplayCollab()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            MyEditor edit = new MyEditor(true, sbox.GetTempDir());
            SvnReplayRevisionArgs ra = new SvnReplayRevisionArgs();
            ra.RetrieveContent = true;
            Client.ReplayRevisions(CollabReposUri, new SvnRevisionRange(0, 10), edit, ra);
        }
Exemplo n.º 43
0
        public void CreateRepository_FsFs()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Exemplo n.º 44
0
        public void Replay_ReplaySingleRev()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            MyEditor edit = new MyEditor(false, sbox.GetTempDir());
            SvnReplayRevisionArgs ra = new SvnReplayRevisionArgs();
            ra.RevisionStart += new EventHandler<SvnReplayRevisionStartEventArgs>(ra_RevisionStart);
            ra.RevisionEnd += new EventHandler<SvnReplayRevisionEndEventArgs>(ra_RevisionEnd);
            Client.ReplayRevisions(CollabReposUri, new SvnRevisionRange(10, 10), edit, ra);
        }
Exemplo n.º 45
0
        public void CreateRepository_Bdb()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryType = SvnRepositoryFileSystem.BerkeleyDB;
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Exemplo n.º 46
0
        public void CheckOut_ProgressEvent()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string newWc = sbox.GetTempDir();
            SvnCheckOutArgs a = new SvnCheckOutArgs();
            bool progressCalled = false;
            a.Progress += delegate(object sender, SvnProgressEventArgs e) { progressCalled = true; };
            a.Depth = SvnDepth.Empty;
            this.Client.CheckOut(new Uri("http://svn.apache.org/repos/asf/subversion/"), newWc, a);

            Assert.That(progressCalled, "Progress delegate not called");
        }
Exemplo n.º 47
0
        public void CreateDirectory_MakeLocalDir()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri emptyUri = sbox.CreateRepository(SandBoxRepository.Empty);

            Client.CheckOut(emptyUri, sbox.Wc);

            string path = Path.Combine(sbox.Wc, "foo");
            Assert.That(Client.CreateDirectory(path));

            Assert.That(this.GetSvnStatus(path), Is.EqualTo(SvnStatus.Added), "Wrong status code");
        }
Exemplo n.º 48
0
        public void Relocate_SvnServeRelocate()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default, false);

            // start a svnserve process on this repos
            Process svnserve = this.StartSvnServe(sbox.RepositoryUri.AbsolutePath);

            try
            {
                Uri localUri = new Uri(String.Format("svn://127.0.0.1:{0}/", PortNumber));

                bool svnServeAvailable = false;
                for (int i = 0; i < 10; i++)
                {
                    SvnInfoArgs ia = new SvnInfoArgs();
                    ia.ThrowOnError = false;

                    // This test also checks whether "svn://127.0.0.1:{0}/" is correctly canonicalized to "svn://127.0.0.1:{0}"
                    Client.Info(localUri, ia,
                        delegate(object sender, SvnInfoEventArgs e)
                        {
                            svnServeAvailable = true;
                        });

                    if (svnServeAvailable)
                        break;
                    Thread.Sleep(100);
                }

                Assert.That(svnServeAvailable);

                Assert.That(Client.Relocate(sbox.Wc, sbox.RepositoryUri, localUri));

                Collection<SvnInfoEventArgs> list;
                SvnInfoArgs a = new SvnInfoArgs();

                Assert.That(Client.GetInfo(sbox.Wc, a, out list));

                Assert.That(list.Count, Is.GreaterThan(0));
                Assert.That(list[0].Uri.ToString().StartsWith(localUri.ToString()));
            }
            finally
            {
                System.Threading.Thread.Sleep(100);
                if (!svnserve.HasExited)
                {
                    svnserve.Kill();
                    svnserve.WaitForExit();
                }
            }
        }
Exemplo n.º 49
0
        public void RevisionProperty_RevSetPropDir()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty);
            sbox.InstallRevpropHook(ReposUrl);

            byte[] propval = Encoding.UTF8.GetBytes("moo");

            this.Client.SetRevisionProperty(ReposUrl, SvnRevision.Head, "cow", propval);

            Assert.That(this.RunCommand("svn", "propget cow --revprop -r head " + ReposUrl).Trim(), Is.EqualTo("moo"),
                "Couldn't set prop on selected Repos!");
        }
Exemplo n.º 50
0
        public void FileVersions_ListIndexDir()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            Uri reposUri = sbox.CreateRepository(SandBoxRepository.Default);

            Client.FileVersions(new Uri(reposUri, "trunk/"),
                delegate(object sender, SvnFileVersionEventArgs e)
                {
                });

            throw new InvalidOperationException(); // Should have failed
        }
Exemplo n.º 51
0
        public void Revert_RevertDirectory()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string oldContents;
            string newContents;
            this.ModifyFile(out oldContents, out newContents, Path.Combine(WcPath, "Form.cs"),
                WcPath, SvnDepth.Infinity);

            Assert.That(newContents, Is.EqualTo(oldContents), "File not reverted");
        }
Exemplo n.º 52
0
        public void Export_ExportNonRecursive()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string wc = Path.Combine(sbox.GetTempDir(), "wc");
            SvnExportArgs a = new SvnExportArgs();
            a.Depth = SvnDepth.Empty;
            SvnUpdateResult r;
            this.Client.Export(WcPath, wc, a, out r);
            Assert.That(Directory.GetDirectories(wc).Length, Is.EqualTo(0));
        }
Exemplo n.º 53
0
        public void TestRevPropGetDir()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases);
            sbox.InstallRevpropHook(ReposUrl);

            this.RunCommand("svn", "ps --revprop -r HEAD cow moo " + ReposUrl);

            string value;
            Assert.That(Client.GetRevisionProperty(ReposUrl, SvnRevision.Head, "cow", out value));

            Assert.That(value, Is.EqualTo("moo"), "Wrong property value");
        }
Exemplo n.º 54
0
        public void DiffSummary_TrunkBranchB()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            SvnDiffSummaryArgs sa = new SvnDiffSummaryArgs();
            Client.DiffSummary(new Uri(CollabReposUri, "trunk"), new Uri(CollabReposUri, "branches/b"), sa,
                delegate(object sender, SvnDiffSummaryEventArgs e)
                {
                    Assert.That(e.FromUri.ToString().StartsWith(CollabReposUri.ToString()));
                    Assert.That(e.ToUri.ToString().StartsWith(CollabReposUri.ToString()));

                });
        }
Exemplo n.º 55
0
        public void RevisionProperty_SetLog()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri reposUri = sbox.CreateRepository(SandBoxRepository.DefaultBranched);
            string reposPath = reposUri.AbsolutePath;

            InstallRevpropHook(reposPath);

            SvnRevision rev = 2;

            Client.SetRevisionProperty(reposUri, rev, SvnPropertyNames.SvnDate, DateTime.UtcNow.ToString("o"));

            Client.SetRevisionProperty(new Uri(reposUri, "trunk"), rev, SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(DateTime.UtcNow));
        }
Exemplo n.º 56
0
        public void CheckOut_BasicCheckout()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases);
            string newWc = sbox.Wc;
            SvnCheckOutArgs a = new SvnCheckOutArgs();
            this.Client.CheckOut(new Uri(ReposUrl, "trunk/"), newWc, a);

            Assert.That(File.Exists(Path.Combine(newWc, "Form.cs")),
                "Checked out file not there");
            Assert.That(Directory.Exists(Path.Combine(newWc, SvnClient.AdministrativeDirectoryName)),
                "No admin directory found");
            Assert.That(this.RunCommand("svn", "st \"" + newWc + "\"").Trim(), Is.EqualTo(""),
                "Wrong status");
        }
Exemplo n.º 57
0
        public void TestIprops()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri uri = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string wc = sbox.Wc;

            SvnSetPropertyArgs pa = new SvnSetPropertyArgs();
            pa.BaseRevision = 17;
            Client.RemoteSetProperty(uri, "root", "root", pa);
            pa.BaseRevision++;
            Client.RemoteSetProperty(new Uri(uri, "trunk"), "trunk", "trunk", pa);
            pa.BaseRevision++;
            Client.RemoteSetProperty(new Uri(uri, "trunk/jobs"), "jobs", "jobs", pa);
            pa.BaseRevision++;
            Client.RemoteSetProperty(new Uri(uri, "trunk/jobs/index.html"), "index", "index", pa);

            SvnUpdateResult ur;
            Client.CheckOut(new Uri(uri, "trunk"), wc, out ur);
            Assert.That(ur.Revision, Is.EqualTo(pa.BaseRevision + 1));

            Client.SetProperty(wc, "local-trunk", "local-trunk");
            Client.SetProperty(Path.Combine(wc, "jobs"), "local-jobs", "local-jobs");

            Collection<SvnInheritedPropertyListEventArgs> results;
            string target = Path.Combine(wc, "jobs/index.html");
            Client.GetInheritedPropertyList(Path.Combine(wc, "jobs/index.html"), out results);

            Assert.That(results, Is.Not.Null);
            Assert.That(results.Count, Is.EqualTo(4));
            Assert.That(results[0].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(target)), "Path 0");
            Assert.That(results[0].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/index.html")));
            Assert.That(results[0].Properties, Is.Not.Empty);
            Assert.That(results[1].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, ".."))), "Path 1");
            Assert.That(results[1].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/")));
            Assert.That(results[1].Properties, Is.Not.Empty);
            Assert.That(results[2].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, "../.."))), "Path 2");
            Assert.That(results[2].Uri, Is.EqualTo(new Uri(uri, "trunk/")));
            Assert.That(results[2].Properties, Is.Not.Empty);
            Assert.That(results[3].Uri, Is.EqualTo(uri), "Path 3");
            Assert.That(results[3].Properties, Is.Not.Empty);

            SvnPropertyCollection pc;
            Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "nop"), out pc), Is.False);

            Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "jobs"), out pc));
            Assert.That(pc, Is.Not.Empty);
            Assert.That(pc.Contains("trunk"), "Contains trunk");
        }
Exemplo n.º 58
0
        public void RepositoryOperation_SetupRepository()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri uri = sbox.CreateRepository(SandBoxRepository.Empty);
            SvnCommitResult cr;

            SvnRepositoryOperationArgs oa = new SvnRepositoryOperationArgs();
            oa.LogMessage = "Everything in one revision";

            using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, oa))
            {
                mucc.CreateDirectory("trunk");
                mucc.CreateDirectory("branches");
                mucc.CreateDirectory("tags");
                mucc.CreateDirectory("trunk/src");
                mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
                mucc.SetProperty("", "svn:global-ignores", "bin obj");

                mucc.CreateFile("trunk/README", new MemoryStream(Encoding.UTF8.GetBytes("Welcome to this project")));
                mucc.SetProperty("trunk/README", "svn:eol-style", "native");

                Assert.That(mucc.Commit(out cr)); // Commit r1
                Assert.That(cr, Is.Not.Null);
            }

            using (SvnClient svn = new SvnClient())
            {
                Collection<SvnListEventArgs> members;
                svn.GetList(uri, out members);

                Assert.That(members, Is.Not.Empty);

                MemoryStream ms = new MemoryStream();
                SvnPropertyCollection props;
                svn.Write(new Uri(uri, "trunk/README"), ms, out props);

                Assert.That(props, Is.Not.Empty);
                Assert.That(Encoding.UTF8.GetString(ms.ToArray()), Is.EqualTo("Welcome to this project"));
                Assert.That(props.Contains("svn:eol-style"));

                Collection<SvnLogEventArgs> la;
                SvnLogArgs ll = new SvnLogArgs();
                ll.Start = 1;
                svn.GetLog(uri, ll, out la);
                Assert.That(la, Is.Not.Empty);
                Assert.That(la[0].LogMessage, Is.EqualTo("Everything in one revision"));
            }
        }
Exemplo n.º 59
0
        public void TestCatFromRepository()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri ReposUrl = new Uri(sbox.CreateRepository(SandBoxRepository.AnkhSvnCases), "trunk/");

            Uri path = new Uri(ReposUrl, "Form.cs");

            string clientOutput = this.RunCommand("svn", "cat " + path);

            MemoryStream stream = new MemoryStream();
            this.Client.Write(new SvnUriTarget(path, SvnRevision.Head), stream);

            string wrapperOutput = Encoding.ASCII.GetString(stream.ToArray());
            Assert.That(wrapperOutput, Is.EqualTo(clientOutput),
                "String from wrapper not the same as string from client");
        }
Exemplo n.º 60
0
        public void Exception_StatusCrash()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);

            SvnStatusArgs sa = new SvnStatusArgs();
            sa.ThrowOnError = false;
            sa.RetrieveAllEntries = true;
            Assert.That(Client.Status(sbox.Wc, sa,
                delegate(object sender, SvnStatusEventArgs e)
                {
                    throw new InvalidOperationException();
                }), Is.False);

            Assert.That(sa.LastException.RootCause, Is.InstanceOf(typeof(InvalidOperationException)));
        }