Example #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");
        }
Example #2
0
        private void OnChangedProps(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(e.HookArgs.LookOrigin, "trunk/A/mu",
                                           delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                {
                    switch (i++)
                    {
                    case 0:
                        Assert.That(ee.Path, Is.EqualTo("trunk"));
                        Assert.That(ee.Properties.Contains("root-A"));
                        break;

                    case 1:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                        Assert.That(ee.Properties.Contains("A-A"));
                        break;

                    case 2:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                        Assert.That(ee.Properties.Contains("mu-A"));
                        break;

                    default:
                        throw new InvalidOperationException("Too many invocations");
                    }
                });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
        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));
            }
        }
Example #4
0
        public void Log_Test14Server()
        {
            SvnLogArgs la = new SvnLogArgs();

            la.Limit = 1;

            DateTime now = DateTime.UtcNow;

            for (int i = 0; i < 20; i++)
            {
                Assert.That(Client.Log(new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn"), la,
                                       delegate(object sender, SvnLogEventArgs e)
                {
                    e.Cancel = true;
                    Assert.That(e.MergeLogNestingLevel, Is.EqualTo(0));
                    Assert.That(e.Revision, Is.GreaterThan(3000L));
                    Assert.That(e.LogMessage, Is.Not.Null);
                    Assert.That(e.Time, Is.GreaterThan(new DateTime(2008, 01, 01)));
                    Assert.That(e.Author, Is.Not.Null);
                    Assert.That(e.ChangedPaths, Is.Not.Null);
                    Assert.That(e.LogOrigin, Is.Null);
                }), Is.False);
            }

            DateTime end = DateTime.UtcNow;

            Debug.WriteLine(string.Format("Time spend: {0}", end - now));
        }
        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();
                }
            }
        }
Example #6
0
        public void TestLibs()
        {
            foreach (SvnLibrary lib in SvnClient.SvnLibraries)
            {
                Assert.That(lib.Name, Is.Not.Null);

                Assert.That(lib.VersionString, Is.Not.Null, "VersionString is null for {0}", lib.Name);
                Assert.That(lib.Version, Is.Not.Null, "Version is null for {0} ({1})", lib.Name, lib.VersionString);
                Assert.That(lib.Version, Is.GreaterThan(new Version(0, 1)));
            }
        }
Example #7
0
        public void Remote_RemoteList()
        {
            DateTime start = DateTime.Now;

            using (SvnRemoteSession rc = new SvnRemoteSession())
            {
                rc.Open(new Uri("http://svn.apache.org/repos/asf/subversion/"));

                int         n          = 0;
                bool        foundTrunk = false;
                List <Uri>  uris       = new List <Uri>();
                SvnNodeKind dir;
                rc.GetNodeKind("", out dir);
                Assert.That(dir, Is.EqualTo(SvnNodeKind.Directory));
                rc.List("",
                        delegate(object sender, SvnRemoteListEventArgs e)
                {
                    n++;
                    if (e.Name == "trunk")
                    {
                        foundTrunk = true;
                        Assert.That(e.Uri, Is.EqualTo(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/")));
                    }
                    uris.Add(e.Uri);
                });

                Assert.That(foundTrunk);
                Assert.That(n, Is.GreaterThan(4));

                Uri reposRoot;
                rc.GetRepositoryRoot(out reposRoot);
                rc.Reparent(reposRoot);

                int n2 = 0;
                rc.List("subversion/",
                        delegate(object sender, SvnRemoteListEventArgs e)
                {
                    n2++;
                    Assert.That(uris.Contains(e.Uri), "Same Uri");
                });

                Assert.That(n2, Is.EqualTo(n));
            }
            DateTime between = DateTime.Now;
            Collection <SvnListEventArgs> items;

            Client.GetList(new Uri("http://svn.apache.org/repos/asf/subversion/"), out items);
            DateTime after = DateTime.Now;

            Console.WriteLine(between - start);
            Console.WriteLine(after - between);
        }
Example #8
0
        public void List_RemoteListTest()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        ReposUrl = sbox.CreateRepository(SandBoxRepository.Greek);

            using (SvnClient client = NewSvnClient(false, false))
            {
                Collection <SvnListEventArgs> items;
                client.GetList(ReposUrl, out items);

                Assert.That(items, Is.Not.Null, "Items retrieved");
                Assert.That(items.Count, Is.GreaterThan(0), "More than 0 items");
            }
        }
        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));
            }
        }
Example #10
0
        public void LookInheritedProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri        uri  = sbox.CreateRepository(SandBoxRepository.Greek);

            using (InstallHook(uri, SvnHookType.PreCommit, OnChangedProps))
            {
                Client.RepositoryOperation(new Uri(uri, "trunk"), delegate(SvnMultiCommandClient cl)
                {
                    cl.SetProperty("", "root-A", "B");
                    cl.SetProperty("A", "A-A", "C");
                    cl.SetProperty("A/mu", "mu-A", "D");
                });
            }

            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(new SvnLookOrigin(uri.LocalPath, 2), "trunk/A/mu",
                                           delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                {
                    switch (i++)
                    {
                    case 0:
                        Assert.That(ee.Path, Is.EqualTo("trunk"));
                        Assert.That(ee.Properties.Contains("root-A"));
                        break;

                    case 1:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                        Assert.That(ee.Properties.Contains("A-A"));
                        break;

                    case 2:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                        Assert.That(ee.Properties.Contains("mu-A"));
                        break;

                    default:
                        throw new InvalidOperationException("Too many invocations");
                    }
                });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
Example #11
0
        public void Merge_RevertToBase()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.MergeScenario);

            int nChanges = 0;

            Client.Notify += delegate(object sender, SvnNotifyEventArgs e)
            {
                nChanges++;
            };

            Assert.That(Client.Merge(sbox.Wc, new Uri(sbox.RepositoryUri, "trunk/"), new SvnRevisionRange(SvnRevision.Head, 2)));

            Assert.That(nChanges, Is.GreaterThan(5));
        }
Example #12
0
        public void List_TestListReflection()
        {
            SvnSandBox sbox          = new SvnSandBox(this);
            Type       svnClientType = Type.GetType("SharpSvn.SvnClient, SharpSvn");
            Type       svnUriTarget  = Type.GetType("SharpSvn.SvnUriTarget, SharpSvn");

            object client = Activator.CreateInstance(svnClientType);
            object target = Activator.CreateInstance(svnUriTarget, sbox.CreateRepository(SandBoxRepository.MergeScenario));

            object[] args = new object[] { target, null };

            svnClientType.InvokeMember("GetList", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, client, args);

            IList list = args[1] as IList;

            Assert.That(list, Is.Not.Null);
            Assert.That(list.Count, Is.GreaterThan(0));
        }
Example #13
0
        public void Remote_StatFile()
        {
            using (SvnRemoteSession rc = new SvnRemoteSession())
            {
                rc.Open(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/COMMITTERS"));

                SvnRemoteStatEventArgs st;
                rc.GetStat("", out st);

                Assert.That(st, Is.Not.Null);
                Assert.That(st.Entry.Time, Is.GreaterThan(new DateTime(2006, 1, 1)));

                SvnNodeKind kind;
                rc.GetNodeKind("", out kind);
                Assert.That(kind, Is.EqualTo(SvnNodeKind.File));

                rc.GetNodeKind("QQQ", out kind);

                Assert.That(kind, Is.EqualTo(SvnNodeKind.None));
            }
        }
Example #14
0
        public void TestSsh()
        {
            SvnClient cl    = new SvnClient();
            bool      found = false;

            //cl.KeepSession = true;

            cl.Authentication.SshServerTrustHandlers += delegate(object sender, Security.SvnSshServerTrustEventArgs e)
            {
                e.AcceptedFailures = e.Failures;
            };

            cl.Authentication.UserNameHandlers += delegate(object sender, Security.SvnUserNameEventArgs e)
            {
                e.UserName = "******";
                e.Save     = true;
            };
            cl.List(new Uri("svn+libssh2://vip/home/svn/repos/ankh-test"), delegate(object Sender, SvnListEventArgs e)
            {
                Assert.That(e.Entry, Is.Not.Null);
                Assert.That(e.Entry.Revision, Is.GreaterThan(0L));
                Assert.That(e.Entry.Author, Is.Not.Null);
                found = true;
            });

            Assert.That(found);

            found = false;

            cl.List(new Uri("svn+libssh2://bert@vip/home/svn/repos/ankh-test"), delegate(object Sender, SvnListEventArgs e)
            {
                Assert.That(e.Entry, Is.Not.Null);
                Assert.That(e.Entry.Revision, Is.GreaterThan(0L));
                Assert.That(e.Entry.Author, Is.Not.Null);
                found = true;
            });

            Assert.That(found);
        }
Example #15
0
        public void TestCancel()
        {
            //this.Client.AuthBaton.Add( AuthenticationProvider.GetUsernameProvider() );
            SvnSandBox sbox = new SvnSandBox(this);

            int cancels = 0;

            EventHandler <SvnCancelEventArgs> cancelHandler = delegate(object sender, SvnCancelEventArgs e)
            {
                cancels++;
            };

            Client.Cancel += cancelHandler;

            Assert.That(Client.CheckOut(sbox.CreateRepository(SandBoxRepository.Greek), sbox.Wc));
            Assert.That(cancels, Is.GreaterThan(0), "No cancellation callbacks");

            Client.Cancel -= new EventHandler <SvnCancelEventArgs>(cancelHandler);
            Client.Cancel += delegate(object sender, SvnCancelEventArgs e) { e.Cancel = true; cancels = -1; };

            Assert.That(Client.Update(sbox.Wc), Is.False);
            Assert.That(cancels, Is.EqualTo(-1));
        }
Example #16
0
        public void FileVersions_ListIndex()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

            bool touched           = false;
            SvnFileVersionsArgs fa = new SvnFileVersionsArgs();

            fa.RetrieveProperties = true;
            Client.FileVersions(new Uri(reposUri, "trunk/README.txt"),
                                fa,
                                delegate(object sender, SvnFileVersionEventArgs e)
            {
                touched = true;
                Assert.That(e.RevisionProperties, Is.Not.Null, "Revision properties available");
                Assert.That(e.Properties, Is.Not.Null, "Properties available");

                Assert.That(e.RevisionProperties.Contains(SvnPropertyNames.SvnAuthor));
//                    Assert.That(e.Properties.Contains(SvnPropertyNames.SvnEolStyle));

                Assert.That(e.Revision, Is.GreaterThan(0));
                Assert.That(e.Author, Is.Not.Null);
                Assert.That(e.LogMessage, Is.Not.Null);
                Assert.That(e.Time, Is.LessThan(DateTime.UtcNow).And.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 0, 2, 0)));

                using (StreamReader sr = new StreamReader(e.GetContentStream()))
                {
                    string content = sr.ReadToEnd();

                    Assert.That(content, Is.Not.Null);
                    Assert.That(content.Length, Is.GreaterThan(10));
                }
            });

            Assert.That(touched);
        }
Example #17
0
        public void RemoteList()
        {
            SvnClient   cl    = NewSvnClient(false, false);
            bool        found = false;
            SvnListArgs la    = new SvnListArgs();

            la.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

            cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), la, delegate(object Sender, SvnListEventArgs e)
            {
                Assert.That(e.Entry, Is.Not.Null);
                Assert.That(e.Entry.Revision, Is.GreaterThan(0L));
                Assert.That(e.Entry.Author, Is.Not.Null);
                found = true;
            });

            Assert.That(found);

            Collection <SvnListEventArgs> ee;

            cl.GetList(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), out ee);
            Assert.That(ee, Is.Not.Null);
            Assert.That(ee[0].Entry.Author, Is.Not.Null);
        }
Example #18
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));
        }
Example #19
0
        public void Log_MultiLogs()
        {
            bool touched = false;

            Assert.That(Client.Log(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/"),
                                   delegate(object sender, SvnLogEventArgs e)
            {
                touched  = true;
                e.Cancel = true;
                Assert.That(e.MergeLogNestingLevel, Is.EqualTo(0));
                Assert.That(e.Revision, Is.GreaterThan(20000L));
                Assert.That(e.LogMessage, Is.Not.Null);
                Assert.That(e.Time, Is.GreaterThan(new DateTime(2008, 01, 01)));
                Assert.That(e.Author, Is.Not.Null);
                Assert.That(e.ChangedPaths, Is.Not.Null);
                Assert.That(e.LogOrigin, Is.Null);
            }), Is.False);

            Assert.That(touched);

            List <Uri> uris = new List <Uri>();
            long       rev  = 0;

            Assert.That(Client.Log(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/"),
                                   delegate(object sender, SvnLogEventArgs e)
            {
                foreach (SvnChangeItem item in e.ChangedPaths)
                {
                    Uri uri = new Uri(new Uri("http://svn.collab.net/repos/asf/"), item.Path.TrimStart('/'));

                    if (item.Action == SvnChangeAction.Delete)
                    {
                        uris.Remove(uri);
                    }
                    else if (item.Action == SvnChangeAction.Add || item.Action == SvnChangeAction.Modify)
                    {
                        uris.Add(uri);
                    }
                }

                if (uris.Count > 10)
                {
                    e.Cancel = true;
                    rev      = e.Revision - 1;
                }
            }), Is.False);

            Assert.That(uris.Count, Is.GreaterThan(10));

            uris.Clear();
            uris.Add(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/README"));
            uris.Add(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/INSTALL"));
            SvnLogArgs args = new SvnLogArgs();

            args.Start = 863074;
            args.End   = 859074;
            args.Limit = 100;
            args.OperationalRevision = 863074;
            touched = false;
            Client.Log(uris, args, delegate(object sender, SvnLogEventArgs e)
            {
                Assert.That(e.LogOrigin, Is.Not.Null);
                touched = true;
            });

            Assert.That(touched);
        }
Example #20
0
        public void List_ListDetails()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string WcPath = sbox.Wc;
            Uri    WcUri  = sbox.Uri;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string oneFile = Path.Combine(WcPath, "LocalFileForTestList");
                TouchFile(oneFile);
                client.Add(oneFile);

                SvnCommitResult ci;
                client.Commit(WcPath, out ci);
                SvnUpdateResult r;
                client.Update(WcPath, out r);

                Assert.That(r, Is.Not.Null);
                Assert.That(r.HasRevision);
                Assert.That(r.HasResultMap);
                Assert.That(r.Revision, Is.EqualTo(ci.Revision));

                bool        visited = false;
                SvnListArgs a       = new SvnListArgs();
                a.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

                client.List(new SvnPathTarget(WcPath), a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");
                    Assert.That(e.RepositoryRoot, Is.Null, "Only valid when listing a Uri");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");


                visited = false;
                client.List(WcUri, a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");

                SvnWorkingCopyClient wcC = new SvnWorkingCopyClient();
                SvnWorkingCopyState  state;
                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.True);

                client.SetProperty(oneFile, "svn:mime-type", "application/binary");

                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.False);
            }
        }
Example #21
0
        public void Copy_CopyTest()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string WcPath = sbox.Wc;
            Uri    WcUri  = sbox.Uri;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string file = Path.Combine(WcPath, "CopyBase");

                TouchFile(file);
                client.Add(file);

                client.Commit(WcPath);

                client.RemoteCopy(new Uri(WcUri, "CopyBase"), new Uri(WcUri, "RemoteCopyBase"));
                bool visited = false;
                bool first   = true;
                client.Log(new Uri(WcUri, "RemoteCopyBase"), delegate(object sender, SvnLogEventArgs e)
                {
                    if (first)
                    {
                        first = false;
                        foreach (SvnChangeItem i in e.ChangedPaths)
                        {
                            Assert.That(i.Path, Is.StringEnding("trunk/RemoteCopyBase"), "Path ends with folder/RemoteCopyBase");
                            Assert.That(i.Action, Is.EqualTo(SvnChangeAction.Add));
                            Assert.That(i.CopyFromPath, Is.StringEnding("trunk/CopyBase"), "CopyFromPath ends with folder/CopyBase");
                            Assert.That(i.CopyFromRevision, Is.GreaterThan(0L));
                            Assert.That(i.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        }
                    }
                    else
                    {
                        foreach (SvnChangeItem i in e.ChangedPaths)
                        {
                            Assert.That(i.Action, Is.EqualTo(SvnChangeAction.Add));
                            Assert.That(i.Path, Is.StringEnding("trunk/CopyBase"), "Path ends with folder/CopyBase");
                            Assert.That(i.NodeKind, Is.EqualTo(SvnNodeKind.File));
                            visited = true;
                        }
                    }
                });
                Assert.That(visited, "Visited log item");

                client.Copy(new SvnPathTarget(file), Path.Combine(WcPath, "LocalCopy"));
                client.Commit(WcPath);
                visited = false;
                first   = true;
                client.Log(new Uri(WcUri, "LocalCopy"), delegate(object sender, SvnLogEventArgs e)
                {
                    if (first)
                    {
                        foreach (SvnChangeItem i in e.ChangedPaths)
                        {
                            Assert.That(i.Path, Is.StringEnding("trunk/LocalCopy"), "Path ends with folder/LocalCopy");
                            Assert.That(i.Action, Is.EqualTo(SvnChangeAction.Add));
                            Assert.That(i.CopyFromPath, Is.StringEnding("trunk/CopyBase"), "CopyFromPath ensd with folder/CopyBase");
                            Assert.That(i.CopyFromRevision, Is.GreaterThan(0L));
                        }
                        first = false;
                    }
                    else
                    {
                        foreach (SvnChangeItem i in e.ChangedPaths)
                        {
                            Assert.That(i.Action, Is.EqualTo(SvnChangeAction.Add));
                            Assert.That(i.Path, Is.StringEnding("trunk/CopyBase"), "Path ends with folder/CopyBase");
                            visited = true;
                        }
                    }
                });
                Assert.That(visited, "Visited local log item");
            }
        }
Example #22
0
        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");
                }
            }
        }
        public void DeleteTest()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string WcPath = sbox.Wc;
            Uri    WcUri  = sbox.Uri;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string local  = Path.Combine(WcPath, "LocalDeleteBase");
                string remote = Path.Combine(WcPath, "RemoteDeleteBase");

                TouchFile(local);
                client.Add(local);
                TouchFile(remote);
                client.Add(remote);

                SvnCommitResult ci;
                client.Commit(WcPath, out ci);

                Assert.That(ItemExists(new Uri(WcUri, "LocalDeleteBase")), Is.True, "Remote base does exist");
                Assert.That(ItemExists(new Uri(WcUri, "RemoteDeleteBase")), Is.True, "Local base does exist");

                client.Delete(local);
                client.RemoteDelete(new Uri(WcUri, "RemoteDeleteBase"));

                bool visited = false;
                int  n       = 0;
                client.Status(local, delegate(object sender, SvnStatusEventArgs e)
                {
                    Assert.That(n++, Is.EqualTo(0));
                    Assert.That(e.FullPath, Is.EqualTo(local));
                    Assert.That(e.LocalNodeStatus, Is.EqualTo(SvnStatus.Deleted));
                    Assert.That(e.Switched, Is.False);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "LocalDeleteBase")));
                    Assert.That(e.IsRemoteUpdated, Is.EqualTo(false));
                    Assert.That(e.LocalNodeStatus, Is.EqualTo(SvnStatus.Deleted));
                    Assert.That(e.LocalCopied, Is.EqualTo(false));
                    Assert.That(e.Wedged, Is.EqualTo(false));
                    Assert.That(e.LocalPropertyStatus, Is.EqualTo(SvnStatus.None));
                    Assert.That(e.Path, Is.EqualTo(local));
                    Assert.That(e.RemoteNodeStatus, Is.EqualTo(SvnStatus.None));
                    Assert.That(e.RemoteLock, Is.Null);
                    Assert.That(e.RemotePropertyStatus, Is.EqualTo(SvnStatus.None));
                    Assert.That(e.RemoteUpdateCommitAuthor, Is.Null);
                    Assert.That(e.RemoteUpdateCommitTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.RemoteUpdateNodeKind, Is.EqualTo(SvnNodeKind.None));
                    Assert.That(e.RemoteUpdateRevision, Is.EqualTo(-1L));
                    Assert.That(e.Switched, Is.EqualTo(false));

#pragma warning disable 0618
                    Assert.That(e.WorkingCopyInfo, Is.Not.Null);
                    Assert.That(e.WorkingCopyInfo.ChangeList, Is.Null);
                    Assert.That(e.WorkingCopyInfo.Checksum, Is.Not.Null);
                    Assert.That(e.WorkingCopyInfo.ConflictNewFile, Is.Null);
                    Assert.That(e.WorkingCopyInfo.ConflictOldFile, Is.Null);
                    Assert.That(e.WorkingCopyInfo.ConflictWorkFile, Is.Null);
                    Assert.That(e.WorkingCopyInfo.CopiedFrom, Is.Null);
                    Assert.That(e.WorkingCopyInfo.CopiedFromRevision, Is.EqualTo(-1L));
                    Assert.That(e.WorkingCopyInfo.Depth, Is.EqualTo(SvnDepth.Infinity));
                    Assert.That(e.WorkingCopyInfo.HasProperties, Is.False);
                    Assert.That(e.WorkingCopyInfo.HasPropertyChanges, Is.False);
                    Assert.That(e.WorkingCopyInfo.IsAbsent, Is.False);
                    Assert.That(e.WorkingCopyInfo.IsCopy, Is.False);
                    Assert.That(e.WorkingCopyInfo.IsDeleted, Is.False);
                    Assert.That(e.WorkingCopyInfo.IsIncomplete, Is.False);
                    Assert.That(e.WorkingCopyInfo.KeepLocal, Is.False);
                    Assert.That(e.WorkingCopyInfo.LastChangeAuthor, Is.EqualTo(Environment.UserName));
                    Assert.That(e.WorkingCopyInfo.LastChangeRevision, Is.EqualTo(ci.Revision));
                    Assert.That(e.WorkingCopyInfo.LastChangeTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 0, 45)));
                    Assert.That(e.WorkingCopyInfo.LockComment, Is.Null);
                    Assert.That(e.WorkingCopyInfo.LockOwner, Is.Null);
                    Assert.That(e.WorkingCopyInfo.LockTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.WorkingCopyInfo.LockToken, Is.Null);
                    Assert.That(e.WorkingCopyInfo.Name, Is.EqualTo("LocalDeleteBase"));
                    Assert.That(e.WorkingCopyInfo.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.WorkingCopyInfo.PropertyRejectFile, Is.Null);
                    Assert.That(e.WorkingCopyInfo.RepositoryId, Is.Not.Null);
                    Assert.That(e.WorkingCopyInfo.RepositoryId, Is.Not.EqualTo(Guid.Empty));
                    Assert.That(e.WorkingCopyInfo.RepositoryUri, Is.EqualTo(sbox.RepositoryUri));
                    Assert.That(e.WorkingCopyInfo.Revision, Is.EqualTo(ci.Revision));
                    Assert.That(e.WorkingCopyInfo.Schedule, Is.EqualTo(SvnSchedule.Delete));
                    Assert.That(e.WorkingCopyInfo.Uri, Is.EqualTo(new Uri(WcUri, "LocalDeleteBase")));
#pragma warning restore 0618
                    visited = true;
                });
                Assert.That(visited, "Visited handler");

                client.Commit(WcPath);

                Assert.That(ItemExists(new Uri(WcUri, "LocalDeleteBase")), Is.False, "Remote base does not exist");
                Assert.That(ItemExists(new Uri(WcUri, "RemoteDeleteBase")), Is.False, "Local base does not exist");
            }
        }
Example #24
0
        public void TestInfo()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = sbox.CreateRepository(SandBoxRepository.Empty);
            Uri        WcUri    = reposUri;
            string     wc       = sbox.Wc;

            using (SvnClient client = NewSvnClient(true, false))
            {
                client.CheckOut(reposUri, wc);

                string file = Path.Combine(wc, "InfoFile");
                TouchFile(file);
                client.Add(file);

                bool visited = false;
                client.Info(file, delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.Null);
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.CopyFromRevision, Is.EqualTo(-1L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.EqualTo(file));
                    Assert.That(e.HasLocalInfo, Is.True);
                    Assert.That(e.LastChangeAuthor, Is.Null);
                    Assert.That(e.LastChangeTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(-1L), "Not committed yet; LastChangeRevision = -1"); // Not committed yet
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.RepositorySize, Is.EqualTo(-1L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri), "Repository valid");
                    Assert.That(e.Revision, Is.LessThanOrEqualTo(0L), "Not committed yet");
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Add));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(-1L));
                    visited = true;
                });
                Assert.That(visited);

                SvnCommitResult commitData;
                client.Commit(wc, out commitData);
                visited = false;
                client.Info(file, delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.EqualTo("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.CopyFromRevision, Is.EqualTo(-1L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.EqualTo(file));
                    Assert.That(e.HasLocalInfo, Is.True);
                    Assert.That(e.LastChangeAuthor, Is.EqualTo(Environment.UserName));
                    Assert.That(e.LastChangeTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(e.ContentTime)); // Not static, might change
                    Assert.That(e.RepositorySize, Is.EqualTo(-1L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                    Assert.That(e.Revision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Normal));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(0L));
                    visited = true;
                });
                Assert.That(visited);

                visited = false;
                client.Info(new Uri(WcUri, "InfoFile"), delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.Null);
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.CopyFromRevision, Is.LessThanOrEqualTo(0L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.Null);
                    Assert.That(e.HasLocalInfo, Is.False);
                    Assert.That(e.LastChangeAuthor, Is.EqualTo(Environment.UserName));
                    Assert.That(e.LastChangeTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeTime, Is.LessThan(DateTime.UtcNow + new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(e.ContentTime));
                    Assert.That(e.RepositorySize, Is.EqualTo(0L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                    Assert.That(e.Revision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Normal));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(-1L));
                    visited = true;
                });
                Assert.That(visited);
            }
        }