/// <summary> /// Reverts a working copy specified by <paramref name="path"/> to its original state. /// </summary> /// <param name="path">Working copy path.</param> /// <param name="depth">Affective depth of the command.</param> public void Revert(string path, DepthType depth) { SvnCommandOptions options = _defaultOptions.Clone(); options.Depth = depth; options.Paths.Add(SvnPath.CreateWCPath(path)); _command.Run("revert", options); }
/// <summary> /// Commits changes to working copy <paramref name="paths"/>. /// </summary> /// <param name="paths"></param> public void Commit(List <string> paths, string comment) { SvnCommandOptions options = _defaultOptions.Clone(); options.Comment = comment; paths.ForEach(p => options.Paths.Add(SvnPath.CreateWCPath(p))); _command.Run("commit", options); }
/// <summary> /// Checks out the <paramref name="uri"/> to the <paramref name="workingCopyPath"/>. /// </summary> /// <param name="uri"></param> /// <param name="workingCopyPath"></param> public void CheckOut(string uri, string workingCopyPath, Revision revision) { SvnCommandOptions options = _defaultOptions.Clone(); options.Revision = revision; options.Paths.Add(SvnPath.CreateSvnPath(uri)); options.Paths.Add(SvnPath.CreateWCPath(workingCopyPath)); _command.Run("checkout", options); }
/// <summary> /// Updates the working copy specified in <paramref name="path"/> to the specified numeric <paramref name="revision"/>. /// </summary> /// <param name="path">Working copy path to update.</param> /// <param name="revision">Numeric revision to which the working path will be updated.</param> /// <param name="depth">The depth to which the operation will apply.</param> public void Update(string path, Revision revision, DepthType depth) { SvnCommandOptions options = _defaultOptions.Clone(); options.Revision = revision; options.Depth = depth; options.Paths.Add(SvnPath.CreateWCPath(path)); _command.Run("update", options); }
private void ScheduleChange(string command, bool noignore, string[] paths) { SvnCommandOptions options = _defaultOptions.Clone(); options.IgnoreStandardExcludes = !noignore; foreach (var path in paths) { options.Paths.Add(SvnPath.CreateWCPath(path)); } _command.Run(command, options); }
/// <summary> /// Exports the <paramref name="depth"/> of the <paramref name="revision" /> of the <paramref name="uri"/> to the <paramref name="localPath"/>. /// </summary> /// <param name="uri">URI to export.</param> /// <param name="revision">Repository revision to export.</param> /// <param name="depth">Depth of the export.</param> /// <param name="localPath">Local path to which the files will be exported.</param> /// <param name="force">Whether or not to force overwrite existing files. Required if target directory exists, even if empty.</param> public void Export(string uri, Revision revision, DepthType depth, string localPath, bool force) { SvnCommandOptions options = _defaultOptions.Clone(); options.Revision = revision; options.Depth = depth; options.MiscArgs.Add(force ? "--force" : null); options.Paths.Add(SvnPath.CreateSvnPath(uri)); options.Paths.Add(SvnPath.CreateWCPath(localPath)); _command.Run("export", options); }
/// <summary> /// Returns whether or not the specified <paramref name="path"/> is a working copy. /// </summary> /// <param name="path">The local path to check.</param> /// <returns></returns> public bool IsWorkingCopy(string path) { try { SvnCommandOptions options = _defaultOptions.Clone(); options.Paths.Add(SvnPath.CreateWCPath(path)); options.Depth = DepthType.Empty; _command.GetXml("status", options); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Checks the path status for any items that have changes (add, modify or delete) /// with the option of including unversioned files. /// </summary> /// <param name="path">Working copy path to check.</param> /// <returns></returns> public bool PathHasChanges(string path, bool includeUnversioned) { XmlDocument objXml = new XmlDocument(); XmlNodeList lstNodes; SvnCommandOptions options = _defaultOptions.Clone(); options.Paths.Add(SvnPath.CreateWCPath(path)); objXml = _command.GetXml("status", options); string strFilter = "@item='deleted' or @item='added' or @item='modified' or @item='missing'"; if (includeUnversioned) { strFilter = string.Concat(strFilter, " or @item='unversioned'"); } lstNodes = objXml.SelectNodes(string.Format("//wc-status[{0}]", strFilter)); return(lstNodes.Count > 0); }
/// <summary> /// Schedules appropriate changes to working copy: adds unversioned files and deletes missing files. /// </summary> /// <param name="path">Working copy path to modify.</param> /// <param name="noIgnore">Whether not to ignore the default ignores.</param> public bool ScheduleChanges(string path, bool noIgnore) { XmlDocument xmlDoc; XmlNodeList xmlNodes; XmlNode objStatusNode; List <string> lstDeletes = new List <string>(); List <string> lstAdds = new List <string>(); string nodePath, nodeAction; int skip = 0, take = 10; DoDebugMessage("retrieving working copy status"); SvnCommandOptions options = _defaultOptions; options.Paths.Add(SvnPath.CreateWCPath(path)); xmlDoc = _command.GetXml("status", options); xmlNodes = xmlDoc.SelectNodes("//entry[wc-status/@item!='normal']"); if (xmlNodes.Count > 0) { foreach (XmlNode node in xmlNodes) { objStatusNode = node.SelectSingleNode("wc-status"); nodeAction = objStatusNode.Attributes["item"].Value; nodePath = node.Attributes["path"].Value; switch (nodeAction) { case "missing": DoVerboseMessage("found missing item: {0}", nodePath); lstDeletes.Add(nodePath); break; case "unversioned": DoVerboseMessage("found unversioned item: {0}", nodePath); lstAdds.Add(nodePath); break; default: DoDebugMessage("ignoring action '{0}' on path '{1}'", nodeAction, nodePath); break; } } if (lstAdds.Count > 0) { skip = 0; DoDebugMessage("scheduling add changes in chunks of '{0}'", take); while (lstAdds.Count > skip) { DoDebugMessage("scheduling the next {0} adds", take); ScheduleChange("add", noIgnore, lstAdds.Skip(skip).Take(take).ToArray()); skip += take; } } if (lstDeletes.Count > 0) { skip = 0; DoDebugMessage("scheduling delete changes in chunks of '{0}'", take); while (lstDeletes.Count > skip) { DoDebugMessage("scheduling the next {0} deletes", take + skip); ScheduleChange("delete", false, lstDeletes.Skip(skip).Take(take).ToArray()); skip += take; } } return(true); } else { return(false); } }
/// <summary> /// Gets the SVN status of the supplied working copy <paramref name="path"/>. /// </summary> /// <param name="path"></param> /// <returns></returns> public string GetPathStatus(string path) { return(GetStatusValue(SvnPath.CreateWCPath(path), "/status/target/entry/wc-status/@item")); }