8000 Filelogging with nlog by pmiossec · Pull Request #999 · git-tfs/git-tfs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Filelogging with nlog #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GitTfs.Vs2010/TfsHelper.Vs2010.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Sep.Git.Tfs.Vs2010
{
public class TfsHelper : TfsHelperBase
{
public TfsHelper(TextWriter stdout, TfsApiBridge bridge, IContainer container) : base(stdout, bridge, container)
public TfsHelper(TfsApiBridge bridge, IContainer container) : base(bridge, container)
{
}

Expand Down
4 changes: 2 additions & 2 deletions GitTfs.Vs2012/TfsHelper.Vs2012.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TfsHelper : TfsHelperVs2012Base
{
protected override string TfsVersionString { get { return "11.0"; } }

public TfsHelper(TextWriter stdout, TfsApiBridge bridge, IContainer container)
: base(stdout, bridge, container) { }
public TfsHelper(TfsApiBridge bridge, IContainer container)
: base(bridge, container) { }
}
}
4 changes: 2 additions & 2 deletions GitTfs.Vs2013/TfsHelper.Vs2013.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TfsHelper : TfsHelperVs2012Base
{
protected override string TfsVersionString { get { return "12.0"; } }

public TfsHelper(TextWriter stdout, TfsApiBridge bridge, IContainer container)
: base(stdout, bridge, container) { }
public TfsHelper(TfsApiBridge bridge, IContainer container)
: base(bridge, container) { }
}
}
4 changes: 2 additions & 2 deletions GitTfs.Vs2015/TfsHelper.Vs2015.cs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class TfsHelper : TfsHelperVs2012Base
{
protected override string TfsVersionString { get { return "14.0"; } }

public TfsHelper(TextWriter stdout, TfsApiBridge bridge, IContainer container)
: base(stdout, bridge, container) { }
public TfsHelper(TfsApiBridge bridge, IContainer container)
: base(bridge, container) { }

protected override string GetDialogAssemblyPath()
{
Expand Down
54 changes: 27 additions & 27 deletions GitTfs.VsCommon/TfsHelper.Common.cs
6851
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ namespace Sep.Git.Tfs.VsCommon
{
public abstract class TfsHelperBase : ITfsHelper
{
protected readonly TextWriter _stdout;
protected readonly TfsApiBridge _bridge;
private readonly IContainer _container;
protected TfsTeamProjectCollection _server;
private static bool _resolverInstalled;

public TfsHelperBase(TextWriter stdout, TfsApiBridge bridge, IContainer container)
public TfsHelperBase(TfsApiBridge bridge, IContainer container)
{
_stdout = stdout;
_bridge = bridge;
_container = container;
if (!_resolverInstalled)
Expand Down Expand Up @@ -139,12 +137,12 @@ private void NonFatalError(object sender, ExceptionEventArgs e)
{
if (e.Failure != null)
{
_stdout.WriteLine(e.Failure.Message);
Trace.TraceInformation(e.Failure.Message);
Trace.WriteLine("Failure: " + e.Failure.Inspect(), "tfs non-fatal error");
}
if (e.Exception != null)
{
_stdout.WriteLine(e.Exception.Message);
Trace.TraceInformation(e.Exception.Message);
Trace.WriteLine("Exception: " + e.Exception.Inspect(), "tfs non-fatal error");
}
}
Expand Down Expand Up @@ -312,9 +310,11 @@ private void GetRootChangesetForBranch(IList<RootBranch> rootBranches, string tf
GetRelevantChangesetBasedOnChangeType(mergedItemsToFirstChangesetInBranchToCreate, tfsPathParentBranch, tfsPathBranchToCreate, out renameFromBranch);

AddNewRootBranch(rootBranches, new RootBranch(rootChangesetInParentBranch, tfsPathBranchToCreate));
Trace.WriteLineIf(renameFromBranch != null, "Found original branch '" + renameFromBranch + "' (renamed in branch '" + tfsPathBranchToCreate + "')");
if (renameFromBranch != null)
{
Trace.WriteLine("Found original branch '" + renameFromBranch + "' (renamed in branch '" + tfsPathBranchToCreate + "')");
GetRootChangesetForBranch(rootBranches, renameFromBranch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these two if statements be combined?

}
}
catch (VersionControlException)
{
Expand Down Expand Up @@ -428,7 +428,7 @@ private int GetRelevantChangesetBasedOnChangeType(IEnumerable<MergeInfo> merges,
}
if (merge == null)
{
_stdout.WriteLine("warning: git-tfs was unable to find the root changeset (ie the last common commit) between the branch '"
Trace.TraceWarning("warning: git-tfs was unable to find the root changeset (ie the last common commit) between the branch '"
+ tfsPathBranchToCreate + "' and its parent branch '" + tfsPathParentBranch + "'.\n"
+ "(Any help to add support of this special case is welcomed! Open an issue on https://github.com/git-tfs/git-tfs/issues )\n\n"
+ "To be able to continue to fetch the changesets from Tfs,\nplease enter the root changeset id between the branch '"
Expand Down Expand Up @@ -490,7 +490,7 @@ private int AskForRootChangesetId()
int changesetId;
while (true)
{
_stdout.Write("Please specify the root changeset id (or 'exit' to stop the process):");
Trace.TraceInformation("Please specify the root changeset id (or 'exit' to stop the process):");
var read = Console.ReadLine();
if (read == "exit")
throw new GitTfsException("Exiting...(fetching stopped by user!)");
Expand Down Expand Up @@ -548,7 +548,7 @@ private IEnumerable<MergeInfo> GetMergeInfo(string tfsPathBranchToCreate, string
TargetChangeType = extendedMerge.TargetItem != null ? extendedMerge.TargetItem.ChangeType : 0
};
mergedItemsToFirstChangesetInBranchToCreate.Add(lastMerge);
Trace.WriteLine(lastMerge, "Merge");
Trace.WriteLine("Merge: " + lastMerge);
}
return mergedItemsToFirstChangesetInBranchToCreate;
}
Expand Down Expand Up @@ -737,7 +737,7 @@ public void CleanupWorkspaces(string workingDirectory)
{
// Normally, the workspace will have one mapping, mapped to the git-tfs
// workspace folder. In that case, we just delete the workspace.
_stdout.WriteLine("Removing workspace \"" + workspace.DisplayName + "\".");
Trace.TraceInformation("Removing workspace \"" + workspace.DisplayName + "\".");
workspace.Delete();
}
else
Expand All @@ -749,7 +749,7 @@ public void CleanupWorkspaces(string workingDirectory)
var fullWorkingDirectoryPath = Path.GetFullPath(workingDirectory);
foreach (var mapping in workspace.Folders.Where(f => fullWorkingDirectoryPath.StartsWith(Path.GetFullPath(f.LocalItem), StringComparison.CurrentCultureIgnoreCase)))
{
_stdout.WriteLine("Removing @\"" + mapping.LocalItem + "\" from workspace \"" + workspace.DisplayName + "\".");
Trace.TraceInformation("Removing @\"" + mapping.LocalItem + "\" from workspace \"" + workspace.DisplayName + "\".");
workspace.DeleteMapping(mapping);
}
}
Expand All @@ -764,7 +764,7 @@ public void CleanupWorkspaces(string workingDirectory)
/// TFS randomly seems to report a workspace removed/deleted BUT subsequent calls by Git-TFS suggest that the delete hasn't actually been completed.
/// This suggest that deletes may be queued and take a lower priority than other actions, especially if the TFS server is under load.
/// </remarks>
private static void TryToDeleteWorkspace(Workspace workspace)
private void TryToDeleteWorkspace(Workspace workspace)
{
// Try and ensure the client and TFS Server are synchronized.
workspace.Refresh();
Expand Down Expand Up @@ -812,7 +812,7 @@ public ITfsChangeset GetShelvesetData(IGitTfsRemote remote, string shelvesetOwne
_bridge.Wrap<WrapperForVersionControlServer, VersionControlServer>(VersionControl);
// TODO - containerify this (no `new`)!
var fakeChangeset = new Unshelveable(shelveset, change, wrapperForVersionControlServer, _bridge);
var tfsChangeset = new TfsChangeset(remote.Tfs, fakeChangeset, _stdout, null) { Summary = new TfsChangesetInfo { Remote = remote } };
var tfsChangeset = new TfsChangeset(remote.Tfs, fakeChangeset, null) { Summary = new TfsChangesetInfo { Remote = remote } };
return tfsChangeset;
}

Expand All @@ -826,12 +826,12 @@ public int ListShelvesets(ShelveList shelveList, IGitTfsRemote remote)
}
catch (IdentityNotFoundException)
{
_stdout.WriteLine("User '{0}' not found", shelveList.Owner);
Trace.TraceInformation("User '{0}' not found", shelveList.Owner);
return GitTfsExitCodes.InvalidArguments;
}
if (shelvesets.Empty())
{
_stdout.WriteLine("No changesets found.");
Trace.TraceInformation("No changesets found.");
return GitTfsExitCodes.OK;
}

Expand All @@ -853,7 +853,7 @@ public int ListShelvesets(ShelveList shelveList, IGitTfsRemote remote)
shelvesets = shelvesets.OrderBy(s => s.Comment);
break;
default:
_stdout.WriteLine("ERROR: sorting criteria '{0}' is invalid. Possible values are: date, owner, name, comment", sortBy);
Trace.TraceInformation("ERROR: sorting criteria '{0}' is invalid. Possible values are: date, owner, name, comment", sortBy);
return GitTfsExitCodes.InvalidArguments;
}
}
Expand All @@ -871,19 +871,19 @@ private void WriteShelvesetsToStdout(IEnumerable<Shelveset> shelvesets)
{
foreach (var shelveset in shelvesets)
{
_stdout.WriteLine("{0,-22} {1,-20}", shelveset.OwnerName, shelveset.Name);
Trace.TraceInformation("{0,-22} {1,-20}", shelveset.OwnerName, shelveset.Name);
}
}

private void WriteShelvesetsToStdoutDetailed(IEnumerable<Shelveset> shelvesets)
{
foreach (var shelveset in shelvesets)
{
_stdout.WriteLine("Name : {0}", shelveset.Name);
_stdout.WriteLine("Owner : {0}", shelveset.OwnerName);
_stdout.WriteLine("Date : {0:g}", shelveset.CreationDate);
_stdout.WriteLine("Comment: {0}", shelveset.Comment);
_stdout.WriteLine();
Trace.TraceInformation("Name : {0}", shelveset.Name);
Trace.TraceInformation("Owner : {0}", shelveset.OwnerName);
Trace.TraceInformation("Date : {0:g}", shelveset.CreationDate);
Trace.TraceInformation("Comment: {0}", shelveset.Comment);
Trace.TraceInformation(string.Empty);
}
}

Expand Down Expand Up @@ -1364,22 +1364,22 @@ public int QueueGatedCheckinBuild(Uri buildDefinitionUri, string buildDefinition
buildRequest.Reason = BuildReason.CheckInShelveset;
buildRequest.GatedCheckInTicket = checkInTicket;

_stdout.WriteLine("Launching build '" + buildDefinitionName + "' to validate your shelveset...");
Trace.TraceInformation("Launching build '" + buildDefinitionName + "' to validate your shelveset...");
var queuedBuild = buildServer.QueueBuild(buildRequest);

_stdout.WriteLine("Waiting for gated check-in build result...");
Trace.TraceInformation("Waiting for gated check-in build result...");
do
{
_stdout.Write(".");
Console.Write(".");
System.Threading.Thread.Sleep(5000);
queuedBuild.Refresh(QueryOptions.Definitions);
} while (queuedBuild.Build == null || !queuedBuild.Build.BuildFinished);
_stdout.WriteLine(string.Empty);
Trace.TraceInformation(string.Empty);

var build = GetSpecificBuildFromQueuedBuild(queuedBuild, shelvesetName);
if (build.Status == BuildStatus.Succeeded)
{
_stdout.WriteLine("Build was successful! Your changes have been checked in.");
Trace.TraceInformation("Build was successful! Your changes have been checked in.");
return VersionControl.GetLatestChangesetId();
}
else
Expand Down
4 changes: 2 additions & 2 deletions GitTfs.VsCommon/TfsHelper.Vs2012Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Sep.Git.Tfs.VsCommon
public abstract class TfsHelperVs2012Base : TfsHelperBase
{
protected abstract string TfsVersionString { get; }
protected TfsHelperVs2012Base(TextWriter stdout, TfsApiBridge bridge, IContainer container)
: base(stdout, bridge, container) { }
protected TfsHelperVs2012Base(TfsApiBridge bridge, IContainer container)
: base(bridge, container) { }

protected override bool HasWorkItems(Changeset changeset)
{
Expand Down
4 changes: 1 addition & 3 deletions GitTfs.VsFake/TfsHelper.VsFake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ public class TfsHelper : ITfsHelper
#region misc/null

IContainer _container;
TextWriter _stdout;
Script _script;
FakeVersionControlServer _versionControlServer;

public TfsHelper(IContainer container, TextWriter stdout, Script script)
public TfsHelper(IContainer container, Script script)
{
_container = container;
_stdout = stdout;
_script = script;
_versionControlServer = new FakeVersionControlServer(_script);
}
Expand Down
9 changes: 4 additions & 5 deletions GitTfs/Commands/Bootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NDesk.Options;
using Sep.Git.Tfs.Core;
using StructureMap;
using System.Diagnostics;

namespace Sep.Git.Tfs.Commands
{
Expand All @@ -14,14 +15,12 @@ public class Bootstrap : GitTfsCommand
{
private readonly RemoteOptions _remoteOptions;
private readonly Globals _globals;
private readonly TextWriter _stdout;
private readonly Bootstrapper _bootstrapper;

public Bootstrap(RemoteOptions remoteOptions, Globals globals, TextWriter stdout, Bootstrapper bootstrapper)
public Bootstrap(RemoteOptions remoteOptions, Globals globals, Bootstrapper bootstrapper)
{
_remoteOptions = remoteOptions;
_globals = globals;
_stdout = stdout;
_bootstrapper = bootstrapper;
}

Expand All @@ -41,13 +40,13 @@ public int Run(string commitish)
foreach (var parent in tfsParents)
{
GitCommit commit = _globals.Repository.GetCommit(parent.GitCommit);
_stdout.WriteLine("commit {0}\nAuthor: {1} <{2}>\nDate: {3}\n\n {4}",
Trace.TraceInformation("commit {0}\nAuthor: {1} <{2}>\nDate: {3}\n\n {4}",
commit.Sha,
commit.AuthorAndEmail.Item1, commit.AuthorAndEmail.Item2,
commit.When.ToString("ddd MMM d HH:mm:ss zzz"),
commit.Message.Replace("\n","\n ").TrimEnd(' '));
_bootstrapper.CreateRemote(parent);
_stdout.WriteLine();
Trace.TraceInformation(string.Empty);
}
return GitTfsExitCodes.OK;
}
Expand Down
Loading
0