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));
            }
        }
        public void Capabilities_SharpCaps()
        {
            using (SvnClient client = new SvnClient())
            {
                Collection <SvnCapability> caps;

                SvnGetCapabilitiesArgs ca = new SvnGetCapabilitiesArgs();
                ca.RetrieveAllCapabilities = true;
                Assert.That(client.GetCapabilities(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn"), ca, out caps));

                Assert.That(caps.Contains(SvnCapability.MergeInfo));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(5));
            }
        }
Exemple #3
0
        void OnPostCommit(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnChangeInfoEventArgs i;
                Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i));

                GC.KeepAlive(i);
                Assert.That(i.Revision, Is.GreaterThanOrEqualTo(0L));
                Assert.That(i.Author, Is.EqualTo(Environment.UserName));
            }
        }
        public void SomeGlobalTests()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            using (SvnClient client = NewSvnClient(false, false))
            {
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(".svn"));
                Assert.That(SvnClient.Version, Is.GreaterThanOrEqualTo(new Version(1, 5, 0)));
                Assert.That(SvnClient.SharpSvnVersion, Is.GreaterThan(new Version(1, 5, 0)));
                Assert.That(client.GetRepositoryRoot(sbox.Uri), Is.EqualTo(sbox.RepositoryUri));
                Assert.That(client.GetRepositoryRoot(sbox.Wc), Is.EqualTo(sbox.RepositoryUri));
            }
        }
Exemple #5
0
        public void Log_LogCreate()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string WcPath = sbox.Wc;
            Uri    WcUri  = new Uri(CollabReposUri, "trunk/");

            Client.CheckOut(WcUri, WcPath);

            string logFile = Path.Combine(WcPath, "LogTestFileBase");

            TouchFile(logFile);
            Client.Add(logFile);
            SvnCommitArgs a = new SvnCommitArgs();

            a.LogMessage = "Commit 1\rWith\nSome\r\nRandom\n\rNewlines\nAdded\n\r\n";
            Client.Commit(WcPath, a);

            File.AppendAllText(logFile, Guid.NewGuid().ToString());
            a.LogMessage = "Commit 2";
            Client.SetProperty(logFile, "TestProperty", "TestValue");
            Client.Commit(WcPath, a);

            string renamedLogFile = Path.Combine(WcPath, "LogTestFileDest");

            Client.Move(logFile, renamedLogFile);
            a.LogMessage = "Commit 3" + Environment.NewLine + "With newline";
            Client.Commit(WcPath, a);

            int        n  = 0;
            SvnLogArgs la = new SvnLogArgs();

            la.StrictNodeHistory = false;


            EventHandler <SvnLogEventArgs> verify = delegate(object sender, SvnLogEventArgs e)
            {
                SvnChangeItem ci;
                SvnChangeItem ci2;

                Assert.That(e.Author, Is.EqualTo(Environment.UserName));
                Assert.That(e.Cancel, Is.False);
                Assert.That(e.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                Assert.That(e.HasChildren, Is.False);
                Assert.That(e.RevisionProperties, Is.Not.Null);
                Assert.That(e.RevisionProperties.Count, Is.GreaterThanOrEqualTo(3));
                switch (n)
                {
                case 0:
                    Assert.That(e.LogMessage, Is.EqualTo("Commit 3" + Environment.NewLine + "With newline"));
                    Assert.That(e.ChangedPaths, Is.Not.Null);
                    Assert.That(e.ChangedPaths.Count, Is.EqualTo(2));
                    Assert.That(e.ChangedPaths.Contains("/trunk/LogTestFileBase"));
                    Assert.That(e.ChangedPaths.Contains("/trunk/LogTestFileDest"));
                    ci  = e.ChangedPaths["/trunk/LogTestFileBase"];
                    ci2 = e.ChangedPaths["/trunk/LogTestFileDest"];

                    Assert.That(ci, Is.Not.Null);
                    Assert.That(ci2, Is.Not.Null);
                    Assert.That(ci.Path, Is.EqualTo("/trunk/LogTestFileBase"));
                    Assert.That(ci.Action, Is.EqualTo(SvnChangeAction.Delete));
                    Assert.That(ci.CopyFromPath, Is.Null);
                    Assert.That(ci.CopyFromRevision, Is.EqualTo(-1));
                    Assert.That(ci2.Path, Is.EqualTo("/trunk/LogTestFileDest"));
                    Assert.That(ci2.Action, Is.EqualTo(SvnChangeAction.Add));
                    Assert.That(ci2.CopyFromPath, Is.EqualTo("/trunk/LogTestFileBase"));
                    Assert.That(ci2.CopyFromRevision, Is.Not.EqualTo(-1));
                    break;

                case 1:
                    Assert.That(e.LogMessage, Is.EqualTo("Commit 2"));
                    Assert.That(e.ChangedPaths, Is.Not.Null);
                    Assert.That(e.ChangedPaths.Count, Is.EqualTo(1));
                    ci = e.ChangedPaths[0];
                    Assert.That(ci, Is.Not.Null);
                    Assert.That(ci.Path, Is.EqualTo("/trunk/LogTestFileBase"));
                    Assert.That(ci.Action, Is.EqualTo(SvnChangeAction.Modify));
                    Assert.That(ci.CopyFromPath, Is.Null);
                    Assert.That(ci.CopyFromRevision, Is.EqualTo(-1));
                    break;

                case 2:
                    Assert.That(e.LogMessage, Is.EqualTo("Commit 1" + Environment.NewLine + "With" +
                                                         Environment.NewLine + "Some" + Environment.NewLine + "Random" + Environment.NewLine +
                                                         "Newlines" + Environment.NewLine + "Added" + Environment.NewLine + Environment.NewLine));
                    Assert.That(e.ChangedPaths, Is.Not.Null);
                    Assert.That(e.ChangedPaths.Count, Is.EqualTo(1));
                    ci = e.ChangedPaths[0];
                    Assert.That(ci, Is.Not.Null);
                    Assert.That(ci.Path, Is.EqualTo("/trunk/LogTestFileBase"));
                    Assert.That(ci.Action, Is.EqualTo(SvnChangeAction.Add));
                    Assert.That(ci.CopyFromPath, Is.Null);
                    Assert.That(ci.CopyFromRevision, Is.EqualTo(-1));
                    break;

                default:
                    Assert.That(false);
                    break;
                }
                n++;
            };

            Client.Log(new Uri(WcUri, "LogTestFileDest"), verify);
            Assert.That(n, Is.EqualTo(3));

            n = 0;

            Client.Log(Path.Combine(WcPath, "LogTestFileDest"), verify);
            Assert.That(n, Is.EqualTo(3));
        }
        public void FileVersions_WalkKeywords()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);

            string wc   = sbox.Wc;
            string file = Path.Combine(wc, "myFile.txt");
            string nl   = Environment.NewLine;

            File.WriteAllText(file, "Line1 $Id: FileVersions.cs 2139 2012-05-19 10:21:53Z rhuijben $" + nl + "$HeadURL$" + nl + nl);

            Client.Add(file);
            Client.SetProperty(file, SvnPropertyNames.SvnKeywords, "Id\nHeadURL");
            Client.Commit(file);
            File.AppendAllText(file, "Line" + nl);
            Client.Commit(file);
            Client.SetProperty(file, SvnPropertyNames.SvnEolStyle, "native");
            Client.Commit(file);
            File.AppendAllText(file, "Line" + nl + "Line");
            Client.Commit(file);
            Client.SetProperty(file, SvnPropertyNames.SvnEolStyle, "CR");
            Client.Commit(file);

            string f2 = file + "2";

            Client.Copy(file, f2);
            SvnCommitArgs xa = new SvnCommitArgs();

            xa.LogProperties.Add("extra", "value");
            Client.Commit(wc, xa);
            Client.Update(wc);

            SvnFileVersionsArgs va;

            using (SvnClient c2 = new SvnClient())
            {
                Uri fileUri = c2.GetUriFromWorkingCopy(file);
                Uri f2Uri   = c2.GetUriFromWorkingCopy(f2);

                for (int L = 0; L < 2; L++)
                {
                    va = new SvnFileVersionsArgs();
                    va.RetrieveProperties = true;
                    switch (L)
                    {
                    case 0:
                        va.Start = SvnRevision.Zero;
                        va.End   = SvnRevision.Head;
                        break;

                    default:
                        break;
                    }

                    int i = 0;
                    Client.FileVersions(f2, va,
                                        delegate(object sender, SvnFileVersionEventArgs e)
                    {
                        Assert.That(e.Revision, Is.EqualTo(i + 1L));
                        Assert.That(e.RepositoryRoot, Is.Not.Null);
                        Assert.That(e.Uri, Is.EqualTo(i == 5 ? f2Uri : fileUri));
                        Assert.That(e.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 0, 10, 0, 0)));
                        Assert.That(e.RevisionProperties.Count, Is.GreaterThanOrEqualTo(3));

                        if (i == 5)
                        {
                            Assert.That(e.RevisionProperties.Contains("extra"), "Contains extra property");
                            //Assert.That(e.Properties.Contains(SvnPropertyNames.SvnMergeInfo), Is.True, "Contains merge info in revision 5");
                        }
                        else
                        {
                            Assert.That(e.Properties.Contains(SvnPropertyNames.SvnMergeInfo), Is.False, "No mergeinfo");
                        }

                        MemoryStream ms1 = new MemoryStream();
                        MemoryStream ms2 = new MemoryStream();

                        e.WriteTo(ms1);
                        c2.Write(new SvnUriTarget(e.Uri, e.Revision), ms2);

                        string s1 = Encoding.UTF8.GetString(ms1.ToArray());
                        string s2 = Encoding.UTF8.GetString(ms2.ToArray());

                        //Assert.That(ms1.Length, Is.EqualTo(ms2.Length), "Export lengths equal");
                        Assert.That(s1, Is.EqualTo(s2));
                        i++;
                    });

                    Assert.That(i, Is.EqualTo(6), "Found 6 versions");
                }
            }
        }