/// <summary> /// Compares changesets /// </summary> /// <param name="localPath"></param> /// <param name="sourceChangesetId">Source changeset Id</param> /// <param name="serverUrl">Server Uri</param> /// <param name="srcPath">Source item path</param> public static void CompareLocal(string localPath, string sourceChangesetId, string serverUri, string srcPath) { if (String.IsNullOrWhiteSpace(sourceChangesetId)) { throw new ArgumentException("'sourceChangesetId' is null or empty."); } if (String.IsNullOrWhiteSpace(serverUri)) { throw new TfsHistorySearchException("'serverUri' is null or empty."); } if (String.IsNullOrWhiteSpace(srcPath)) { throw new TfsHistorySearchException("'srcPath' is null or empty."); } if (String.IsNullOrWhiteSpace(localPath)) { throw new TfsHistorySearchException("'localPath' is null or empty."); } TfsTeamProjectCollection tc = new TfsTeamProjectCollection(new Uri(serverUri)); VersionControlServer vcs = tc.GetService(typeof(VersionControlServer)) as VersionControlServer; //VersionSpec sourceVersion = VersionSpec.ParseSingleSpec(sourceChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName); VersionSpec sourceVersion = VersionSpec.ParseSingleSpec(sourceChangesetId, vcs.AuthorizedUser); //VersionSpec targetVersion = VersionSpec.ParseSingleSpec(targetChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName); //Difference.DiffFiles( Difference.VisualDiffItems(vcs, Difference.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), Difference.CreateTargetDiffItem(vcs, localPath, null, 0, null)); //Difference.VisualDiffFiles(); //Difference.VisualDiffItems(vcs, // Difference.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), // Difference.CreateTargetDiffItem(vcs, targetPath, targetVersion, 0, targetVersion)); }
/// <summary> /// Compares changesets /// </summary> /// <param name="sourceChangesetId">Source changeset Id</param> /// <param name="targetChangesetId">Target changeset Id</param> /// <param name="serverUrl">Server Uri</param> /// <param name="srcPath">Source item path</param> /// <param name="targetPath">Target item path</param> public static void Compare(string sourceChangesetId, string targetChangesetId, string serverUri, string srcPath, string targetPath) { if (String.IsNullOrWhiteSpace(sourceChangesetId)) { throw new ArgumentException("'sourceChangesetId' is null or empty."); } if (String.IsNullOrWhiteSpace(targetChangesetId)) { throw new ArgumentException("'targetChangesetId' is null or empty."); } if (String.IsNullOrWhiteSpace(serverUri)) { throw new ArgumentException("'serverUri' is null or empty."); } if (String.IsNullOrWhiteSpace(srcPath)) { throw new ArgumentException("'srcPath' is null or empty."); } if (String.IsNullOrWhiteSpace(targetPath)) { throw new ArgumentException("'targetPath' is null or empty."); } TfsTeamProjectCollection tc = new TfsTeamProjectCollection(new Uri(serverUri)); VersionControlServer vcs = tc.GetService(typeof(VersionControlServer)) as VersionControlServer; VersionSpec sourceVersion = VersionSpec.ParseSingleSpec(sourceChangesetId, vcs.AuthorizedUser); VersionSpec targetVersion = VersionSpec.ParseSingleSpec(targetChangesetId, vcs.AuthorizedUser); Difference.VisualDiffItems(vcs, Difference.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), Difference.CreateTargetDiffItem(vcs, targetPath, targetVersion, 0, targetVersion)); }
public void CompareFiles(string sourceFile, string targetFile) { Difference.VisualDiffItems(versionControlServer, Difference.CreateTargetDiffItem(versionControlServer, sourceFile, VersionSpec.Latest, 0, VersionSpec.Latest), Difference.CreateTargetDiffItem(versionControlServer, targetFile, VersionSpec.Latest, 0, VersionSpec.Latest), false); }
/// <summary> /// Visual compare current text document with the latest version in Version Control. /// </summary> private void CompareDocumentWithLatestVersion() { Item item = _marginCore.VersionControlItem; VersionControlServer vcs = item.VersionControlServer; ITextDocument textDoc = _marginCore.TextDocument; IDiffItem source = Difference.CreateTargetDiffItem(vcs, item.ServerItem, VersionSpec.Latest, 0, VersionSpec.Latest); var target = new DiffItemLocalFile(textDoc.FilePath, textDoc.Encoding.CodePage, textDoc.LastContentModifiedTime, false); Difference.VisualDiffItems(vcs, source, target); }
/// <summary> /// difference a specific set o' stuffs /// </summary> /// <param name="item1"></param> /// <param name="csID1"></param> /// <param name="item2"></param> /// <param name="csID2"></param> public static void VisualDiff(Item item1, int csID1, Item item2, int csID2) { VersionControlServer vcs = item1.VersionControlServer; IDiffItem left; IDiffItem right; left = new DiffItemVersionedFile(item1, new ChangesetVersionSpec(csID1)); right = new DiffItemVersionedFile(item2, new ChangesetVersionSpec(csID2)); Difference.VisualDiffItems(vcs, left, right); }
private bool DiffFiles(Item item1, Item item2) { if (item1 == null || item2 == null || item1.ItemType != ItemType.File) { return(false); } lock (_lock) { Difference.VisualDiffItems(_versionControlServer, Difference.CreateTargetDiffItem(_versionControlServer, item2.ServerItem, new ChangesetVersionSpec(item2.ChangesetId), 0, new ChangesetVersionSpec(item2.ChangesetId)), Difference.CreateTargetDiffItem(_versionControlServer, item1.ServerItem, new ChangesetVersionSpec(item1.ChangesetId), 0, new ChangesetVersionSpec(item1.ChangesetId))); } return(true); }
private void Compare(string serverItem, int fromChangesetId, int toChangesetId) { try { var itemFrom = new DiffItemVersionedFile(versionControlServer, serverItem, new ChangesetVersionSpec(fromChangesetId)); var itemTo = new DiffItemVersionedFile(versionControlServer, serverItem, new ChangesetVersionSpec(toChangesetId)); Difference.VisualDiffItems(versionControlServer, itemFrom, itemTo); } catch (Exception ex) { //HACK } }