/// <summary>Gets the repository url and repository id for a working copy path</summary> public unsafe bool TryGetRepository(string path, out Uri repositoryUrl, out Guid id) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (!IsNotUri(path)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(path)); } id = Guid.Empty; repositoryUrl = null; EnsureState(SvnContextState.ConfigLoaded); using (var pool = new AprPool(_pool)) using (var store = new NoArgsStore(this, pool)) { sbyte *urlStr = null; sbyte *uuidStr = null; svn_error_t err = svn_client.svn_client_get_repos_root( &urlStr, &uuidStr, pool.AllocAbsoluteDirent(path), CtxHandle, pool.Handle, pool.Handle); if (err != null || urlStr == null || uuidStr == null || *urlStr == 0 || *uuidStr == 0) { svn_error.svn_error_clear(err); return(false); } repositoryUrl = Utf8_PtrToUri(urlStr, SvnNodeKind.Directory); id = new Guid(Utf8_PtrToString(uuidStr)); return(true); } }
///////////////////////////////////////// /// <summary>Gets the repository Uri of a path, or <c>null</c> if path is not versioned</summary> /// <remarks>See also <see cref="SvnTools.GetUriFromWorkingCopy" /></remarks> public unsafe Uri GetUriFromWorkingCopy(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (!IsNotUri(path)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(path)); } var pool = new AprPool(_pool); var store = new NoArgsStore(this, pool); try { sbyte *url = null; svn_error_t err = svn_client.svn_client_url_from_path2( &url, pool.AllocAbsoluteDirent(path), CtxHandle, pool.Handle, pool.Handle); if (err == null && url != null) { return(Utf8_PtrToUri(url, Directory.Exists(path) ? SvnNodeKind.Directory : SvnNodeKind.File)); } if (err != null) { svn_error.svn_error_clear(err); } return(null); } finally { store.Dispose(); pool.Dispose(); } }
/// <summary>Gets the (relevant) working copy root of a path or <c>null</c> if the path doesn't have one</summary> public unsafe string GetWorkingCopyRoot(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (!IsNotUri(path)) { throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(path)); } sbyte *wcroot_abspath = null; EnsureState(SvnContextState.ConfigLoaded); using (var pool = new AprPool(_pool)) using (var store = new NoArgsStore(this, pool)) { svn_error_t err = svn_client.svn_client_get_wc_root( &wcroot_abspath, pool.AllocAbsoluteDirent(path), CtxHandle, pool.Handle, pool.Handle); if (err == null && wcroot_abspath != null) { return(Utf8_PathPtrToString(wcroot_abspath, pool)); } if (err != null) { svn_error.svn_error_clear(err); } return(null); } }