public void ChangeInfo_GetInfoCompare() { SvnSandBox sbox = new SvnSandBox(this); Uri reposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); string reposPath = reposUri.LocalPath; using (SvnClient cl = new SvnClient()) { SvnSetPropertyArgs sa = new SvnSetPropertyArgs(); sa.BaseRevision = 17; sa.LogMessage = "Message"; cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa); } for (long ii = 1; ii < 19; ii++) { using (SvnLookClient lcl = new SvnLookClient()) using (SvnClient cl = new SvnClient()) { SvnChangeInfoEventArgs r; SvnChangeInfoArgs ia = new SvnChangeInfoArgs(); SvnLookOrigin origin = new SvnLookOrigin(reposPath, ii); SvnLogArgs la = new SvnLogArgs(); la.Start = la.End = ii; Collection <SvnLogEventArgs> lrc; //ia.RetrieveChangedPaths = false; // Will fail if true Assert.That(lcl.GetChangeInfo(origin, ia, out r)); Assert.That(cl.GetLog(reposUri, la, out lrc)); Assert.That(r, Is.Not.Null); Assert.That(lrc.Count, Is.EqualTo(1)); SvnLogEventArgs lr = lrc[0]; Assert.That(r.Author, Is.EqualTo(lr.Author)); Assert.That(r.Revision, Is.EqualTo(lr.Revision)); Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1)); Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage)); Assert.That(r.Time, Is.EqualTo(lr.Time)); Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii); Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii); Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count)); for (int i = 0; i < r.ChangedPaths.Count; i++) { SvnChangeItem c = r.ChangedPaths[i]; SvnChangeItem lc = lr.ChangedPaths[c.Path]; Assert.That(c.Path, Is.EqualTo(lc.Path)); Assert.That(c.Action, Is.EqualTo(lc.Action)); Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath)); Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision)); } } } }
public void SetProperty_SetRecursivly() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); string WcPath = sbox.Wc; string filePath = Path.Combine(WcPath, "Form.cs"); byte[] propval = Encoding.UTF8.GetBytes("baa"); bool ticked = false; SvnSetPropertyArgs a = new SvnSetPropertyArgs(); a.Notify += delegate(object sender, SvnNotifyEventArgs e) { ticked = true; }; a.Depth = SvnDepth.Infinity; this.Client.SetProperty(WcPath, "moo", propval, a); if (SvnClient.Version >= new Version(1, 6)) { Assert.That(ticked, Is.True); } Assert.That(this.RunCommand("svn", "propget moo " + WcPath).Trim(), Is.EqualTo("baa"), "PropSet didn't work on directory!"); Assert.That(this.RunCommand("svn", "propget moo " + filePath).Trim(), Is.EqualTo("baa"), "PropSet didn't work on file!"); }
public void TestIprops() { SvnSandBox sbox = new SvnSandBox(this); Uri uri = sbox.CreateRepository(SandBoxRepository.MergeScenario); string wc = sbox.Wc; SvnSetPropertyArgs pa = new SvnSetPropertyArgs(); pa.BaseRevision = 17; Client.RemoteSetProperty(uri, "root", "root", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk"), "trunk", "trunk", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk/jobs"), "jobs", "jobs", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk/jobs/index.html"), "index", "index", pa); SvnUpdateResult ur; Client.CheckOut(new Uri(uri, "trunk"), wc, out ur); Assert.That(ur.Revision, Is.EqualTo(pa.BaseRevision + 1)); Client.SetProperty(wc, "local-trunk", "local-trunk"); Client.SetProperty(Path.Combine(wc, "jobs"), "local-jobs", "local-jobs"); Collection <SvnInheritedPropertyListEventArgs> results; string target = Path.Combine(wc, "jobs/index.html"); Client.GetInheritedPropertyList(Path.Combine(wc, "jobs/index.html"), out results); Assert.That(results, Is.Not.Null); Assert.That(results.Count, Is.EqualTo(4)); Assert.That(results[0].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(target)), "Path 0"); Assert.That(results[0].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/index.html"))); Assert.That(results[0].Properties, Is.Not.Empty); Assert.That(results[1].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, ".."))), "Path 1"); Assert.That(results[1].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/"))); Assert.That(results[1].Properties, Is.Not.Empty); Assert.That(results[2].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, "../.."))), "Path 2"); Assert.That(results[2].Uri, Is.EqualTo(new Uri(uri, "trunk/"))); Assert.That(results[2].Properties, Is.Not.Empty); Assert.That(results[3].Uri, Is.EqualTo(uri), "Path 3"); Assert.That(results[3].Properties, Is.Not.Empty); SvnPropertyCollection pc; Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "nop"), out pc), Is.False); Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "jobs"), out pc)); Assert.That(pc, Is.Not.Empty); Assert.That(pc.Contains("trunk"), "Contains trunk"); }
public void SaveProperty(string propertyName, string value, string target, bool recursive, bool skipChecks) { try { SvnSetPropertyArgs args = new SvnSetPropertyArgs(); args.SkipChecks = skipChecks; args.Depth = recursive ? SvnDepth.Infinity : SvnDepth.Children; client.SetProperty(target, propertyName, value, args); } catch (Exception ex) { OnError(ex); } }
public void TestIprops() { SvnSandBox sbox = new SvnSandBox(this); Uri uri = sbox.CreateRepository(SandBoxRepository.MergeScenario); string wc = sbox.Wc; SvnSetPropertyArgs pa = new SvnSetPropertyArgs(); pa.BaseRevision = 17; Client.RemoteSetProperty(uri, "root", "root", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk"), "trunk", "trunk", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk/jobs"), "jobs", "jobs", pa); pa.BaseRevision++; Client.RemoteSetProperty(new Uri(uri, "trunk/jobs/index.html"), "index", "index", pa); SvnUpdateResult ur; Client.CheckOut(new Uri(uri, "trunk"), wc, out ur); Assert.That(ur.Revision, Is.EqualTo(pa.BaseRevision + 1)); Client.SetProperty(wc, "local-trunk", "local-trunk"); Client.SetProperty(Path.Combine(wc, "jobs"), "local-jobs", "local-jobs"); Collection<SvnInheritedPropertyListEventArgs> results; string target = Path.Combine(wc, "jobs/index.html"); Client.GetInheritedPropertyList(Path.Combine(wc, "jobs/index.html"), out results); Assert.That(results, Is.Not.Null); Assert.That(results.Count, Is.EqualTo(4)); Assert.That(results[0].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(target)), "Path 0"); Assert.That(results[0].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/index.html"))); Assert.That(results[0].Properties, Is.Not.Empty); Assert.That(results[1].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, ".."))), "Path 1"); Assert.That(results[1].Uri, Is.EqualTo(new Uri(uri, "trunk/jobs/"))); Assert.That(results[1].Properties, Is.Not.Empty); Assert.That(results[2].Path, Is.EqualTo(SvnTools.GetNormalizedFullPath(Path.Combine(target, "../.."))), "Path 2"); Assert.That(results[2].Uri, Is.EqualTo(new Uri(uri, "trunk/"))); Assert.That(results[2].Properties, Is.Not.Empty); Assert.That(results[3].Uri, Is.EqualTo(uri), "Path 3"); Assert.That(results[3].Properties, Is.Not.Empty); SvnPropertyCollection pc; Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "nop"), out pc), Is.False); Assert.That(Client.TryGetAllInheritedProperties(Path.Combine(wc, "jobs"), out pc)); Assert.That(pc, Is.Not.Empty); Assert.That(pc.Contains("trunk"), "Contains trunk"); }
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; }
/// <summary> /// Add to ignore list... /// </summary> /// <param name="filePath"></param> /// <returns></returns> public bool Ignore(string value) { var returnValue = false; try { //Get Uri from file path var uri = _svnClient.GetUriFromWorkingCopy(_repo); // To Get the Latest Revision on the Required SVN Folder SvnInfoEventArgs info; _svnClient.GetInfo(uri, out info); //SvnGetPropertyArgs getPropertyArgs = new SvnGetPropertyArgs() //{ // Revision = info.Revision //}; //_svnClient.GetProperty(uri, "svn:ignore", getPropertyArgs, out SvnTargetPropertyCollection x); // Prepare a PropertyArgs object with latest revision and a commit message; SvnSetPropertyArgs setPropertyArgs = new SvnSetPropertyArgs() { BaseRevision = info.Revision, LogMessage = "SVN Ignore" }; // Set property to file in the svn directory returnValue = _svnClient.RemoteSetProperty(uri, "svn:ignore", value, setPropertyArgs); _svnClient.Update(_repo); } catch (Exception ex) { Console.WriteLine(ex); } return(returnValue); }
public static bool WriteExternals(SvnClient client, string externalsHostUrl, SvnExternalItem[] extItems, long revision) { // reassemble value from parsed items var sb = new StringBuilder(); foreach (var ei in extItems) { ei.WriteTo(sb, false); sb.Append("\r\n"); } var externalsPropValue = sb.ToString(); // - set svn:external property back to given url + ext.LocalPath var args = new SvnSetPropertyArgs(); args.BaseRevision = revision; args.LogMessage = ""; if (!client.RemoteSetProperty(new Uri(externalsHostUrl), "svn:externals", externalsPropValue, args)) { return(false); } return(true); }
internal void HandleEvent(AnkhCommand command) { List <SccProject> dirtyProjects; HybridCollection <string> dirtyCheck; HybridCollection <string> maybeAdd; SvnSccProvider provider = GetService <SvnSccProvider>(); lock (_lock) { _posted = false; _onIdle = false; if (provider == null) { return; } dirtyProjects = _dirtyProjects; dirtyCheck = _dirtyCheck; maybeAdd = _maybeAdd; _dirtyProjects = null; _dirtyCheck = null; _maybeAdd = null; } if (dirtyCheck != null) { foreach (string file in dirtyCheck) { DocumentTracker.CheckDirty(file); } } if (dirtyProjects != null) { foreach (SccProject project in dirtyProjects) { if (project.IsSolution) { provider.UpdateSolutionGlyph(); } else { project.NotifyGlyphChanged(); } } } if (maybeAdd != null) { using (SvnClient cl = GetService <ISvnClientPool>().GetNoUIClient()) { foreach (string file in maybeAdd) { SvnItem item = SvnCache[file]; // Only add // * files // * that are unversioned // * that are addable // * that are not ignored // * and just to be sure: that are still part of the solution if (item.IsFile && !item.IsVersioned && item.IsVersionable && !item.IsIgnored && item.InSolution && !item.IsSccExcluded) { SvnAddArgs aa = new SvnAddArgs(); aa.ThrowOnError = false; // Just ignore errors here; make the user add them themselves aa.AddParents = true; if (cl.Add(item.FullPath, aa)) { item.MarkDirty(); // Detect if we have a file that Subversion might detect as binary if (item.IsVersioned && !item.IsTextFile) { // Only check small files, avoid checking big binary files FileInfo fi = new FileInfo(item.FullPath); if (fi.Length < 10) { // We're sure it's at most 10 bytes here, so just read all byte[] fileBytes = File.ReadAllBytes(item.FullPath); // If the file starts with a UTF8 BOM, we're sure enough it's a text file, keep UTF16 & 32 binary if (StartsWith(fileBytes, new byte[] { 0xEF, 0xBB, 0xBF })) { // Delete the mime type property, so it's detected as a text file again SvnSetPropertyArgs pa = new SvnSetPropertyArgs(); pa.ThrowOnError = false; cl.DeleteProperty(item.FullPath, SvnPropertyNames.SvnMimeType, pa); } } } } } } } } }
public void ChangeInfo_GetInfoCompare() { SvnSandBox sbox = new SvnSandBox(this); Uri reposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); string reposPath = reposUri.LocalPath; using (SvnClient cl = new SvnClient()) { SvnSetPropertyArgs sa = new SvnSetPropertyArgs(); sa.BaseRevision = 17; sa.LogMessage = "Message"; cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa); } for (long ii = 1; ii < 19; ii++) { using (SvnLookClient lcl = new SvnLookClient()) using (SvnClient cl = new SvnClient()) { SvnChangeInfoEventArgs r; SvnChangeInfoArgs ia = new SvnChangeInfoArgs(); SvnLookOrigin origin = new SvnLookOrigin(reposPath, ii); SvnLogArgs la = new SvnLogArgs(); la.Start = la.End = ii; Collection<SvnLogEventArgs> lrc; //ia.RetrieveChangedPaths = false; // Will fail if true Assert.That(lcl.GetChangeInfo(origin, ia, out r)); Assert.That(cl.GetLog(reposUri, la, out lrc)); Assert.That(r, Is.Not.Null); Assert.That(lrc.Count, Is.EqualTo(1)); SvnLogEventArgs lr = lrc[0]; Assert.That(r.Author, Is.EqualTo(lr.Author)); Assert.That(r.Revision, Is.EqualTo(lr.Revision)); Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1)); Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage)); Assert.That(r.Time, Is.EqualTo(lr.Time)); Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii); Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii); Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count)); for (int i = 0; i < r.ChangedPaths.Count; i++) { SvnChangeItem c = r.ChangedPaths[i]; SvnChangeItem lc = lr.ChangedPaths[c.Path]; Assert.That(c.Path, Is.EqualTo(lc.Path)); Assert.That(c.Action, Is.EqualTo(lc.Action)); Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath)); Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision)); } } } }
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<IFileStatusCache>().MarkDirty(SolutionFilename); // The getter will reload the settings for us } _cache = null; }