private void gatherArguments(IEnumerable <Discussion> discussions,
                                     out HashSet <GitDiffArguments> diffArgs, out HashSet <GitShowRevisionArguments> revisionArgs)
        {
            diffArgs     = new HashSet <GitDiffArguments>();
            revisionArgs = new HashSet <GitShowRevisionArguments>();

            foreach (Discussion discussion in discussions)
            {
                Debug.Assert(discussion.Notes != null &&
                             discussion.Notes.Any() &&
                             !discussion.Notes.First().System &&
                             discussion.Notes.First().Type == "DiffNote");

                Core.Matching.DiffPosition position =
                    PositionConverter.Convert(discussion.Notes.First().Position);
                if (!Core.Context.Helpers.IsValidPosition(position))
                {
                    continue;
                }

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(0)
                             ));

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(Constants.FullContextSize)
                             ));

                if (Core.Context.Helpers.IsRightSidePosition(position))
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.RightPath, position.Refs.RightSHA));
                }
                else
                {
                    Debug.Assert(Core.Context.Helpers.IsLeftSidePosition(position));
                    revisionArgs.Add(new GitShowRevisionArguments(position.LeftPath, position.Refs.LeftSHA));
                }
            }
        }
Example #2
0
        private void gatherArguments(IEnumerable <Discussion> discussions,
                                     out HashSet <GitDiffArguments> diffArgs, out HashSet <GitShowRevisionArguments> revisionArgs)
        {
            diffArgs     = new HashSet <GitDiffArguments>();
            revisionArgs = new HashSet <GitShowRevisionArguments>();

            foreach (Discussion discussion in discussions)
            {
                Debug.Assert(discussion.Notes != null &&
                             discussion.Notes.Any() &&
                             !discussion.Notes.First().System &&
                             discussion.Notes.First().Type == "DiffNote");

                Core.Matching.DiffPosition position =
                    PositionConverter.Convert(discussion.Notes.First().Position);

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(0)
                             ));

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(Constants.FullContextSize)
                             ));

                // the same condition as in EnhancedContextMaker and SimpleContextMaker,
                // which are consumers of the cache
                if (position.RightLine != null)
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.RightPath, position.Refs.RightSHA));
                }
                else
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.LeftPath, position.Refs.LeftSHA));
                }
            }
        }