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); } }); } }); } }
public void Blame_TestMore() { SvnSandBox sbox = new SvnSandBox(this); string reposPath = sbox.CreateRepository(SandBoxRepository.MergeScenario).AbsolutePath; Uri reposUri = SvnTools.LocalPathToUri(reposPath, true); Uri uri = new Uri(reposUri, "trunk/index.html"); int n = 0; SvnBlameArgs ba = new SvnBlameArgs(); ba.Notify += delegate(object sender, SvnNotifyEventArgs e) { Assert.That(e.Uri, Is.EqualTo(uri)); Assert.That(e.RevisionProperties, Is.Not.Null); n++; }; int lines = 0; Client.Blame(uri, ba, delegate(object sender, SvnBlameEventArgs e) { Assert.That(e.Author, Is.Not.Null); Assert.That(e.RevisionProperties, Is.Not.Null); Assert.That(e.RevisionProperties.Contains(SvnPropertyNames.SvnAuthor)); Assert.That(e.RevisionProperties.Contains(SvnPropertyNames.SvnLog)); Assert.That(e.RevisionProperties[SvnPropertyNames.SvnAuthor].StringValue, Is.Not.Null); Assert.That(e.RevisionProperties[SvnPropertyNames.SvnLog].StringValue, Is.Not.Null); Assert.That(e.MergedAuthor, Is.Null); Assert.That(e.MergedRevisionProperties, Is.Null); lines++; }); Assert.That(n, Is.EqualTo(3)); Assert.That(lines, Is.EqualTo(32)); }
public void Path_PathToUri() { Assert.That(SvnTools.LocalPathToUri(@"c:\TemP\file", false).AbsoluteUri, Is.EqualTo("file:///C:/TemP/file")); //Assert.That(SvnTools.SvnTools.LocalPathToUri(@"\\QUAD\public\temp", false), Is.EqualTo("file://quad/public/temp")); }
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)); }