Beispiel #1
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)
                {
                });
            }
        }
Beispiel #2
0
        public void List_TestHash()
        {
            using (SvnClient client = new SvnClient())
            {
                Uri    reposUri = new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn/");
                string baseUri  = "https://ctf.open.collab.net/svn/repos/ankhsvn/testcases/trunk/WorstCase/AllTypesSolution/";
                string exUri    = baseUri + "%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3%e3%82%b0%23Silverlight/";

                client.Authentication.Clear();
                client.Authentication.DefaultCredentials         = new NetworkCredential("guest", "");
                client.Authentication.SslServerTrustHandlers    += SvnAuthentication.SubversionWindowsSslServerTrustHandler;
                client.Authentication.SslAuthorityTrustHandlers += SvnAuthentication.SubversionWindowsSslAuthorityTrustHandler;

                bool found = false;
                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        return;
                    }

                    if (e.Uri == new Uri(exUri))
                    {
                        found = true;
                    }
                });

                Assert.That(found, "Found subdir");
                found = false;

                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri(baseUri)));
                        return;
                    }
                });

                client.List(new SvnUriTarget(new Uri(exUri + "Properties/"), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri(exUri + "Properties/")));
                        return;
                    }
                });
            }
        }
Beispiel #3
0
        public void List_TestHash()
        {
            using (SvnClient client = NewSvnClient(false, false))
            {
                Uri    reposUri = new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn/");
                string baseUri  = "https://ctf.open.collab.net/svn/repos/ankhsvn/testcases/trunk/WorstCase/AllTypesSolution/";
                string exUri    = baseUri + "%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3%e3%82%b0%23Silverlight/";

                bool found = false;
                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        return;
                    }

                    if (e.Uri == new Uri(exUri))
                    {
                        found = true;
                    }
                });

                Assert.That(found, "Found subdir");
                found = false;

                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri(baseUri)));
                        return;
                    }
                });

                client.List(new SvnUriTarget(new Uri(exUri + "Properties/"), 11888),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri(exUri + "Properties/")));
                        return;
                    }
                });
            }
        }
Beispiel #4
0
        public void ForEachChild(string path, int revision, Change change, Action <PathChange> action)
        {
            SvnClient client = AllocSvnClient();
            SvnTarget target = MakeTarget(path, change == Change.Delete ? revision - 1 : revision);

            try
            {
                SvnListArgs args = new SvnListArgs {
                    Depth = SvnDepth.Infinity
                };
                client.List(target, args, delegate(object s, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        return;
                    }

                    var pc = new PathChange();
                    {
                        pc.Change   = change;
                        pc.Revision = revision;
                        // to be compatible with the log output (which has no trailing '/' for directories)
                        // we need to remove trailing '/'
                        pc.Path = (e.BasePath.EndsWith("/") ? e.BasePath : e.BasePath + "/") + e.Path.TrimEnd('/');
                    }
                    action(pc);
                });
            }
            finally
            {
                FreeSvnClient(client);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Actual method to be executed for the implementing task
        /// </summary>
        /// <param name="client">The instance of the SVN client</param>
        /// <returns></returns>
        public override bool ExecuteCommand(SvnClient client)
        {
            SvnTarget target = new SvnUriTarget(RepositoryPath);
            SvnListArgs args = new SvnListArgs();
            args.Depth = Recursive ? SvnDepth.Infinity : SvnDepth.Children;

            return client.List(target, args, listHandler);
        }
Beispiel #6
0
        public void ListSsh()
        {
            using (SvnClient client = new SvnClient())
            {
                bool foundOne = false;
                client.List(new Uri("svn+ssh://vip.alh.net.qqn.nl/home/bert/repos/"), delegate(object sender, SvnListEventArgs e)
                {
                    foundOne = true;
                });

                Assert.That(foundOne);
            }
        }
Beispiel #7
0
        public void ListSsh()
        {
            using (SvnClient client = new SvnClient())
            {
                bool foundOne = false;
                client.List(new Uri("svn+ssh://vip.alh.net.qqn.nl/home/bert/repos/"), delegate(object sender, SvnListEventArgs e)
                {
                    foundOne = true;
                });

                Assert.That(foundOne);
            }
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public void List_TestRoot()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            using (SvnClient client = new SvnClient())
            {
                client.List(CollabReposUri, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.RepositoryRoot, Is.EqualTo(CollabReposUri));
                    Assert.That(e.RepositoryRoot.ToString().EndsWith("/"));
                });
            }
        }
Beispiel #10
0
        public void List_ListSharp()
        {
            using (SvnClient client = new SvnClient())
            {
                Client.Authentication.Clear();
                Client.Authentication.DefaultCredentials = new NetworkCredential("guest", "");

                client.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"),
                            delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.RepositoryRoot, Is.EqualTo(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/")));
                    Assert.That(e.BaseUri, Is.EqualTo(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/")));
                    Assert.That(e.BasePath, Is.EqualTo("/trunk"));
                });
            }
        }
Beispiel #11
0
 public bool ExportDirectory(SvnTarget sourceUri, string destinationPath)
 {
     using (var svnClient = new SvnClient())
     {
         svnClient.List(
             sourceUri,
             new SvnListArgs {
             Depth = SvnDepth.Infinity
         },
             (s, e) => _g.Interaction.DoInteractively(
                 ref _ignoreItemError,
                 TitleErrorProcessingNode,
                 () => ExportDirectoryListItem(e, sourceUri.Revision, destinationPath)));
     }
     return(!_g.StopRequested);
 }
Beispiel #12
0
        public void RemoteList()
        {
            SvnClient cl = new SvnClient();
            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);
        }
Beispiel #13
0
        //[TestMethod]
        public void TestSpace()
        {
            using (SvnClient client = new SvnClient())
            {
                int n = 0;
                client.List(new Uri("http://sharpsvn.googlecode.com/svn/trunk/tests/folder%20with spaces"),
                            delegate(object sender, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(new Uri("http://sharpsvn.googlecode.com/svn/")));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri("http://sharpsvn.googlecode.com/svn/trunk/tests/folder%20with spaces/")));
                        return;
                    }

                    n++;
                }
                            );

                Assert.That(n, Is.EqualTo(2));
            }
        }
Beispiel #14
0
        public void List_ParallelList()
        {
            List <Task> handlers = new List <Task>();

            for (int i = 0; i < 32; i++)
            {
                int n = i;

                handlers.Add(Task.Run(() =>
                {
                    Trace.WriteLine("Starting job" + n.ToString());
                    using (var cl = new SvnClient())
                    {
                        SetupAuth(cl);
                        cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/src/SharpSvn"),
                                delegate { });
                    }
                }));
            }

            Task.WaitAll(handlers.ToArray());
        }
Beispiel #15
0
        IEnumerable <DirectoryEntry> List(SvnTarget target, bool recurse)
        {
            List <DirectoryEntry> list = new List <DirectoryEntry> ();
            SvnListArgs           args = new SvnListArgs();

            args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children;
            client.List(target, args, delegate(object o, SvnListEventArgs a) {
                if (string.IsNullOrEmpty(a.Path))
                {
                    return;
                }
                DirectoryEntry de  = new DirectoryEntry();
                de.CreatedRevision = ToBaseRevision(a.Entry.Revision).Rev;
                de.HasProps        = a.Entry.HasProperties;
                de.IsDirectory     = a.Entry.NodeKind == SvnNodeKind.Directory;
                de.LastAuthor      = a.Entry.Author;
                de.Name            = a.Path;
                de.Size            = a.Entry.FileSize;
                de.Time            = a.Entry.Time;
                list.Add(de);
            });
            return(list);
        }
Beispiel #16
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);
        }
Beispiel #17
0
        //[TestMethod]
        public void TestSpace()
        {
            using(SvnClient client = new SvnClient())
            {
                int n = 0;
                client.List(new Uri("http://sharpsvn.googlecode.com/svn/trunk/tests/folder%20with spaces"),
                    delegate(object sender, SvnListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            Assert.That(e.RepositoryRoot, Is.EqualTo(new Uri("http://sharpsvn.googlecode.com/svn/")));
                            Assert.That(e.BaseUri, Is.EqualTo(new Uri("http://sharpsvn.googlecode.com/svn/trunk/tests/folder%20with spaces/")));
                            return;
                        }

                        n++;
                    }
                );

                Assert.That(n, Is.EqualTo(2));
            }
        }
Beispiel #18
0
        public void List_TestRoot()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            using (SvnClient client = new SvnClient())
            {
                client.List(CollabReposUri, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.RepositoryRoot, Is.EqualTo(CollabReposUri));
                    Assert.That(e.RepositoryRoot.ToString().EndsWith("/"));
                });
            }
        }
Beispiel #19
0
        public void List_TestHash()
        {
            using (SvnClient client = new SvnClient())
            {
                Uri reposUri = new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn/");
                string baseUri = "https://ctf.open.collab.net/svn/repos/ankhsvn/testcases/trunk/WorstCase/AllTypesSolution/";
                string exUri = baseUri + "%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3%e3%82%b0%23Silverlight/";

                client.Authentication.Clear();
                client.Authentication.DefaultCredentials = new NetworkCredential("guest", "");
                client.Authentication.SslServerTrustHandlers += SvnAuthentication.SubversionWindowsSslServerTrustHandler;
                client.Authentication.SslAuthorityTrustHandlers += SvnAuthentication.SubversionWindowsSslAuthorityTrustHandler;

                bool found = false;
                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                    delegate(object sender, SvnListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                            return;
                        }

                        if (e.Uri == new Uri(exUri))
                            found = true;
                    });

                Assert.That(found, "Found subdir");
                found = false;

                client.List(new SvnUriTarget(new Uri(baseUri), 11888),
                    delegate(object sender, SvnListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                            Assert.That(e.BaseUri, Is.EqualTo(new Uri(baseUri)));
                            return;
                        }
                    });

                client.List(new SvnUriTarget(new Uri(exUri + "Properties/"), 11888),
                    delegate(object sender, SvnListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                            Assert.That(e.BaseUri, Is.EqualTo(new Uri(exUri + "Properties/")));
                            return;
                        }
                    });
            }
        }
Beispiel #20
0
        public void List_ListSharp()
        {
            using (SvnClient client = new SvnClient())
            {
                Client.Authentication.Clear();
                Client.Authentication.DefaultCredentials = new NetworkCredential("guest", "");

                client.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"),
                    delegate(object sender, SvnListEventArgs e)
                    {
                        Assert.That(e.RepositoryRoot, Is.EqualTo(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/")));
                        Assert.That(e.BaseUri, Is.EqualTo(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/")));
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"));
                    });

            }
        }
Beispiel #21
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);
        }
Beispiel #22
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);
            }
        }