Пример #1
0
        public void Dump_DumpDb()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            string     repos = sbox.GetTempDir();

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

                cl.CreateRepository(repos, ra);

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

                Assert.That(new FileInfo(file).Length, Is.GreaterThan(12));
            }
        }
Пример #2
0
        public void Dump_DumpDb()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string repos = sbox.GetTempDir();

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

                cl.CreateRepository(repos, ra);

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

                Assert.That(new FileInfo(file).Length, Is.GreaterThan(12));
            }
        }
Пример #3
0
 public static void SetupRepository()
 {
     TestFileSystemHelper.RecreateDirectory(RepositoryPath);
     using (var client = new SvnRepositoryClient()) {
         client.CreateRepository(RepositoryPath);
     }
 }
Пример #4
0
        /// <summary>
        /// Actualiza la ubicacion del repositorio.
        /// </summary>
        /// <param name="rutaRepositorio"></param>
        /// <param name="rutaRepoAntigua"></param>
        /// <returns></returns>
        public static string ActualizarRepositorio(string rutaRepositorio, string rutaRepoAntigua)
        {
            var msj = "";

            // Checar si ya se había creado el repositorio en la ruta proporcionada.
            if (rutaRepositorio == rutaRepoAntigua)
            {
                return("Exito");
            }

            // TODO Checar si no hay algún otro repositorio en la ruta proporcionada.
            using (var svnRepoClient = new SvnRepositoryClient())
            {
                svnRepoClient.LoadConfiguration(rutaRepositorio);

                if (svnRepoClient.CreateRepository(rutaRepositorio))
                {
                    msj = "Exito";
                }
                else
                {
                    msj = "Error al crear el repositorio.";
                }
            }

            return(msj);
        }
Пример #5
0
        public void CreateRepository_FsFs()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Пример #6
0
        public void CreateRepository_FsFs()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Пример #7
0
        public void CreateRepository_Bdb()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryType          = SvnRepositoryFileSystem.BerkeleyDB;
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Пример #8
0
        public void CreateRepository_Bdb()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnRepositoryClient reposClient = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs cra = new SvnCreateRepositoryArgs();
                cra.RepositoryType = SvnRepositoryFileSystem.BerkeleyDB;
                cra.RepositoryCompatibility = SvnRepositoryCompatibility.Default;
                reposClient.CreateRepository(sbox.GetTempDir(), cra);
            }
        }
Пример #9
0
    static void Main(string[] args)
    {
        Uri uri = null;

        if (args.Length < 2 ||
            !Uri.TryCreate(args[0], UriKind.Absolute, out uri))
        {
            Console.Error.WriteLine("Usage: SvnDumpFileToRepository URL PATH");
        }
        using (SvnRepositoryClient repos = new SvnRepositoryClient())
        {
            repos.CreateRepository(args[1]);
        }
        Uri reposUri = SvnTools.LocalPathToUri(args[1], true);

        using (SvnClient client = new SvnClient())
            using (SvnClient client2 = new SvnClient())
            {
                SvnUI.Bind(client, new SvnUIBindArgs());
                string fileName = SvnTools.GetFileName(uri);
                bool   create   = true;
                client.FileVersions(uri,
                                    delegate(object sender, SvnFileVersionEventArgs e)
                {
                    Console.Write("Copying {0} in r{1}", fileName, e.Revision);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        e.WriteTo(ms);     // Write full text to memory stream
                        ms.Position = 0;
                        // And now use 'svnmucc' to update repository
                        client2.RepositoryOperation(reposUri,
                                                    new SvnRepositoryOperationArgs {
                            LogMessage = e.LogMessage
                        },
                                                    delegate(SvnMultiCommandClient mucc)
                        {
                            if (create)
                            {
                                mucc.CreateFile(fileName, ms);
                                create = false;
                            }
                            else
                            {
                                mucc.UpdateFile(fileName, ms);
                            }
                        });
                    }
                });
            }
    }
Пример #10
0
        public void CreateBdbRepos()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string path = sbox.GetTempDir();

            SvnRepositoryClient reposClient = new SvnRepositoryClient();

            SvnCreateRepositoryArgs ra = new SvnCreateRepositoryArgs();
            ra.RepositoryType = SvnRepositoryFileSystem.BerkeleyDB;
            reposClient.CreateRepository(path, ra);

            Assert.That(File.Exists(Path.Combine(path, "db/DB_CONFIG")));

            reposClient.HotCopy(path, sbox.GetTempDir());

            reposClient.SetRevisionProperty(path, 0, SvnPropertyNames.SvnLog, "Hahaha");
        }
Пример #11
0
        public void CreateBdbRepos()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            string     path = sbox.GetTempDir();

            SvnRepositoryClient reposClient = new SvnRepositoryClient();

            SvnCreateRepositoryArgs ra = new SvnCreateRepositoryArgs();

            ra.RepositoryType = SvnRepositoryFileSystem.BerkeleyDB;
            reposClient.CreateRepository(path, ra);

            Assert.That(File.Exists(Path.Combine(path, "db/DB_CONFIG")));

            reposClient.HotCopy(path, sbox.GetTempDir());

            reposClient.SetRevisionProperty(path, 0, SvnPropertyNames.SvnLog, "Hahaha");
        }
Пример #12
0
        /// <summary>
        /// Crea un repositorio SVN en la ruta indicada.
        /// </summary>
        /// <param name="rutaRepositorio"></param>
        /// <returns></returns>
        public static string CrearRepositorio(string rutaRepositorio)
        {
            var msj = "";

            using (var svnRepoClient = new SvnRepositoryClient())
            {
                svnRepoClient.LoadConfiguration(rutaRepositorio);

                if (svnRepoClient.CreateRepository(rutaRepositorio))
                {
                    msj = "Exito";
                }
                else
                {
                    msj = "Error al crear el repositorio.";
                }
            }

            return(msj);
        }
Пример #13
0
		public static void CreateRepo(string repoDir)
		{
			using (var svn = new SvnRepositoryClient())
			{
				if (Directory.Exists(repoDir))
					svn.DeleteRepository(repoDir);

				svn.CreateRepository(repoDir);
			}

			// create hooks
			File.WriteAllText(Path.Combine(repoDir, "hooks/post-revprop-change.bat"), "exit 0");
			File.WriteAllText(Path.Combine(repoDir, "hooks/pre-revprop-change.bat"), "exit 0");
		}
Пример #14
0
        public void Create()
        {
            SvnRepositoryClient client = new SvnRepositoryClient();

            if (Directory.Exists(RepositoryPath))
                throw new Exception("Repository already exists");

            Directory.CreateDirectory(RepositoryPath);

            client.LoadConfiguration(RepositoryPath);

            if (!client.CreateRepository(RepositoryPath))
                throw new Exception("Failed to create new repository");

            usePasswd(true);
            anonAccess(Access.None);
            authAccess(Access.Write);
        }
Пример #15
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));
        }