Пример #1
0
        private void ProcessBlame(string filename, GitRevision revision, IReadOnlyList <ObjectId> children, Control controlToMask, int lineNumber, int scrollpos)
        {
            var avatarSize = BlameAuthor.Font.Height + 1;

            var(gutter, body, avatars) = BuildBlameContents(filename, avatarSize);

            BlameAuthor.SetGitBlameGutter(avatars);

            ThreadHelper.JoinableTaskFactory.RunAsync(
                () => BlameAuthor.ViewTextAsync("committer.txt", gutter));
            ThreadHelper.JoinableTaskFactory.RunAsync(
                () => BlameFile.ViewTextAsync(_fileName, body));

            if (lineNumber > 0)
            {
                BlameFile.GoToLine(lineNumber - 1);
            }
            else
            {
                BlameFile.VScrollPosition = scrollpos;
            }

            _clickedBlameLine = null;

            _blameId = revision.ObjectId;
            CommitInfo.SetRevisionWithChildren(revision, children);

            controlToMask?.UnMask();
        }
Пример #2
0
        private void ProcessBlame(GitRevision revision, IReadOnlyList <ObjectId> children, Control controlToMask, int lineNumber, int scrollpos)
        {
            var gutter = new StringBuilder(capacity: 4096);
            var body   = new StringBuilder(capacity: 4096);

            GitBlameCommit lastCommit = null;

            // NOTE EOL white-space supports highlight on mouse-over.
            // Highlighting is done via text background colour.
            // If it could be done with a solid rectangle around the text,
            // the extra spaces added here could be omitted.

            foreach (var line in _blame.Lines)
            {
                if (line.Commit == lastCommit)
                {
                    gutter.Append(' ', 200).AppendLine();
                }
                else
                {
                    gutter.Append(line.Commit.Author);
                    gutter.Append(" - ");
                    gutter.Append(line.Commit.AuthorTime.ToString(CultureInfo.CurrentUICulture));
                    gutter.Append(" - ");
                    gutter.Append(line.Commit.FileName);
                    gutter.Append(' ', 100).AppendLine();
                }

                body.AppendLine(line.Text);

                lastCommit = line.Commit;
            }

            ThreadHelper.JoinableTaskFactory.RunAsync(
                () => BlameCommitter.ViewTextAsync("committer.txt", gutter.ToString()));
            ThreadHelper.JoinableTaskFactory.RunAsync(
                () => BlameFile.ViewTextAsync(_fileName, body.ToString()));

            if (lineNumber > 0)
            {
                BlameFile.GoToLine(lineNumber - 1);
            }
            else
            {
                BlameFile.ScrollPos = scrollpos;
            }

            _clickedBlameLine = null;

            _blameId = revision.ObjectId;
            CommitInfo.SetRevisionWithChildren(revision, children);

            controlToMask?.UnMask();
        }
Пример #3
0
        private void ProcessBlame(GitRevision revision, List <string> children, Control controlToMask, int line, int scrollpos)
        {
            var blameCommitter = new StringBuilder();
            var blameFile      = new StringBuilder();

            for (int i = 0; i < _blame.Lines.Count; i++)
            {
                GitBlameLine   blameLine   = _blame.Lines[i];
                GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid);
                if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid)
                {
                    blameCommitter.AppendLine(new string(' ', 200));
                }
                else
                {
                    blameCommitter.AppendLine(
                        (blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName +
                         new string(' ', 100)).Trim(new[] { '\r', '\n' }));
                }
                if (blameLine.LineText == null)
                {
                    blameFile.AppendLine("");
                }
                else
                {
                    blameFile.AppendLine(blameLine.LineText.Trim(new[] { '\r', '\n' }));
                }
            }

            BlameCommitter.ViewText("committer.txt", blameCommitter.ToString());
            BlameFile.ViewText(_fileName, blameFile.ToString());
            if (line > 0)
            {
                BlameFile.GoToLine(line - 1);
            }
            else
            {
                BlameFile.ScrollPos = scrollpos;
            }

            _clickedBlameLine = new GitBlameLine();

            _blameHash = revision.Guid;
            CommitInfo.SetRevisionWithChildren(revision, children);

            if (controlToMask != null)
            {
                controlToMask.UnMask();
            }
        }
Пример #4
0
        public void LoadBlame(GitRevision revision, List <string> children, string fileName, RevisionGrid revGrid, Control controlToMask, Encoding encoding)
        {
            string guid = revision.Guid;

            //refresh only when something changed
            if (guid.Equals(CommitInfo.Revision) && fileName.Equals(fileName) && revGrid == _revGrid && encoding == _encoding)
            {
                return;
            }

            if (controlToMask != null)
            {
                controlToMask.Mask();
            }

            var scrollpos = BlameFile.ScrollPos;

            var blameCommitter = new StringBuilder();
            var blameFile      = new StringBuilder();

            _revGrid  = revGrid;
            _fileName = fileName;
            _encoding = encoding;

            blameLoader.Load(() =>
            {
                _blame = Module.Blame(fileName, guid, encoding);
            },
                             () =>
            {
                for (int i = 0; i < _blame.Lines.Count; i++)
                {
                    GitBlameLine blameLine     = _blame.Lines[i];
                    GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid);
                    if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid)
                    {
                        blameCommitter.AppendLine(new string(' ', 200));
                    }
                    else
                    {
                        blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new[] { '\r', '\n' }));
                    }
                    if (blameLine.LineText == null)
                    {
                        blameFile.AppendLine("");
                    }
                    else
                    {
                        blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' }));
                    }
                }

                BlameCommitter.ViewText("committer.txt", blameCommitter.ToString());
                BlameFile.ViewText(fileName, blameFile.ToString());
                BlameFile.ScrollPos = scrollpos;

                CommitInfo.SetRevisionWithChildren(revision, children);

                if (controlToMask != null)
                {
                    controlToMask.UnMask();
                }
            });
        }