From 88fcfcc2dbe89ebf42751d5ceeb7fd902ff3b817 Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Mon, 17 Aug 2009 18:28:34 -0400 Subject: [PATCH] Improved debug output. Added a todo. --- GitTfs/Commands/FcOptions.cs | 35 +++++++++++++++++++++++++++++------ GitTfs/Core/GitHelpers.cs | 10 +++++++++- GitTfs/Core/TfsHelper.cs | 2 ++ TODO | 5 ++++- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/GitTfs/Commands/FcOptions.cs b/GitTfs/Commands/FcOptions.cs index 90f4e1de..9cbe74a9 100644 --- a/GitTfs/Commands/FcOptions.cs +++ b/GitTfs/Commands/FcOptions.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Diagnostics; using CommandLine.OptParse; using Sep.Git.Tfs.Util; @@ -40,13 +41,35 @@ namespace Sep.Git.Tfs.Commands // I don't know what this is // public int LogWindowSize { get; set; } // public bool NoCheckout { get; set; } - - [OptDef(OptValType.IncrementalFlag)] - [ShortOptionName('q')] - [LongOptionName("quiet")] + + private int? _debugTraceListener; + + [OptDef(OptValType.Flag)] + [ShortOptionName('d')] + [LongOptionName("debug")] [UseNameAsLongOption(false)] - [Description("Reduce the amount of logged information.")] - public int OutputLevel { get; set; } + [Description("Show lots of output.")] + public bool DebugOutput + { + get { return _debugTraceListener.HasValue; } + set + { + if (value) + { + if (_debugTraceListener == null) + { + _debugTraceListener = Trace.Listeners.Add(new ConsoleTraceListener()); + } + } + else + { + if (_debugTraceListener != null) + { + Trace.Listeners.RemoveAt(_debugTraceListener.Value); + } + } + } + } // I think I'm going to make these the default. I may allow their disablement // later. diff --git a/GitTfs/Core/GitHelpers.cs b/GitTfs/Core/GitHelpers.cs index 47a4c41f..ea7b4827 100644 --- a/GitTfs/Core/GitHelpers.cs +++ b/GitTfs/Core/GitHelpers.cs @@ -116,11 +116,19 @@ namespace Sep.Git.Tfs.Core initialize(startInfo); Trace.WriteLine("Starting process: " + startInfo.FileName + " " + startInfo.Arguments, "git command"); var process = Process.Start(startInfo); - process.ErrorDataReceived += (sender, e) => Trace.WriteLine(e.Data, "git stderr"); + process.ErrorDataReceived += StdErrReceived; process.BeginErrorReadLine(); return process; } + private void StdErrReceived(object sender, DataReceivedEventArgs e) + { + if(e.Data != null && e.Data.Trim() != "") + { + Trace.WriteLine(e.Data.TrimEnd(), "git stderr"); + } + } + /// /// WrapGitCommandErrors the actions, and if there are any git exceptions, rethrow a new exception with the given message. /// diff --git a/GitTfs/Core/TfsHelper.cs b/GitTfs/Core/TfsHelper.cs index 6042c4f3..528e37ac 100644 --- a/GitTfs/Core/TfsHelper.cs +++ b/GitTfs/Core/TfsHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Net; using Microsoft.TeamFoundation.Client; @@ -78,6 +79,7 @@ namespace Sep.Git.Tfs.Core public IEnumerable GetChangesets(string path, long startVersion) { + Trace.WriteLine("Getting changesets from " + startVersion + " to current ...", "tfs"); var changesets = VersionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, new ChangesetVersionSpec((int) startVersion), VersionSpec.Latest, int.MaxValue, true, true, true); diff --git a/TODO b/TODO index 8b912780..22bd3dd3 100644 --- a/TODO +++ b/TODO @@ -34,4 +34,7 @@ The commands I plan to implement, in order of priority: migrate ? Known bugs: - None right now. + None right now. + +Potential enhancements: + Query history in chunks, either in a background thread or just with 100 changeset chunks, in order to speed up the initial output from a fetch. \ No newline at end of file