Esempio n. 1
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"));
            }
        }
        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"));
            }
        }
Esempio n. 3
0
        public Uri CreateRepository(SandBoxRepository type)
        {
            string dir = GetTempDir("repos");

            using (SvnRepositoryClient rc = new SvnRepositoryClient())
            {
                rc.UseDefaultConfiguration(); // Don't load config

                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();

                if (type == SandBoxRepository.EmptyNoMerge)
                {
                    cra.RepositoryCompatibility = SvnRepositoryCompatibility.Subversion14;
                }
                rc.CreateRepository(dir, cra);

                Uri uri = SvnTools.LocalPathToUri(dir, false);

                switch (type)
                {
                case SandBoxRepository.Empty:
                    break;

                case SandBoxRepository.Default:
                case SandBoxRepository.DefaultBranched:
                    SvnRepositoryOperationArgs ra = new SvnRepositoryOperationArgs();
                    ra.LogMessage = "r1";
                    using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, ra))
                    {
                        mucc.CreateDirectory("trunk");
                        mucc.CreateDirectory("trunk/src");
                        mucc.CreateDirectory("branches");
                        mucc.CreateDirectory("branches/A");
                        mucc.CreateDirectory("branches/B");
                        mucc.CreateFile("trunk/README.txt", new MemoryStream(Encoding.UTF8.GetBytes("Read me, please?\n")));
                        mucc.CreateFile("trunk/src/file1.cs", new MemoryStream(Encoding.UTF8.GetBytes("using SharpSvn;\n")));
                        mucc.CreateFile("trunk/src/file2.vb", new MemoryStream(Encoding.UTF8.GetBytes("Imports SharpSvn;\n")));
                        mucc.CreateFile("trunk/src/file3.cpp", new MemoryStream(Encoding.UTF8.GetBytes("using namespace SharpSvn;\n")));
                        mucc.SetProperty("trunk/src/file3.cpp", SvnPropertyNames.SvnEolStyle, "native");
                        mucc.CreateFile("trunk/src/file4.fs", new MemoryStream(Encoding.UTF8.GetBytes("namespace SharpSvn\n")));
                        mucc.SetProperty("trunk/src/file4.fs", SvnPropertyNames.SvnEolStyle, "LF");

                        mucc.Commit();
                    }
                    if (type == SandBoxRepository.Default)
                    {
                        break;
                    }
                    ra.LogMessage = "r2";
                    using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, ra))
                    {
                        mucc.CreateDirectory("branches/C");
                        mucc.Copy("trunk", "branches/trunk-r1");
                        mucc.UpdateFile("trunk/README.txt", new MemoryStream(Encoding.UTF8.GetBytes("Read me, please?\n\"Ok, read!\"\n")));

                        mucc.Commit();
                    }
                    ra.LogMessage = "r3";
                    using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, ra))
                    {
                        mucc.CreateDirectory("branches/D");
                        mucc.Copy("trunk", "branches/trunk-r2");
                        mucc.UpdateFile("trunk/README.txt", new MemoryStream(Encoding.UTF8.GetBytes("Read me, please?\n\"Ok, read!\"\n")));

                        mucc.Commit();
                    }
                    ra.LogMessage = "r4";
                    using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, ra))
                    {
                        mucc.CreateDirectory("branches/E");
                        mucc.Copy("trunk", "branches/trunk-r3");
                        mucc.UpdateFile("trunk/README.txt", new MemoryStream(Encoding.UTF8.GetBytes("Read me, please?\n\"Ok, read!\"\nNo way!\n")));

                        mucc.Commit();
                    }
                    break;

                case SandBoxRepository.MergeScenario:
                    rc.LoadRepository(dir, typeof(SvnSandBox).Assembly.GetManifestResourceStream("SharpSvn.TestBuilder.Resources.MergeScenario.repos"));
                    break;

                case SandBoxRepository.AnkhSvnCases:
                    BuildAnkhCases(uri);
                    break;

                case SandBoxRepository.Greek:
                    BuildGreek(uri);
                    break;

                default:
                    break;
                }
            }

            return(SvnTools.LocalPathToUri(dir, true));
        }