From 721b4f14c48c65bc40f44eb87b85658908b49f68 Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Wed, 5 Dec 2007 22:33:32 -0500 Subject: [PATCH] tf merges --- ChangeLog | 1 + class/OpenTF.Common/Settings.cs | 1 + docs/tf.txt | 8 ++++++++ tools/opentf/MergesCommand.cs | 45 +++++++++++++++++++++++++++++++++++------ 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f072c33..4799fd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ # NEW: add alpha-quality MonoDevelop addin # NEW: implement "tf shelve " to create new shelvesets # NEW: implement "tf shelve /delete " for deleting shelvesets + # NEW: implement "tf merges " for listing merge points # NEW: implement "tf diff /ignorespace" option # NEW: add Get.DefaultToCwd setting: By enabling this option, the TF client will look for updates starting with the current working folder diff --git a/class/OpenTF.Common/Settings.cs b/class/OpenTF.Common/Settings.cs index 33451a6..063b07a 100644 --- a/class/OpenTF.Common/Settings.cs +++ b/class/OpenTF.Common/Settings.cs @@ -67,6 +67,7 @@ namespace OpenTF.Common Add("History.Detailed", "false"); Add("History.Recursive", "false"); Add("History.StopAfter", "256"); + Add("Merges.Recursive", "false"); Add("Online.Recursive", "false"); Add("Server.Default", ""); Add("Workspace.Default", ""); diff --git a/docs/tf.txt b/docs/tf.txt index 7723f50..173dbf0 100644 --- a/docs/tf.txt +++ b/docs/tf.txt @@ -112,6 +112,10 @@ COMMANDS server you've not yet fetched. To show those files as well, use "/old /all". This behavior may change in future releases, based on user feedback. +*merges [] *:: + Lists merge points in the history of the destination item. The destination + item can either be expressed as a server item or a local item. + *online [ /added | /modified | /deleted | /preview ]*:: Finds all writable files and marks them as pending changes on the server. It also finds all unknown files and marks them as pending adds, missing @@ -271,6 +275,10 @@ The TF client stores configuration settings in ~/.tf/TfClient.config. The TF client defaults to showing the last 255 checkins in history output. Set this option to an integer to change the default. +*Merges.Recursive*:: + The TF client will automatically do recursive merge queries when set + to "true". IMHO, this is far more useful than the default behavior. + *Online.Recursive*:: The TF client will automatically do a recursive online command when set to "true". IMHO, this is far more useful than the default behavior for diff --git a/tools/opentf/MergesCommand.cs b/tools/opentf/MergesCommand.cs index 6e6bbf4..51734fd 100644 --- a/tools/opentf/MergesCommand.cs +++ b/tools/opentf/MergesCommand.cs @@ -33,10 +33,16 @@ using System.Text; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; using Mono.GetOptions; +using OpenTF.Common; [Command("merges", "List merges for a path.", "[] ")] class MergesCommand : Command { + private readonly static string SourceHdr = "Changeset"; + private readonly static string TargetHdr = "Merged in Changeset"; + private readonly static string AuthorHdr = "Author"; + private readonly static string DateHdr = "Date"; + [Option("Recursive", "R", "recursive")] public bool OptionRecursive = false; @@ -44,6 +50,35 @@ class MergesCommand : Command { } + public void BriefOutput(ChangesetMerge[] merges) + { + if (merges.Length == 0) return; + int maxAuthor = 29; + + string line = String.Format("{0} {1} {2} {3}", SourceHdr, TargetHdr, + AuthorHdr.PadRight(maxAuthor), DateHdr); + Console.WriteLine(line); + + line = String.Format("{0} {1} {2} {3}", "-".PadRight(SourceHdr.Length, '-'), + "-".PadRight(TargetHdr.Length, '-'), + "-".PadRight(maxAuthor, '-'), + "-".PadRight(10, '-')); + Console.WriteLine(line); + + foreach (ChangesetMerge merge in merges) + { + string srcver = merge.SourceVersion.ToString(); + string trgver = merge.TargetVersion.ToString(); + + line = String.Format("{0} {1} {2} {3}", + srcver.PadLeft(SourceHdr.Length), + trgver.PadLeft(TargetHdr.Length), + merge.TargetChangeset.Owner.PadRight(maxAuthor), + merge.TargetChangeset.CreationDate.ToString("d")); + Console.WriteLine(line); + } + } + public override void Run() { string sourcePath = String.Empty; @@ -65,15 +100,13 @@ class MergesCommand : Command } RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; + bool setting = Settings.Current.GetAsBool("Merges.Recursive"); + if (setting) rtype = RecursionType.Full; + ChangesetMerge[] merges = VersionControlServer.QueryMerges(sourcePath, null, targetPath, VersionSpec.Latest, null, null, rtype); - foreach (ChangesetMerge merge in merges) - { - Console.WriteLine("SourceVersion: " + merge.SourceVersion); - Console.WriteLine("TargetVersion: " + merge.TargetVersion); - Console.WriteLine("Partial: " + merge.Partial); - } + BriefOutput(merges); } } -- 2.11.4.GIT