// Copyright Epic Games, Inc. All Rights Reserved. using EpicGames.Core; using EpicGames.Perforce; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; namespace P4VUtils.Commands { [Command("reconcilecode", CommandCategory.Toolbox, 2)] class FastReconcileCodeEditsCommand : Command { public override string Description => "Performs a fast reconcile of locally writeable code files into the default CL"; public override CustomToolInfo CustomTool => new CustomToolInfo("Fast Reconcile Writeable Code Files", "%D") { ShowConsole = true, RefreshUI = true }; public virtual string[] GetExtensions() { string[] Extensions = { ".c*", ".h*", ".up*", ".ini" }; return Extensions; } public override async Task Execute(string[] Args, IReadOnlyDictionary ConfigValues, ILogger Logger) { if (Args.Length < 2) { Logger.LogError("no folders selected"); return 1; } string[] Extensions = GetExtensions(); List ReconcilePaths = new List(); // %D is 'selected files or folders', ensure we only use folders for (int i=1;i Results = await Perforce.ReconcileAsync(-1, options, ReconcilePaths.ToArray(), CancellationToken.None); int Duration = Convert.ToInt32((DateTime.Now - Start).TotalSeconds); foreach (ReconcileRecord res in Results) { Logger.LogInformation("Marked for Edit {Res}", res); } Logger.LogInformation("Completed in {Duration}s", Duration); return 0; } } [Command("reconcileall", CommandCategory.Toolbox, 3)] class FastReconcileAllEditsCommand : FastReconcileCodeEditsCommand { public override string[] GetExtensions() { string[] Extensions = { ".*", }; return Extensions; } public override string Description => "Performs a fast reconcile of locally writeable files into the default CL"; public override CustomToolInfo CustomTool => new CustomToolInfo("Fast Reconcile Writeable Files", "%D") { ShowConsole = true, RefreshUI = true }; } }