Esempio n. 1
0
        void IResultWriter.WriteResults(CommandLineParameters commandLineParameters, List <SvnMergesEligibleEventArgs> missingRevisions)
        {
            WriteCommandLineParameters(commandLineParameters);

            foreach (var rev in missingRevisions)
            {
                WriteRevisionDetails(rev);
            }
        }
        static void Main(string[] args)
        {
            var exitCode = ExitCodes.Success;

            IInputOutputHelper io = new ConsoleHelper();
            ILog logger           = new Logger(io);

            var preambleHelper = new PreambleHelper(io);

            preambleHelper.Show();
            try
            {
                var commandLineParameters = new CommandLineParameters(io);

                var missingRevisions = SubversionHelper.GetMissingRevisions(io, commandLineParameters);
                if (missingRevisions == null || missingRevisions.Count == 0)
                {
                    io.WriteLine("YAY!!! Nothing amiss!!!");
                }
                else
                {
                    DumpResults(io, commandLineParameters, missingRevisions);
                }
            }
            catch (InvalidCommandLineParametersException ex)
            {
                exitCode = ex.ExitCode;
                if (exitCode != ExitCodes.ShowHelp)
                {
                    logger.Error(ex);
                }
            }
            catch (UriFormatException ex)
            {
                logger.Error(ex);
                exitCode = ExitCodes.InvalidUri;
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                exitCode = ExitCodes.GeneralFailure;
            }
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                io.Wait();
            }
#endif
            Exit(exitCode);
        }
Esempio n. 3
0
        private void WriteCommandLineParameters(CommandLineParameters commandLineParameters)
        {
            body.AddElement(ElementNames.CommandLineParameter)
            .AddAttribute(AttributeNames.Name, ElementNames.SourceRepository)
            .AddAttribute(AttributeNames.Value, commandLineParameters.SourceRepository);

            body.AddElement(ElementNames.CommandLineParameter)
            .AddAttribute(AttributeNames.Name, ElementNames.TargetRepository)
            .AddAttribute(AttributeNames.Value, commandLineParameters.TargetRepository);

            if (commandLineParameters.EndVersion.HasValue)
            {
                body.AddElement(ElementNames.CommandLineParameter)
                .AddAttribute(AttributeNames.Name, AttributeNames.EndRevision)
                .AddAttribute(AttributeNames.Value, commandLineParameters.EndVersion.Value);
            }
        }
Esempio n. 4
0
        void IResultWriter.WriteResults(CommandLineParameters commandLineParameters, List <SvnMergesEligibleEventArgs> missingRevisions)
        {
            sw.WriteLine("Source Repository: {0}", commandLineParameters.SourceRepository);
            sw.WriteLine("Target Repository: {0}", commandLineParameters.TargetRepository);
            sw.WriteLine();
            sw.WriteLine();

            var missingrevisionsNumbers = missingRevisions.Select(a => a.Revision).ToList();

            sw.WriteLine("Missing revisions:");
            sw.WriteLine(string.Join(", ", missingrevisionsNumbers));
            sw.WriteLine();
            sw.WriteLine("Missing revisions (summarised):");
            sw.WriteLine(string.Join(", ", Utility.GetIntListAsRanges(missingrevisionsNumbers)));
            sw.WriteLine();

            foreach (var rev in missingRevisions)
            {
                WriteRevisionDetails(rev);
            }
        }
        private static void DumpResults(IInputOutputHelper io, CommandLineParameters commandLineParameters, List <SvnMergesEligibleEventArgs> missingRevisions)
        {
            IResultWriter resultWriter = new ResultWriterConsole(io);

            switch (commandLineParameters.LogType)
            {
            case LogTypes.Text:
            {
                resultWriter = new ResultWriterText(io);
                break;
            }

            case LogTypes.Xml:
            {
                resultWriter = new ResultWriterXml(io);
                break;
            }
            }

            resultWriter.WriteResults(commandLineParameters, missingRevisions);

            resultWriter.End();
        }
        public static List <SvnMergesEligibleEventArgs> GetMissingRevisions(IInputOutputHelper io, CommandLineParameters commandLineParameters)
        {
            var res = new List <SvnMergesEligibleEventArgs>();

            var branchFirstRevision = SubversionHelper.GetFirstRevision(io, commandLineParameters.SourceRepository);

            if (!branchFirstRevision.HasValue)
            {
                io.WriteLine("No branch revisions found.");
            }
            else
            {
                io.WriteLine("Source branch was created in rev: " + branchFirstRevision.Value);

                var tasks = new List <Task>();

                io.WriteLine("Getting revision information from source branch...");
                var mergesEligible = new List <SvnMergesEligibleEventArgs>();
                tasks.Add(Task.Factory.StartNew(delegate
                {
                    var client = GetSvnClient();
                    var args   = new SvnMergesEligibleArgs
                    {
                        Range = new SvnRevisionRange(new SvnRevision(branchFirstRevision.Value), new SvnRevision(SvnRevisionType.Head)),
                        RetrieveChangedPaths = true,
                    };
                    var list = client.ListMergesEligible(new Uri(commandLineParameters.TargetRepository),
                                                         new Uri(commandLineParameters.SourceRepository), args, delegate(object sender, SvnMergesEligibleEventArgs e)
                    {
                        e.Detach();
                        mergesEligible.Add(e);
                    });
                }));


                io.WriteLine("Getting merged ranges in the target branch...");
                var mergesMerged = new List <SvnMergesMergedEventArgs>();
                tasks.Add(Task.Factory.StartNew(delegate
                {
                    var client = GetSvnClient();
                    var args   = new SvnMergesMergedArgs
                    {
                        Range = new SvnRevisionRange(new SvnRevision(branchFirstRevision.Value), new SvnRevision(SvnRevisionType.Head)),
                        RetrieveChangedPaths = false,
                    };
                    var list = client.ListMergesMerged(new Uri(commandLineParameters.TargetRepository),
                                                       new Uri(commandLineParameters.SourceRepository), args, delegate(object sender, SvnMergesMergedEventArgs e)
                    {
                        e.Detach();
                        mergesMerged.Add(e);
                    });
                }));

                io.WriteLine("Please wait...");

                Task.WaitAll(tasks.ToArray());

                var missingRevisions = mergesEligible.Where(a => !mergesMerged.Any(b => b.Revision == a.Revision)).ToList();

                res.AddRange(missingRevisions);
            }
            return(res);
        }