public void TestNonExistentPropertyExistingFile() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); string wc = sbox.Wc; Client.CheckOut(new Uri(CollabReposUri, "trunk"), wc); SvnGetPropertyArgs pa = new SvnGetPropertyArgs(); pa.ThrowOnError = false; string value; Assert.That(Client.GetProperty(Path.Combine(wc, "index.html"), "new-prop", out value), Is.True, "GetProperty succeeds on non existent property"); Assert.That(value, Is.Null, "No value available"); }
public void GetPropertyValues() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); Uri trunk = new Uri(CollabReposUri, "trunk"); string dir = sbox.GetTempDir(); Client.CheckOut(trunk, dir); SvnGetPropertyArgs pa = new SvnGetPropertyArgs(); pa.Depth = SvnDepth.Infinity; SvnTargetPropertyCollection pc; Client.GetProperty(trunk, SvnPropertyNames.SvnEolStyle, pa, out pc); foreach (SvnPropertyValue pv in pc) { SvnUriTarget ut = pv.Target as SvnUriTarget; Assert.That(ut, Is.Not.Null); Uri relative = trunk.MakeRelativeUri(ut.Uri); Assert.That(!relative.ToString().StartsWith("/")); Assert.That(!relative.ToString().StartsWith("../")); } Client.GetProperty(dir, SvnPropertyNames.SvnEolStyle, pa, out pc); dir += "\\"; foreach (SvnPropertyValue pv in pc) { SvnPathTarget pt = pv.Target as SvnPathTarget; Assert.That(pt, Is.Not.Null); Assert.That(pt.TargetPath.StartsWith(dir)); } Assert.That(pc[dir + "index.html"], Is.Not.Null, "Can get wcroot\\index.html?"); }
private static void AddIgnores(IAnkhServiceProvider context, string path, List<string> ignores) { try { context.GetService<IProgressRunner>().RunModal(CommandStrings.IgnoreCaption, delegate(object sender, ProgressWorkerArgs e) { SvnGetPropertyArgs pa = new SvnGetPropertyArgs(); pa.ThrowOnError = false; SvnTargetPropertyCollection tpc; if (e.Client.GetProperty(path, SvnPropertyNames.SvnIgnore, pa, out tpc)) { SvnPropertyValue pv; if (tpc.Count > 0 && null != (pv = tpc[0]) && pv.StringValue != null) { int n = 0; foreach (string oldItem in pv.StringValue.Split('\n')) { string item = oldItem.TrimEnd('\r'); if (item.Trim().Length == 0) continue; // Don't add duplicates while (n < ignores.Count && ignores.IndexOf(item, n) >= 0) ignores.RemoveAt(ignores.IndexOf(item, n)); if (ignores.Contains(item)) continue; ignores.Insert(n++, item); } } StringBuilder sb = new StringBuilder(); bool next = false; foreach (string item in ignores) { if (next) sb.Append('\n'); // Subversion wants only newlines else next = true; sb.Append(item); } e.Client.SetProperty(path, SvnPropertyNames.SvnIgnore, sb.ToString()); } }); // Make sure a changed directory is visible in the PC Window context.GetService<IFileStatusMonitor>().ScheduleMonitor(path); } finally { // Ignore doesn't bubble context.GetService<IFileStatusCache>().MarkDirtyRecursive(path); } }
public static List<long> GetRecommendedRevisions(Source source) { List<long> list = new List<long>(); string value = string.Empty; using (SvnClient client = GetSvnClient()) { SvnGetPropertyArgs args = new SvnGetPropertyArgs { ThrowOnError = false }; SvnTargetPropertyCollection collection = new SvnTargetPropertyCollection(); client.GetProperty(source.Path, "svnmonitor:recommend", args, out collection); if ((collection != null) && (collection.Count == 1)) { SvnPropertyValue svnPropertyValue = collection[0]; value = svnPropertyValue.StringValue; } } GetRevisionsFromString(value, list); return list; }
private static void AddIgnores(IAnkhServiceProvider context, string path, List <string> ignores) { try { context.GetService <IProgressRunner>().RunModal(CommandStrings.IgnoreCaption, delegate(object sender, ProgressWorkerArgs e) { SvnGetPropertyArgs pa = new SvnGetPropertyArgs(); pa.ThrowOnError = false; SvnTargetPropertyCollection tpc; if (e.Client.GetProperty(path, SvnPropertyNames.SvnIgnore, pa, out tpc)) { SvnPropertyValue pv; if (tpc.Count > 0 && null != (pv = tpc[0]) && pv.StringValue != null) { int n = 0; foreach (string oldItem in pv.StringValue.Split('\n')) { string item = oldItem.TrimEnd('\r'); if (item.Trim().Length == 0) { continue; } // Don't add duplicates while (n < ignores.Count && ignores.IndexOf(item, n) >= 0) { ignores.RemoveAt(ignores.IndexOf(item, n)); } if (ignores.Contains(item)) { continue; } ignores.Insert(n++, item); } } StringBuilder sb = new StringBuilder(); bool next = false; foreach (string item in ignores) { if (next) { sb.Append('\n'); // Subversion wants only newlines } else { next = true; } sb.Append(item); } e.Client.SetProperty(path, SvnPropertyNames.SvnIgnore, sb.ToString()); } }); // Make sure a changed directory is visible in the PC Window context.GetService <IFileStatusMonitor>().ScheduleMonitor(path); } finally { // Ignore doesn't bubble context.GetService <ISvnStatusCache>().MarkDirtyRecursive(path); } }