void ApplyStatusFromExtendedItem(VersionedAsset asset, ExtendedItem eachItem) { if (asset == null) { return; } var isLocal = true; if (eachItem.ChangeType.HasFlag(ChangeType.Lock)) { asset.AddState(isLocal ? State.kLockedLocal : State.kLockedRemote); } if (eachItem.ChangeType.HasFlag(ChangeType.Add)) { asset.AddState(isLocal ? State.kAddedLocal : State.kAddedRemote); } else if (eachItem.ChangeType.HasFlag(ChangeType.Delete)) { asset.AddState(isLocal ? State.kDeletedLocal : State.kDeletedRemote); if (isLocal) { asset.RemoveState(State.kMissing); asset.AddState(State.kSynced); } } else if (eachItem.ChangeType.HasFlag(ChangeType.Edit) || eachItem.ChangeType.HasFlag(ChangeType.Rename) || eachItem.ChangeType.HasFlag(ChangeType.Branch) || eachItem.ChangeType.HasFlag(ChangeType.Merge) || eachItem.ChangeType.HasFlag(ChangeType.Rollback) || eachItem.ChangeType.HasFlag(ChangeType.Undelete) || eachItem.ChangeType.HasFlag(ChangeType.Encoding)) { asset.AddState(isLocal ? State.kCheckedOutLocal : State.kCheckedOutRemote); } }
public VersionedAsset ToVersionedAsset(ExtendedItem eachItem) { VersionedAsset asset = new VersionedAsset(GetAssetPath(eachItem, Workspace)); asset.SetChangeListID(eachItem.VersionLocal.ToString()); asset.SetRevision(eachItem.VersionLocal.ToString()); if (asset.ExistsOnDisk) { asset.AddState(State.kLocal); } else { asset.AddState(State.kMissing); } if (eachItem.IsInWorkspace) { if (eachItem.IsLatest) { asset.AddState(State.kSynced); } else { asset.AddState(State.kOutOfSync); } } if (Workspace.Location == Microsoft.TeamFoundation.VersionControl.Common.WorkspaceLocation.Local) { ApplyStatusFromExtendedItem(asset, eachItem); } return(asset); }
private bool IsNoLocked(VersionedAsset asset) { foreach (var item in nolockRegexCache.Value) { if (item.IsMatch(asset.GetPath())) { return(true); } } return(false); }
public bool IsIgnored(VersionedAsset asset) { foreach (var item in ignoreRegexCache.Value) { if (item.IsMatch(asset.GetPath())) { return(true); } } return(false); }
void ToVersionedAssetList(ExtendedItem[][] items, VersionedAssetList result) { foreach (var item in items) { foreach (var eachItem in item) { VersionedAsset asset = ToVersionedAsset(eachItem); result.Add(asset); } } }
public VersionedAssetList GetStatus() { VersionedAssetList result = new VersionedAssetList(); var projectFolder = new VersionedAsset(GetAssetPath(projectPath, Workspace.GetServerItemForLocalItem(projectPath), ItemType.Folder, Workspace)); GetStatus(new VersionedAssetList { projectFolder }, result, true, true); return(result); }
private static void ExpandFoldersIntoFiles(TfsTask task, Connection connection, VersionedAssetList versionedAssets) { List <string> enumeratedFiles = new List <string>(); //Check each asset to see if it is a folder for (int i = versionedAssets.Count - 1; i >= 0; i--) { VersionedAsset asset = versionedAssets[i]; if (!asset.IsFolder()) { continue; } try { //Get all files in the folder enumeratedFiles.AddRange(Directory.GetFiles(asset.Path, "*.*", SearchOption.AllDirectories)); connection.LogInfo("Expanding Folder: " + asset.Path); } catch (Exception e) { connection.WarnLine(e.Message); } //Remove the folder from the checkout versionedAssets.RemoveAt(i); } //Get the status of the enumerated files VersionedAssetList newVersionedAssets = new VersionedAssetList(); task.GetStatus(enumeratedFiles.ToArray(), newVersionedAssets, false, true); //Remove any local-only files for (int i = newVersionedAssets.Count - 1; i >= 0; i--) { VersionedAsset asset = newVersionedAssets[i]; if (!asset.IsKnownByVersionControl || asset.HasPendingLocalChange) { newVersionedAssets.RemoveAt(i); } } //Add the new assets to the asset list versionedAssets.AddRange(newVersionedAssets); }
private void GetConflictInfo(TfsTask task, string assetPath, string tmpFile, out VersionedAsset mine, out VersionedAsset theirs, out VersionedAsset baseAsset) { mine = null; theirs = null; baseAsset = null; var conflicts = task.Workspace.QueryConflicts(new[] { assetPath }, false); if (conflicts.Length > 0) { var conflict = conflicts[0]; mine = new VersionedAsset(assetPath); theirs = new VersionedAsset(tmpFile + "_" + conflict.TheirVersion.ToString()); theirs.SetRevision(conflict.TheirVersion.ToString()); conflict.DownloadTheirFile(theirs.GetPath()); baseAsset = new VersionedAsset(tmpFile + "_" + conflict.BaseVersion.ToString()); baseAsset.SetRevision(conflict.BaseVersion.ToString()); conflict.DownloadBaseFile(baseAsset.GetPath()); } }
public bool ShouldLock(VersionedAsset asset) { return(asset.IsOfType(exclusiveCheckoutTypes) && !IsNoLocked(asset)); }
public static bool IsDescendant(VersionedAsset parent, VersionedAsset desc) { return(desc.Path.StartsWith(parent.Path, StringComparison.CurrentCultureIgnoreCase)); }
public static bool IsMeta(VersionedAsset asset) { return(asset.Path.EndsWith(".meta", StringComparison.CurrentCultureIgnoreCase)); }
public static bool IsFolder(VersionedAsset asset) { return(IsFolder(asset.Path)); }
public bool Run(TfsTask task, DownloadRequest req, DownloadResponse resp) { int idx = 0; foreach (var i in req.Assets) { string assetPath = i.GetPath(); string tmpFile = req.TargetDir + "/" + idx.ToString() + "_"; foreach (var j in req.Revisions) { string revision = j; try { if (revision == ChangelistRevision.kDefaultListRevision || revision == "head") { if (!EnsureDirectory(req.TargetDir)) { string msg = "Could not create temp dir: " + req.TargetDir; req.Conn.ErrorLine(msg); resp.Assets.Clear(); resp.Write(); return(true); } string f = tmpFile + "_" + revision; Download(task, assetPath, f, VersionSpec.Latest); VersionedAsset asset = new VersionedAsset(); asset.SetPath(f); resp.Assets.Add(asset); } else if (revision == "mineAndConflictingAndBase") { if (!EnsureDirectory(req.TargetDir)) { string msg = "Could not create temp dir: " + req.TargetDir; req.Conn.ErrorLine(msg); resp.Assets.Clear(); resp.Write(); return(true); } VersionedAsset mine, conflict, baseAsset; GetConflictInfo(task, assetPath, tmpFile, out mine, out conflict, out baseAsset); // If we cannot locate the working file we do not // include this asset in the response. if (mine == null) { req.Conn.ErrorLine("No 'mine' file for " + assetPath); continue; } if (conflict == null) { req.Conn.ErrorLine("No 'conflict' file for " + assetPath); continue; } if (baseAsset == null) { req.Conn.ErrorLine("No 'base' file for " + assetPath); continue; } resp.Assets.Add(mine); resp.Assets.Add(conflict); resp.Assets.Add(baseAsset); } idx += 1; } catch (Exception e) { req.Conn.LogNotice(e.Message); req.Conn.ErrorLine("Error downloading file through svn"); resp.Assets.Clear(); resp.Write(); return(true); } } } resp.Write(); return(true); }