/// <summary>Updates the specified paths to the specified revision</summary> /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception> /// <exception type="ArgumentException">Parameters invalid</exception> /// <returns>true if the operation succeeded; false if it did not</returns> public unsafe bool Update(ICollection <string> paths, SvnUpdateArgs args, out SvnUpdateResult updateResult) { if (paths == null) { throw new ArgumentNullException(nameof(paths)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } updateResult = null; foreach (string s in paths) { if (string.IsNullOrEmpty(s)) { throw new ArgumentException(SharpSvnStrings.ItemInListIsNull, nameof(paths)); } if (!IsNotUri(s)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(paths)); } } EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); var aprPaths = new AprArray <string, AprCStrDirentMarshaller>(paths, pool); apr_array_header_t.__Internal *revs_ptr = null; svn_opt_revision_t uRev = args.Revision.Or(SvnRevision.Head).AllocSvnRevision(pool); svn_error_t r = svn_client.svn_client_update4( (void **)&revs_ptr, aprPaths.Handle, uRev, (svn_depth_t)args.Depth, args.KeepDepth, args.IgnoreExternals, args.AllowObstructions, args.AddsAsModifications, args.UpdateParents, CtxHandle, pool.Handle); if (args.HandleResult(this, r, paths)) { var revs = apr_array_header_t.__CreateInstance(new IntPtr(revs_ptr)); var aprRevs = new AprArray <long, AprSvnRevNumMarshaller>(revs, pool); updateResult = new SvnUpdateResult(paths, aprRevs.ToArray(), (paths.Count >= 1) ? aprRevs[0] : -1); return(true); } return(false); }
/// <summary>Streamingly lists directory entries in the repository. (<c>svn list</c>)</summary> public unsafe bool List(SvnTarget target, SvnListArgs args, EventHandler <SvnListEventArgs> listHandler) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } // We allow a null listHandler; the args object might just handle it itself EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); args.Prepare(target, args.Revision.RevisionType != SvnRevisionType.None); if (listHandler != null) { args.List += listHandler; } try { svn_opt_revision_t pegrev = target.Revision.AllocSvnRevision(pool); svn_opt_revision_t rev = args.Revision.Or(target.Revision).AllocSvnRevision(pool); using var svnclient_list_func_handle = new SafeFuncHandle <svn_client_list_func2_t>(svnclient_list_handler); svn_error_t r = svn_client.svn_client_list3( target.AllocAsString(pool), pegrev, rev, (svn_depth_t)args.Depth, (uint)args.RetrieveEntries, args.RetrieveLocks, args.IncludeExternals, svnclient_list_func_handle.Get(), _clientBaton.Handle, CtxHandle, pool.Handle); return(args.HandleResult(this, r, target)); } finally { if (listHandler != null) { args.List -= listHandler; } } }
/// <summary>Performs a checkout of <paramref name="url" /> to <paramref name="path" /> to the specified param</summary> /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception> /// <exception type="ArgumentException">Parameters invalid</exception> /// <returns>true if the operation succeeded; false if it did not</returns> public unsafe bool CheckOut(SvnUriTarget url, string path, SvnCheckOutArgs args, out SvnUpdateResult result) { if (url == null) { throw new ArgumentNullException(nameof(url)); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } if (args.Revision.RequiresWorkingCopy) { throw new ArgumentException(SharpSvnStrings.RevisionTypeMustBeHeadDateOrSpecific, nameof(args)); } if (url.Revision.RequiresWorkingCopy) { throw new ArgumentException(SharpSvnStrings.RevisionTypeMustBeHeadDateOrSpecific, nameof(url)); } EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); int version = 0; svn_opt_revision_t pegRev = url.Revision.AllocSvnRevision(pool); svn_opt_revision_t coRev = args.Revision.Or(url.Revision).Or(SvnRevision.Head).AllocSvnRevision(pool); svn_error_t r = svn_client.svn_client_checkout3( ref version, pool.AllocUri(url.Uri), pool.AllocDirent(path), pegRev, coRev, (svn_depth_t)args.Depth, args.IgnoreExternals, args.AllowObstructions, CtxHandle, pool.Handle); result = SvnUpdateResult.Create(this, args, version); return(args.HandleResult(this, r, url)); }
/// <summary>Exports the specified target to the specified path</summary> /// <remarks>Subversion optimizes this call if you specify a workingcopy file instead of an url</remarks> public unsafe bool Export(SvnTarget from, string toPath, SvnExportArgs args, out SvnUpdateResult result) { if (from == null) { throw new ArgumentNullException(nameof(from)); } if (toPath == null) { throw new ArgumentNullException(nameof(toPath)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); result = null; int resultRev = 0; svn_opt_revision_t pegRev = from.Revision.AllocSvnRevision(pool); svn_opt_revision_t rev = args.Revision.Or(from.GetSvnRevision(SvnRevision.Working, SvnRevision.Head)).AllocSvnRevision(pool); svn_error_t r = svn_client.svn_client_export5( ref resultRev, from.AllocAsString(pool), pool.AllocDirent(toPath), pegRev, rev, args.Overwrite, args.IgnoreExternals, args.IgnoreKeywords, (svn_depth_t)args.Depth, pool.AllocString(GetEolPtr(args.LineStyle)), CtxHandle, pool.Handle); if (args.HandleResult(this, r, from)) { result = SvnUpdateResult.Create(this, args, resultRev); return(true); } return(false); }
internal static SvnRevision Load(svn_opt_revision_t revData) { if (revData == null) { throw new ArgumentNullException(nameof(revData)); } var type = (SvnRevisionType)revData.kind; switch (type) { case SvnRevisionType.None: return(None); case SvnRevisionType.Committed: return(Committed); case SvnRevisionType.Previous: return(Previous); case SvnRevisionType.Base: return(Base); case SvnRevisionType.Working: return(Working); case SvnRevisionType.Head: return(Head); case SvnRevisionType.Number: if (revData.value.number == 0) { return(Zero); } if (revData.value.number == 1) { return(One); } return(new SvnRevision(revData.value.number)); case SvnRevisionType.Time: // apr_time_t is in microseconds since 1-1-1970 UTC; filetime is in 100 nanoseconds return(new SvnRevision(SvnBase.DateTimeFromAprTime(revData.value.date))); default: throw new ArgumentException(SharpSvnStrings.InvalidSvnRevisionTypeValue, nameof(revData)); } }
unsafe bool InternalWrite(SvnTarget target, Stream output, SvnWriteArgs args, apr_hash_t.__Internal **props, AprPool resultPool) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } if (args == null) { throw new ObjectDisposedException(nameof(args)); } using var scratchPool = new AprPool(resultPool); EnsureState(SvnContextState.AuthorizationInitialized); using var store = new ArgsStore(this, args, scratchPool); using var wrapper = new SvnStreamWrapper(output, false, true, scratchPool); svn_opt_revision_t pegRev = target.Revision.AllocSvnRevision(scratchPool); svn_opt_revision_t rev = args.Revision.Or(target.Revision).AllocSvnRevision(scratchPool); svn_error_t r = svn_client.svn_client_cat3( (void **)props, wrapper.Handle, target.AllocAsString(scratchPool, true), pegRev, rev, !args.IgnoreKeywords, CtxHandle, resultPool.Handle, scratchPool.Handle); return(args.HandleResult(this, r, target)); }
unsafe bool InternalLog(ICollection <string> targets, Uri searchRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler <SvnLogEventArgs> logHandler) { if (targets == null) { throw new ArgumentNullException(nameof(targets)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); args._mergeLogLevel = 0; // Clear log level args._searchRoot = searchRoot; if (logHandler != null) { args.Log += logHandler; } try { apr_array_header_t retrieveProperties; if (args.RetrieveAllProperties) { retrieveProperties = null; } else if (args.RetrievePropertiesUsed) { retrieveProperties = AllocArray(args.RetrieveProperties, pool); } else { retrieveProperties = svn_compat.svn_compat_log_revprops_in(pool.Handle); } svn_opt_revision_t pegRev = args.OriginRevision.Or(altPegRev).AllocSvnRevision(pool); int count = args.RangesUsed ? args.Ranges.Count : 1; var revisionRanges = apr_tables.apr_array_make( pool.Handle, count, sizeof(svn_opt_revision_range_t.__Internal *)); if (args.RangesUsed) { foreach (SvnRevisionRange r in args.Ranges) { var range = (svn_opt_revision_range_t.__Internal *)pool.Alloc( sizeof(svn_opt_revision_range_t.__Internal)); range->start = r.StartRevision.Or(SvnRevision.Head).ToSvnRevision(); range->end = r.EndRevision.Or(SvnRevision.Zero).ToSvnRevision(); *((svn_opt_revision_range_t.__Internal * *)apr_tables.apr_array_push(revisionRanges)) = range; } } else { var range = (svn_opt_revision_range_t.__Internal *)pool.Alloc( sizeof(svn_opt_revision_range_t.__Internal)); range->start = args.Start.Or(args.OriginRevision).Or(SvnRevision.Head).ToSvnRevision(); range->end = args.End.Or(SvnRevision.Zero).ToSvnRevision(); *((svn_opt_revision_range_t.__Internal * *)apr_tables.apr_array_push(revisionRanges)) = range; } using var svnclient_log_receiver_handle = new SafeFuncHandle <svn_log_entry_receiver_t>(svnclient_log_handler); svn_error_t err = svn_client.svn_client_log5( AllocArray(targets, pool), pegRev, revisionRanges, args.Limit, args.RetrieveChangedPaths, args.StrictNodeHistory, args.RetrieveMergedRevisions, retrieveProperties, svnclient_log_receiver_handle.Get(), _clientBaton.Handle, CtxHandle, pool.Handle); return(args.HandleResult(this, err, targets)); } finally { if (logHandler != null) { args.Log -= logHandler; } args._searchRoot = null; args._mergeLogLevel = 0; } }
/// <summary>Duplicate something in repository, remembering history (<c>svn copy</c>)</summary> /// <remarks>Can be called with either a list of <see cref="SvnTarget" />, <see cref="SvnUriTarget" /> or <see cref="SvnPathTarget" />. /// All members must be of the same type.</remarks> public unsafe bool RemoteCopy <TSvnTarget>(ICollection <TSvnTarget> sources, Uri toUri, SvnCopyArgs args, out SvnCommitResult result) where TSvnTarget : SvnTarget { if (sources == null) { throw new ArgumentNullException(nameof(sources)); } if (toUri == null) { throw new ArgumentNullException(nameof(toUri)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } if (!SvnBase.IsValidReposUri(toUri)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAValidRepositoryUri, nameof(toUri)); } if (sources.Count == 0) { throw new ArgumentException(SharpSvnStrings.CollectionMustContainAtLeastOneItem, nameof(sources)); } bool isFirst = true; bool isLocal = false; foreach (SvnTarget target in sources) { if (target == null) { throw new ArgumentException(SharpSvnStrings.ItemInListIsNull, nameof(sources)); } SvnPathTarget pt = target as SvnPathTarget; if (isFirst) { isLocal = (null != pt); isFirst = false; } else if (isLocal != (null != pt)) { throw new ArgumentException(SharpSvnStrings.AllTargetsMustBeUriOrPath, nameof(sources)); } } EnsureState(SvnContextState.AuthorizationInitialized); using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); using var crr = new CommitResultReceiver(this); apr_array_header_t copies = AllocCopyArray(sources, pool); if (copies != null && args.Revision.RevisionType != SvnRevisionType.None) { svn_opt_revision_t rev = args.Revision.AllocSvnRevision(pool); for (int i = 0; i < copies.nelts; i++) { var cp = ((svn_client_copy_source_t.__Internal * *)copies.elts)[i]; cp->revision = rev.__Instance; } } svn_error_t r = svn_client.svn_client_copy7( copies, pool.AllocUri(toUri), args.AlwaysCopyAsChild || (sources.Count > 1), args.CreateParents, args.IgnoreExternals, args.MetaDataOnly, args.PinExternals, null /* */, CreateRevPropList(args.LogProperties, pool), crr.CommitCallback.Get(), crr.CommitBaton, CtxHandle, pool.Handle); result = crr.CommitResult; return(args.HandleResult(this, r, sources)); }
/// <summary>Gets status data for the specified path</summary> public unsafe bool Status(string path, SvnStatusArgs args, EventHandler <SvnStatusEventArgs> statusHandler) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } if (!IsNotUri(path)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(path)); } // We allow a null statusHandler; the args object might just handle it itself if (args.ContactRepository) { EnsureState(SvnContextState.AuthorizationInitialized); } else { EnsureState(SvnContextState.ConfigLoaded); } using var pool = new AprPool(_pool); using var store = new ArgsStore(this, args, pool); if (statusHandler != null) { args.Status += statusHandler; } try { int version = 0; svn_opt_revision_t pegRev = args.Revision.AllocSvnRevision(pool); using var svnclient_status_func_handle = new SafeFuncHandle <svn_client_status_func_t>(svnclient_status_handler); svn_error_t r = svn_client.svn_client_status6( ref version, CtxHandle, pool.AllocDirent(path), pegRev, (svn_depth_t)args.Depth, args.RetrieveAllEntries, args.RetrieveRemoteStatus, !args.IgnoreWorkingCopyStatus, args.RetrieveIgnoredEntries, args.IgnoreExternals, args.KeepDepth, CreateChangeListsList(args.ChangeLists, pool), // Intersect ChangeLists svnclient_status_func_handle.Get(), _clientBaton.Handle, pool.Handle); return(args.HandleResult(this, r, path)); } finally { if (statusHandler != null) { args.Status -= statusHandler; } } }
private SvnOptRevision(svn_opt_revision_t *ptr) { mOptRevision = ptr; }