コード例 #1
0
        private static Command GetCommand2(QueryReflogParameters parameters)
        {
            var args = new List <ICommandArgument>();

            args.Add(LogCommand.WalkReflogs());
            if (parameters.MaxCount != 0)
            {
                args.Add(LogCommand.MaxCount(parameters.MaxCount));
            }
            args.Add(LogCommand.NullTerminate());
            args.Add(LogCommand.FormatRaw());
            if (parameters.Reference != null)
            {
                args.Add(new CommandParameter(parameters.Reference));
            }
            return(new LogCommand(args));
        }
コード例 #2
0
        public IList <ReflogRecordData> Invoke(QueryReflogParameters parameters)
        {
            Verify.Argument.IsNotNull(parameters, "parameters");

            var command = _commandFactory(parameters);
            var output  = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None);

            output.ThrowOnBadReturnCode();

            var cache = new Dictionary <Hash, RevisionData>(Hash.EqualityComparer);
            var list  = ParseResult1(output, cache);

            // get real commit parents
            command = GetCommand2(parameters);
            output  = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None);
            output.ThrowOnBadReturnCode();
            var parser = new GitParser(output.Output);

            parser.ParseCommitParentsFromRaw(list.Select(rrd => rrd.Revision), cache);

            return(list);
        }
コード例 #3
0
        public Task <IList <ReflogRecordData> > InvokeAsync(QueryReflogParameters parameters,
                                                            IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(parameters, "parameters");

            var command1 = _commandFactory(parameters);
            var command2 = GetCommand2(parameters);

            var tcs = new TaskCompletionSource <object>();

            if (cancellationToken.CanBeCanceled)
            {
                cancellationToken.Register(() => tcs.TrySetCanceled());
            }

            int completedTasks = 0;

            var task1 = _commandExecutor.ExecuteCommandAsync(command1, CommandExecutionFlags.None, cancellationToken);
            var task2 = _commandExecutor.ExecuteCommandAsync(command2, CommandExecutionFlags.None, cancellationToken);

            task1.ContinueWith(
                t => tcs.TrySetCanceled(),
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnCanceled,
                TaskScheduler.Default);
            task2.ContinueWith(
                t => tcs.TrySetCanceled(),
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnCanceled,
                TaskScheduler.Default);
            task1.ContinueWith(
                t => tcs.TrySetException(t.Exception),
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted,
                TaskScheduler.Default);
            task2.ContinueWith(
                t => tcs.TrySetException(t.Exception),
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted,
                TaskScheduler.Default);
            task1.ContinueWith(
                t =>
            {
                if (Interlocked.Increment(ref completedTasks) == 2)
                {
                    tcs.TrySetResult(null);
                }
            },
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion,
                TaskScheduler.Default);
            task2.ContinueWith(
                t =>
            {
                if (Interlocked.Increment(ref completedTasks) == 2)
                {
                    tcs.TrySetResult(null);
                }
            },
                cancellationToken,
                TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion,
                TaskScheduler.Default);

            return(tcs.Task.
                   ContinueWith(
                       t =>
            {
                TaskUtility.PropagateFaultedStates(t);

                var output1 = TaskUtility.UnwrapResult(task1);
                output1.ThrowOnBadReturnCode();
                var output2 = TaskUtility.UnwrapResult(task2);
                output2.ThrowOnBadReturnCode();

                var cache = new Dictionary <Hash, RevisionData>(Hash.EqualityComparer);
                var list = ParseResult1(output1, cache);
                var parser = new GitParser(output2.Output);
                parser.ParseCommitParentsFromRaw(list.Select(rrd => rrd.Revision), cache);
                return list;
            },
                       cancellationToken,
                       TaskContinuationOptions.ExecuteSynchronously,
                       TaskScheduler.Default));
        }
コード例 #4
0
ファイル: CommandBuilder.cs プロジェクト: Kuzq/gitter
        public Command GetQueryReflogCommand(QueryReflogParameters parameters)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>(5);
            args.Add(LogCommand.WalkReflogs());
            if(parameters.MaxCount != 0)
            {
                args.Add(LogCommand.MaxCount(parameters.MaxCount));
            }
            args.Add(LogCommand.NullTerminate());
            args.Add(GetReflogFormatArgument());
            if(parameters.Reference != null)
            {
                args.Add(new CommandParameter(parameters.Reference));
            }
            return new LogCommand(args);
        }