public void SplitByLockPolicy(IEnumerable <VersionedAsset> assets, out string[] needLocks, out string[] noLocks) { List <string> toLock = new List <string>(); List <string> notToLock = new List <string>(); foreach (var item in assets) { if (ShouldLock(item)) { toLock.Add(Path.GetFullPath(item.GetPath())); } else { notToLock.Add(Path.GetFullPath(item.GetPath())); } } // check the currently lock status of binary files, if they are checked out, or have a checkin lock, dont lock them if (toLock.Count != 0 && shareBinaryFileCheckout.Value) { var lockLevel = GetLockLevel(); List <TfsFileStatus> status = new List <TfsFileStatus>(); TfsFileStatusCache.RefreshExtendedStatus(Workspace, toLock, status); foreach (var item in status) { if (!item.ExtendedItem.HasOtherPendingChange) { continue; } if (lockLevel == LockLevel.Checkin && item.ExtendedItem.LockStatus == LockLevel.None) { continue; } var fullpath = item.LocalFullPath; toLock.RemoveAll(each => each.Equals(fullpath, StringComparison.CurrentCultureIgnoreCase)); notToLock.Add(fullpath); } } needLocks = toLock.ToArray(); noLocks = notToLock.ToArray(); }
internal void GetStatus(string[] assets, VersionedAssetList result, bool recursive, bool queryRemote) { var timer = new Stopwatch(); timer.Start(); var time = DateTime.Now; // if we are not connected to tfs if (this.Workspace == null) { return; } if (recursive) { if (assets.Length == 0) { // Empty means all in recursive mode var status = GetProjectExtendedStatus(); tfsFileStatusCache.RefreshExtendedStatus(status, Workspace, time); ToVersionedAssetList(status, result); } else { var status = GetProjectExtendedStatus(assets, true); tfsFileStatusCache.RefreshExtendedStatus(status, Workspace, time); ToVersionedAssetList(status, result); } } else { if (assets.Length != 0) { var status = GetProjectExtendedStatus(assets, false); tfsFileStatusCache.RefreshExtendedStatus(status, Workspace, time); ToVersionedAssetList(status, result); } } // Make sure that we have status for local only assets as well foreach (var i in assets) { if (i.Contains("*")) { continue; } if (!result.Any(each => each.GetPath().Equals(i, StringComparison.CurrentCultureIgnoreCase))) { result.Add(new VersionedAsset(i, State.kLocal, "0")); } } timer.Restart(); MergeInMoreDetailedPendingChanges(result, recursive); if (IsPartiallyOffline) { MergeInWorkLocalStatus(result); } }