public Unshelveable(Shelveset shelveset, PendingSet pendingSet, IVersionControlServer versionControlServer, TfsApiBridge bridge) { _shelveset = shelveset; _versionControlServer = versionControlServer; _bridge = bridge; _pendingSet = pendingSet; _changes = _pendingSet.PendingChanges.Select(x => new UnshelveChange(x, _bridge, versionControlServer)).Cast <IChange>().ToArray(); }
private static IEnumerable <Tuple <int, int> > AsEnumerable(PendingSet[] pendingSets) { for (var i = 0; i < pendingSets.Length; i++) { PendingSet pendingSet = pendingSets[i]; PendingChange[] pendingChanges = pendingSet.PendingChanges; for (var j = 0; j < pendingChanges.Length; j++) { var pair = Tuple.Create(i, j); yield return(pair); } } }
public IEnumerable <IShelveset> GetShelvesetByOwner(string serverUrl, string actingUserName, string ownerName) { TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serverUrl)); teamProjectCollection.EnsureAuthenticated(); VersionControlServer vcServer = teamProjectCollection.GetService <VersionControlServer>(); HashSet <string> workspaceBranchNames = new HashSet <string>(); foreach (Workspace workspace in vcServer.QueryWorkspaces(null, actingUserName, null)) { workspace.Folders.ToList().ForEach(f => workspaceBranchNames.Add(f.ServerItem)); } foreach (Shelveset shelveset in vcServer.QueryShelvesets(null, ownerName)) { PendingSet changeSet = vcServer.QueryShelvedChanges(shelveset).FirstOrDefault(); if (changeSet != null) { yield return(new AdapterShelveset(shelveset, changeSet.PendingChanges, workspaceBranchNames.ToArray())); } } }
private void ApplyStatusFromPendingSet(VersionedAssetList result, PendingSet item, bool isLocal) { // each local pending change foreach (var eachPendingChange in item.PendingChanges) { var asset = FindVersionedAsset(eachPendingChange, result); if (asset == null) { continue; } if (eachPendingChange.IsLock) { asset.AddState(isLocal ? State.kLockedLocal : State.kLockedRemote); } if (eachPendingChange.IsAdd) { asset.AddState(isLocal ? State.kAddedLocal : State.kAddedRemote); } else if (eachPendingChange.IsDelete) { asset.AddState(isLocal ? State.kDeletedLocal : State.kDeletedRemote); if (isLocal) { asset.RemoveState(State.kMissing); asset.AddState(State.kSynced); } } else if (eachPendingChange.IsEdit || eachPendingChange.IsRename || eachPendingChange.IsBranch || eachPendingChange.IsMerge || eachPendingChange.IsRollback || eachPendingChange.IsUndelete || eachPendingChange.IsEncoding) { asset.AddState(isLocal ? State.kCheckedOutLocal : State.kCheckedOutRemote); } } }
/// <summary> /// Create a difference string from a shelveset /// Also sets the URl to the file on the TFS Server /// </summary> /// <param name="set">The selected PendingSet</param> /// <returns>the diff String which is sent to Codestriker</returns> public string ReviewShelveset( PendingSet set) { if (set == null) { throw new ArgumentNullException(nameof(set)); } MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); { DiffOptions options = new DiffOptions { Flags = DiffOptionFlags.EnablePreambleHandling, OutputType = DiffOutputType.Unified, TargetEncoding = Encoding.UTF8, SourceEncoding = Encoding.UTF8, Recursive = true, StreamWriter = writer }; StringBuilder sb = new StringBuilder(); int streampos = 0; foreach (var pendingchange in set.PendingChanges) { if (pendingchange.ItemType != ItemType.Folder) { string fileUrl = string.Format(pendingchange.VersionControlServer.TeamProjectCollection.Uri.AbsoluteUri); fileUrl += s_LinkCompletionVersioncontrol; fileUrl += $"{HttpUtility.UrlEncode(pendingchange.PendingSetName + ";" + pendingchange.PendingSetOwner)}{s_PathParameter}"; fileUrl += HttpUtility.UrlEncode(pendingchange.LocalOrServerItem); //the semicolons after s_ActionParameter and pendingchange.FileName are important for the right parsing on codestriker fileUrl += $"{s_ActionParameter}&#path={HttpUtility.UrlEncode(pendingchange.LocalOrServerItem)}{s_ActionParameter};{pendingchange.LocalOrServerItem};"; var diffChange = new DiffItemShelvedChange(set.Name, pendingchange); var diffVersion = Difference.CreateTargetDiffItem(m_VersionControl, pendingchange, null); Difference.DiffFiles( m_VersionControl, diffVersion, diffChange, options, string.Empty, true); writer.Flush(); sb.Append(writer.GetHashCode()).Append(Environment.NewLine); string pendingChangeString = Encoding.UTF8.GetString(stream.ToArray().Skip(streampos).ToArray()); Regex rgx = new Regex(s_RegexPattern); //replace the filename with the tfs url path of the file //necessary for the link between codestriker and TFS pendingChangeString = rgx.Replace( pendingChangeString, m => m.Groups["prefix"].Value + ": " + fileUrl, 1); sb.Append(pendingChangeString); streampos = stream.ToArray().Length; } } return(sb.ToString()); } #endregion }
public bool TryWorkspaceQueryShelvedChanges(Workspace workspace, out PendingSet[] pendingSets, string shelvesetName, string shelvesetOwner, ItemSpec[] itemSpecs) { try { pendingSets = _teamPilgrimTfsService.WorkspaceQueryShelvedChanges(workspace, shelvesetName, shelvesetOwner, itemSpecs); return true; } catch (ShelvesetNotFoundException) { pendingSets = null; return true; } catch (Exception ex) { this.Logger().DebugException(ex); LastException = ex; } pendingSets = null; return false; }
public override bool Read() { bool read; if (this.command.Cancelled) { read = false; } else { if (this.first) { this.first = false; var parameters = this.command.Parameters; string path = Database.GetValueOrDefault <string>(parameters["path"].Value); string recursionString = Database.GetValueOrDefault <string>(parameters["recursion"].Value); RecursionType recursion; if (recursionString != null) { recursion = Enum <RecursionType> .Parse(recursionString); } else { recursion = RecursionType.Full; } string workspace = Database.GetValueOrDefault <string>(parameters["workspace"].Value); string user = Database.GetValueOrDefault <string>(parameters["user"].Value); this.pendingSets = this.command.Connection.VersionControlServer.QueryPendingSets(new string[] { path }, recursion, workspace, user); this.enumerator = AsEnumerable(this.pendingSets).GetEnumerator(); } var moveNext = this.enumerator.MoveNext(); if (moveNext) { var pair = this.enumerator.Current; PendingSet pendingSet = this.pendingSets[pair.Item1]; PendingChange pendingChange = pendingSet.PendingChanges[pair.Item2]; var values = new object[] { pendingSet.Computer, pendingSet.Name, pendingSet.OwnerName, pendingSet.Type.ToString(), pendingChange.ChangeType.ToString(), pendingChange.CreationDate, pendingChange.FileName, pendingChange.ItemType.ToString(), pendingChange.LockLevelName, pendingChange.ServerItem, pendingChange.LocalItem }; this.Values = values; read = true; } else { read = false; } } return(read); }
public PendingSetWrapper(PendingSet set, DateTime creationDate) { Set = set; CreationDate = creationDate; }