// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo(FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo(new FilePath[] { localPath }, queryFlags).ToArray(); if (infos.Length != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } return(infos.Single()); }
// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo(FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo(new FilePath[] { localPath }, queryFlags).ToArray(); if (infos.Length != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } try { return(infos.Single()); } catch (InvalidOperationException) { // Workaround for #17216. return(infos [0]); } }
public bool TryGetVersionInfo(IEnumerable <FilePath> paths, VersionInfoQueryFlags queryFlags, out IReadOnlyList <VersionInfo> infos) { var result = new List <VersionInfo> (); var pathsToQuery = new List <FilePath> (); bool getVersionInfoFailed = false; foreach (var path in paths) { var vi = infoCache.GetStatus(path); if (vi != null) { result.Add(vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) { pathsToQuery.Add(path); } } else { pathsToQuery.Add(path); getVersionInfoFailed = true; } } if (pathsToQuery.Count > 0) { ExclusiveOperationFactory.StartNew(async delegate { // we don't care about initialization and setstatus async to happen on the exclusive thread, as we're not running a query here. var status = await OnGetVersionInfoAsync(paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0).ConfigureAwait(false); foreach (var vi in status) { if (!vi.IsInitialized) { await vi.InitAsync(this).ConfigureAwait(false); } } await infoCache.SetStatusAsync(status).ConfigureAwait(false); }).Ignore(); } if (getVersionInfoFailed) { infos = null; return(false); } infos = result; return(true); }
public bool TryGetVersionInfo(FilePath localPath, VersionInfoQueryFlags queryFlags, out VersionInfo info) { var result = TryGetVersionInfo(new FilePath [] { localPath }, queryFlags, out var infos); if (!result || infos == null) { info = null; return(false); } if (infos.Count != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Count, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } info = infos [0]; return(result); }
// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo(FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo(new FilePath[] { localPath }, queryFlags).ToArray(); if (infos.Length != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } // HACK: This was slowing down the IDE a lot in case in the eventuality of submodules. return(infos [0]); /*try { * return infos.Single (); * } catch (InvalidOperationException) { * // Workaround for #17216. * return infos [0]; * }*/ }
// Returns the versioning status of a file or directory public async Task <VersionInfo> GetVersionInfoAsync(FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None, CancellationToken cancellationToken = default) { var infos = await GetVersionInfoAsync(new FilePath [] { localPath }, queryFlags, cancellationToken); if (infos.Count != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Count, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } // HACK: This was slowing down the IDE a lot in case in the eventuality of submodules. return(infos [0]); /*try { * return infos.Single (); * } catch (InvalidOperationException) { * // Workaround for #17216. * return infos [0]; * }*/ }
/// <summary> /// Returns the versioning status of a set of files or directories /// </summary> /// <param name='paths'> /// A list of files or directories /// </param> /// <param name='queryFlags'> /// Use VersionInfoQueryFlags enum for options. /// </param> public async Task <IReadOnlyList <VersionInfo> > GetVersionInfoAsync(IEnumerable <FilePath> paths, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None, CancellationToken cancellationToken = default) { if ((queryFlags & VersionInfoQueryFlags.IgnoreCache) != 0) { // We shouldn't use IEnumerable because elements don't save property modifications. var res = await OnGetVersionInfoAsync(paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0, cancellationToken); foreach (var vi in res) { if (!vi.IsInitialized) { await vi.InitAsync(this, cancellationToken); } } await infoCache.SetStatusAsync(res, cancellationToken : cancellationToken); return(res); } var pathsToQuery = new List <FilePath> (); var result = new List <VersionInfo> (); foreach (var path in paths) { var vi = infoCache.GetStatus(path); if (vi != null) { result.Add(vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) { pathsToQuery.Add(path); } } else { // If there is no cached status, query it asynchronously vi = new VersionInfo(path, "", Directory.Exists(path), VersionStatus.Versioned, null, VersionStatus.Versioned, null); await infoCache.SetStatusAsync(vi, false); result.Add(vi); pathsToQuery.Add(path); } // Console.WriteLine ("GetVersionInfo " + string.Join (", ", paths.Select (p => p.FullPath))); } if (pathsToQuery.Count > 0) { ConcurrentOperationFactory.StartNew(async delegate { var status = await OnGetVersionInfoAsync(pathsToQuery, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0, cancellationToken); foreach (var vi in status) { if (!vi.IsInitialized) { await vi.InitAsync(this, cancellationToken); } } await infoCache.SetStatusAsync(status, cancellationToken); }).Ignore(); } return(result); }
/// <summary> /// Returns the versioning status of a set of files or directories /// </summary> /// <param name='paths'> /// A list of files or directories /// </param> /// <param name='queryFlags'> /// Use VersionInfoQueryFlags enum for options. /// </param> public IEnumerable<VersionInfo> GetVersionInfo (IEnumerable<FilePath> paths, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { if ((queryFlags & VersionInfoQueryFlags.IgnoreCache) != 0) { // We shouldn't use IEnumerable because elements don't save property modifications. var res = OnGetVersionInfo (paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0).ToList (); infoCache.SetStatus (res); return res; } List<FilePath> pathsToQuery = new List<FilePath> (); var result = new List<VersionInfo> (); foreach (var p in paths) { var vi = infoCache.GetStatus (p); if (vi != null) { result.Add (vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) pathsToQuery.Add (p); } else { // If there is no cached status, query it asynchronously vi = new VersionInfo (p, "", Directory.Exists (p), VersionStatus.Versioned, null, VersionStatus.Versioned, null); infoCache.SetStatus (vi, false); result.Add (vi); pathsToQuery.Add (p); } // Console.WriteLine ("GetVersionInfo " + string.Join (", ", paths.Select (p => p.FullPath))); } if (pathsToQuery.Count > 0) AddQuery (new VersionInfoQuery () { Paths = pathsToQuery, QueryFlags = queryFlags }); return result; }
// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo (FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo (new FilePath[] { localPath }, queryFlags).ToArray (); if (infos.Length != 1) { LoggingService.LogError ("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError ("The infos were: {0}", string.Join (" ::: ", infos.Select (i => i.LocalPath))); } // HACK: This was slowing down the IDE a lot in case in the eventuality of submodules. return infos [0]; /*try { return infos.Single (); } catch (InvalidOperationException) { // Workaround for #17216. return infos [0]; }*/ }
/// <summary> /// Returns the versioning status of a set of files or directories /// </summary> /// <param name='paths'> /// A list of files or directories /// </param> /// <param name='queryFlags'> /// Use VersionInfoQueryFlags enum for options. /// </param> public IEnumerable <VersionInfo> GetVersionInfo(IEnumerable <FilePath> paths, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { if ((queryFlags & VersionInfoQueryFlags.IgnoreCache) != 0) { // We shouldn't use IEnumerable because elements don't save property modifications. var res = OnGetVersionInfo(paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0).ToList(); infoCache.SetStatus(res); return(res); } List <FilePath> pathsToQuery = new List <FilePath> (); var result = new List <VersionInfo> (); foreach (var p in paths) { var vi = infoCache.GetStatus(p); if (vi != null) { result.Add(vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) { pathsToQuery.Add(p); } } else { // If there is no cached status, query it asynchronously vi = new VersionInfo(p, "", Directory.Exists(p), VersionStatus.Versioned, null, VersionStatus.Versioned, null); infoCache.SetStatus(vi, false); result.Add(vi); pathsToQuery.Add(p); } // Console.WriteLine ("GetVersionInfo " + string.Join (", ", paths.Select (p => p.FullPath))); } if (pathsToQuery.Count > 0) { AddQuery(new VersionInfoQuery() { Paths = pathsToQuery, QueryFlags = queryFlags }); } return(result); }
// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo (FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo (new FilePath[] { localPath }, queryFlags).ToArray (); if (infos.Length != 1) { LoggingService.LogError ("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError ("The infos were: {0}", string.Join (" ::: ", infos.Select (i => i.LocalPath))); } return infos.Single (); }
// Returns the versioning status of a file or directory public VersionInfo GetVersionInfo (FilePath localPath, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { VersionInfo[] infos = GetVersionInfo (new FilePath[] { localPath }, queryFlags).ToArray (); if (infos.Length != 1) { LoggingService.LogError ("VersionControl returned {0} items for {1}", infos.Length, localPath); LoggingService.LogError ("The infos were: {0}", string.Join (" ::: ", infos.Select (i => i.LocalPath))); } try { return infos.Single (); } catch (InvalidOperationException) { // Workaround for #17216. return infos [0]; } }