public void Path_TestPathToUri() { Uri root = new Uri("http://server/q/"); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("\\a b\\test")).AbsoluteUri, Is.EqualTo("http://server/a%20b/test")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("\\a b\\test\\")).AbsoluteUri, Is.EqualTo("http://server/a%20b/test/")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("\\c#\\test\\")).AbsoluteUri, Is.EqualTo("http://server/c%23/test/")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("a b\\test")).AbsoluteUri, Is.EqualTo("http://server/q/a%20b/test")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("a b\\test\\")).AbsoluteUri, Is.EqualTo("http://server/q/a%20b/test/")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("c#\\test\\")).AbsoluteUri, Is.EqualTo("http://server/q/c%23/test/")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("r\\a b\\test")).AbsoluteUri, Is.EqualTo("http://server/q/r/a%20b/test")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("r\\a b\\test\\")).AbsoluteUri, Is.EqualTo("http://server/q/r/a%20b/test/")); Assert.That(new Uri(root, SvnTools.PathToRelativeUri("r\\c#\\test\\")).AbsoluteUri, Is.EqualTo("http://server/q/r/c%23/test/")); }
void SetProjectRootValue(string value) { if (SolutionFilename == null) { return; } string sd = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedDirectoryName(SolutionFilename).TrimEnd('\\') + '\\').ToString(); string v = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedFullPath(value)).ToString(); if (!v.EndsWith("/")) { v += "/"; } if (!sd.StartsWith(v, StringComparison.OrdinalIgnoreCase)) { return; } Uri solUri; Uri resUri; if (!Uri.TryCreate("file:///" + sd.Replace('\\', '/'), UriKind.Absolute, out solUri) || !Uri.TryCreate("file:///" + v.Replace('\\', '/'), UriKind.Absolute, out resUri)) { return; } using (SvnClient client = GetService <ISvnClientPool>().GetNoUIClient()) { SvnSetPropertyArgs ps = new SvnSetPropertyArgs(); ps.ThrowOnError = false; client.SetProperty(SolutionFilename, AnkhSccPropertyNames.ProjectRoot, solUri.MakeRelativeUri(resUri).ToString(), ps); GetService <ISvnStatusCache>().MarkDirty(SolutionFilename); // The getter will reload the settings for us } _cache = null; }
public void List_WorstLocalDir() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); Uri uri = CollabReposUri; string tmp = sbox.GetTempDir(); Client.CheckOut(uri, tmp); string s1 = "start #"; string s2 = "q!@#$%^&()_- +={}[]',.eia"; string s3 = "done!"; string d = tmp; Directory.CreateDirectory(d = Path.Combine(d, s1)); Directory.CreateDirectory(d = Path.Combine(d, s2)); Directory.CreateDirectory(d = Path.Combine(d, s3)); string f1, f2; TouchFile(f1 = Path.Combine(d, "file.txt")); TouchFile(f2 = Path.Combine(d, s2 + ".txt")); SvnAddArgs aa = new SvnAddArgs(); aa.AddParents = true; Client.Add(f1, aa); Client.Add(f2, aa); Client.Commit(tmp); SvnInfoEventArgs ea; Client.GetInfo(d, out ea); Uri r = new Uri(new Uri(new Uri(uri, SvnTools.PathToRelativeUri(s1 + "/")), SvnTools.PathToRelativeUri(s2 + "/")), SvnTools.PathToRelativeUri(s3 + "/")); if (Environment.Version.Major < 4) { Assert.That(r.ToString(), Is.EqualTo(ea.Uri.ToString())); } // Run with a .Net normalized Uri Client.List(r, delegate(object sender, SvnListEventArgs e) { Assert.That(e.RepositoryRoot, Is.EqualTo(uri)); }); // Run with a SVN normalized Uri Client.List(ea.Uri, delegate(object sender, SvnListEventArgs e) { Assert.That(e.RepositoryRoot, Is.EqualTo(uri)); }); r = new Uri(new Uri(new Uri(uri, SvnTools.PathToRelativeUri(s1 + "//")), SvnTools.PathToRelativeUri(s2 + "///")), SvnTools.PathToRelativeUri(s3 + "////")); // Run with uncanonical Uri Client.List(r, delegate(object sender, SvnListEventArgs e) { Assert.That(e.RepositoryRoot, Is.EqualTo(uri)); }); }