/// <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))); } // 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 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]; } }