/// <summary> /// Helper function for unit tests /// </summary> /// <param name="workingPath"></param> /// <param name="unitTestDirectory"></param> /// <returns></returns> public bool BuildUnitTestRepo(string workingPath, string unitTestDirectory) { var unitTestPath = Path.Combine(workingPath, unitTestDirectory); var pathExists = Directory.Exists(unitTestPath); if (!pathExists) { if (IsWorkingCopy(workingPath)) { if (_svnClient.CreateDirectory(unitTestPath)) { //TODO fix //CommitAllFiles(unitTestPath, "Unit Test"); return(true); } else { return(false); } } else { return(false); } } else { return(true); } }
public void Merge_MinimalMergeTest() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); using (SvnClient client = NewSvnClient(true, false)) { string merge1 = Path.Combine(sbox.Wc, "mmerge-1"); string merge2 = Path.Combine(sbox.Wc, "mmerge-2"); client.CreateDirectory(merge1); string f1 = Path.Combine(merge1, "myfile.txt"); using (StreamWriter fs = File.CreateText(f1)) { fs.WriteLine("First line"); fs.WriteLine("Second line"); fs.WriteLine("Third line"); fs.WriteLine("Fourth line"); } client.Add(f1); SvnCommitResult ci; client.Commit(sbox.Wc, out ci); client.Copy(new SvnPathTarget(merge1), merge2); client.Commit(sbox.Wc); client.Update(sbox.Wc); SvnMergeSourcesCollection sources; client.GetSuggestedMergeSources(new SvnPathTarget(merge1), out sources); Assert.That(sources.Count, Is.EqualTo(0)); client.GetSuggestedMergeSources(new SvnPathTarget(merge2), out sources); Assert.That(sources.Count, Is.EqualTo(1)); Uri fromUri = new Uri(sbox.RepositoryUri, new Uri("mmerge-1", UriKind.Relative)); Assert.That(sources[0].Uri, Is.EqualTo(fromUri)); SvnAppliedMergeInfo applied; client.GetAppliedMergeInfo(new SvnPathTarget(merge2), out applied); Assert.That(applied, Is.Null); //Assert.That(applied.AppliedMerges.Count, Is.EqualTo(0)); //Assert.That(applied.Target, Is.Not.Null); Collection <SvnMergesEligibleEventArgs> available; client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available); Assert.That(available, Is.Not.Null); Assert.That(available.Count, Is.EqualTo(0)); /*Assert.That(available[0].Revision, Is.EqualTo(ci.Revision)); * //Assert.That(available.MergeRanges[0].End, Is.EqualTo(ci.Revision + 1)); * //Assert.That(available.MergeRanges[0].Inheritable, Is.True); * Assert.That(available[0].SourceUri, Is.Not.Null);*/ using (StreamWriter fs = File.AppendText(f1)) { fs.WriteLine("Fifth line"); } client.Commit(merge1); client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available); Assert.That(available, Is.Not.Null); Assert.That(available.Count, Is.EqualTo(1)); Assert.That(available[0].Revision, Is.EqualTo(3)); Assert.That(available[0].SourceUri, Is.Not.Null); client.Merge(merge2, fromUri, available[0].AsRange()); client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available); Assert.That(available, Is.Not.Null); Assert.That(available.Count, Is.EqualTo(0)); client.Commit(sbox.Wc); client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available); Assert.That(available, Is.Not.Null); Assert.That(available.Count, Is.EqualTo(0)); client.GetAppliedMergeInfo(new SvnPathTarget(merge2), out applied); Assert.That(applied, Is.Not.Null); Assert.That(applied.AppliedMerges.Count, Is.EqualTo(1)); Assert.That(applied.AppliedMerges[0].Uri, Is.EqualTo(fromUri)); Assert.That(applied.AppliedMerges[0].MergeRanges, Is.Not.Null); Assert.That(applied.AppliedMerges[0].MergeRanges.Count, Is.EqualTo(1)); Assert.That(applied.AppliedMerges[0].MergeRanges[0].Start, Is.EqualTo(ci.Revision + 1)); Assert.That(applied.AppliedMerges[0].MergeRanges[0].End, Is.EqualTo(ci.Revision + 2)); Assert.That(applied.AppliedMerges[0].MergeRanges[0].Inheritable, Is.True); Assert.That(applied.Target, Is.Not.Null); } }
public void AddDirectory(string dir) { using (var svn = new SvnClient()) svn.CreateDirectory(dir, new SvnCreateDirectoryArgs { CreateParents = true }); }
void Main2(String[] args) { // from where to where urls = new[] { "https://svn.code.sf.net/p/syncproj/code/", "https://github.com/tapika/syncProj.git/trunk" }; workDir = new[] { @"d:\Prototyping\svnSource", @"d:\Prototyping\svnTarget" }; Uri[] uris = new Uri[2]; for (int i = 0; i < urls.Length; i++) { uris[i] = new Uri(urls[i]); if (!Directory.Exists(workDir[i])) { if (i == 0) { svn.CheckOut(uris[i], workDir[i], new SvnCheckOutArgs() { Revision = new SvnRevision(i) }); } else { svn.CheckOut(uris[i], workDir[i]); } } } SvnInfoEventArgs info; svn.GetInfo(uris[0], out info); SvnLogArgs svnArgs = new SvnLogArgs { Start = 1 /*change next svn revision number*/, End = info.Revision, RetrieveAllProperties = true }; Collection <SvnLogEventArgs> list; svn.GetLog(uris[0], svnArgs, out list); foreach (SvnLogEventArgs log in list) { long rev = log.Revision; String msg = log.LogMessage; Console.WriteLine("Commit " + rev + ": " + msg); svn.Update(workDir[0], new SvnUpdateArgs() { Revision = new SvnRevision(rev) }); foreach (SvnChangeItem chItem in log.ChangedPaths) { String path = chItem.Path; switch (chItem.Action) { case SvnChangeAction.Add: if (chItem.NodeKind == SvnNodeKind.Directory) { try { svn.CreateDirectory(workDir[1] + path); } catch { } } else { File.Copy(workDir[0] + path, workDir[1] + path, true); try { svn.Add(workDir[1] + path); } catch { } } break; case SvnChangeAction.Replace: case SvnChangeAction.Delete: if (chItem.NodeKind == SvnNodeKind.Directory) { svn.Delete(workDir[1] + path); } else { File.Delete(workDir[1] + path); svn.Delete(workDir[1] + path); } break; case SvnChangeAction.Modify: if (chItem.NodeKind == SvnNodeKind.Directory) { Collection <SvnPropertyListEventArgs> propList = null; svn.GetPropertyList(new SvnPathTarget(workDir[0] + path), out propList); foreach (SvnPropertyListEventArgs p in propList) { foreach (SvnPropertyValue pv in p.Properties) { svn.SetProperty(workDir[1] + path, pv.Key, pv.StringValue); } } } else { File.Copy(workDir[0] + path, workDir[1] + path, true); } break; } } svn.Commit(workDir[1], new SvnCommitArgs() { LogMessage = msg }); } }