Inheritance: IGitItem
        public static void BuildStatusImageColumnCellPainting(DataGridViewCellPaintingEventArgs e, GitRevision revision, Brush foreBrush, Font rowFont)
        {
            if (revision.BuildStatus != null)
            {
                Image buildStatusImage = null;

                switch (revision.BuildStatus.Status)
                {
                    case BuildInfo.BuildStatus.Success:
                        buildStatusImage = Resources.BuildSuccessful;
                        break;
                    case BuildInfo.BuildStatus.Failure:
                        buildStatusImage = Resources.BuildFailed;
                        break;
                    case BuildInfo.BuildStatus.Unknown:
                        buildStatusImage = Resources.BuildCancelled;
                        break;
                    case BuildInfo.BuildStatus.InProgress:
                        buildStatusImage = Resources.Icon_77;
                        break;
                    case BuildInfo.BuildStatus.Unstable:
                        buildStatusImage = Resources.bug;
                        break;
                    case BuildInfo.BuildStatus.Stopped:
                        buildStatusImage = Resources.BuildCancelled;
                        break;
                }

                if (buildStatusImage != null)
                {
                    e.Graphics.DrawImage(buildStatusImage, new Rectangle(e.CellBounds.Left, e.CellBounds.Top + 4, 16, 16));
                }
            }
        }
        public static void BuildStatusMessageCellPainting(DataGridViewCellPaintingEventArgs e, GitRevision revision, Brush foreBrush, Font rowFont)
        {
            if (revision.BuildStatus != null)
            {
                Brush buildStatusForebrush = foreBrush;

                switch (revision.BuildStatus.Status)
                {
                    case BuildInfo.BuildStatus.Success:
                        buildStatusForebrush = Brushes.DarkGreen;
                        break;
                    case BuildInfo.BuildStatus.Failure:
                        buildStatusForebrush = Brushes.DarkRed;
                        break;
                    case BuildInfo.BuildStatus.InProgress:
                        buildStatusForebrush = Brushes.Blue;
                        break;
                    case BuildInfo.BuildStatus.Unstable:
                        buildStatusForebrush = Brushes.OrangeRed;
                        break;
                    case BuildInfo.BuildStatus.Stopped:
                        buildStatusForebrush = Brushes.Gray;
                        break;
                }

                var text = (string)e.FormattedValue;
                e.Graphics.DrawString(text, rowFont, buildStatusForebrush, new PointF(e.CellBounds.Left, e.CellBounds.Top + 4));
            }
        }
Exemplo n.º 3
0
        private void revisionGrid_SelectionChanged(object sender, EventArgs e)
        {
            var revisions = revisionGrid.GetSelectedRevisions();

            if (1 != revisions.Count)
            {
                return;
            }
            SelectedRevision = revisions[0];

            flowLayoutPanelParents.Visible = SelectedRevision.HasParent;

            if (!flowLayoutPanelParents.Visible)
            {
                return;
            }
            _parents             = SelectedRevision.ParentGuids.ToDictionary(p => GitRevision.ToShortSha(p), p => p);
            linkLabelParent.Text = _parents.Keys.ElementAt(0);

            linkLabelParent2.Visible = _parents.Count > 1;
            if (linkLabelParent2.Visible)
            {
                linkLabelParent2.Text = _parents.Keys.ElementAt(1);
            }
        }
Exemplo n.º 4
0
        public FormDiff(GitUICommands aCommands, RevisionGrid revisionGrid, string baseCommitSha,
            string headCommitSha, string baseCommitDisplayStr, string headCommitDisplayStr) : base(aCommands)
        {
            RevisionGrid = revisionGrid;
            _baseCommitDisplayStr = baseCommitDisplayStr;
            _headCommitDisplayStr = headCommitDisplayStr;

            InitializeComponent();
            Translate();

            _toolTipControl.SetToolTip(btnAnotherBaseBranch, anotherBranchTooltip.Text);
            _toolTipControl.SetToolTip(btnAnotherHeadBranch, anotherBranchTooltip.Text);
            _toolTipControl.SetToolTip(btnAnotherBaseCommit, anotherCommitTooltip.Text);
            _toolTipControl.SetToolTip(btnAnotherHeadCommit, anotherCommitTooltip.Text);
            _toolTipControl.SetToolTip(btnSwap, btnSwapTooltip.Text);

            if (!IsUICommandsInitialized)
            {// UICommands is not initialized in translation unit test.
                return;
            }

            _baseRevision = new GitRevision(Module, baseCommitSha);
            _headRevision = new GitRevision(Module, headCommitSha);
            _mergeBase = new GitRevision(Module, Module.GetMergeBase(_baseRevision.Guid, _headRevision.Guid));

            lblBaseCommit.BackColor = AppSettings.DiffRemovedColor;
            lblHeadCommit.BackColor = AppSettings.DiffAddedColor;

            DiffFiles.SelectedIndexChanged += DiffFiles_SelectedIndexChanged;

            DiffFiles.ContextMenuStrip = DiffContextMenu;

            this.Load += (sender, args) => PopulateDiffFiles();
        }
Exemplo n.º 5
0
        public RevisionGrid(GitRevision initialSelectedRevision)
        {
            _initialSelectedRevision = initialSelectedRevision;
            syncContext = SynchronizationContext.Current;

            base.InitLayout();
            InitializeComponent(); Translate();

            NormalFont = Revisions.Font;
            HeadFont = new Font(NormalFont, FontStyle.Underline);
            RefsFont = new Font(NormalFont, FontStyle.Bold);

            Revisions.CellPainting += new DataGridViewCellPaintingEventHandler(Revisions_CellPainting);
            Revisions.KeyDown += new KeyEventHandler(Revisions_KeyDown);

            showRevisionGraphToolStripMenuItem.Checked = Settings.ShowRevisionGraph;
            showAuthorDateToolStripMenuItem.Checked = Settings.ShowAuthorDate;
            orderRevisionsByDateToolStripMenuItem.Checked = Settings.OrderRevisionByDate;
            showRelativeDateToolStripMenuItem.Checked = Settings.RelativeDate;

            BranchFilter = String.Empty;
            SetShowBranches();
            filter = "";
            quickSearchString = "";
            quickSearchTimer.Tick += new EventHandler(quickSearchTimer_Tick);

            Revisions.Loading += new DvcsGraph.LoadingHandler(Revisions_Loading);
        }
Exemplo n.º 6
0
        public FormDiff(GitRevision revision)
        {
            InitializeComponent();
            EditorOptions.SetSyntax(DiffText, "output.cs");

            RevisionGrid.SetSelectedRevision( revision);
        }
Exemplo n.º 7
0
 public void SetRevision(string revision)
 {
     Revision = new GitRevision();
     Revision.Guid = revision;
     Revision.ParentGuids.Add(revision + "^");
     SetRevision(Revision);
 }
        public FormResetCurrentBranch(GitUICommands aCommands, GitRevision Revision)
            : base(aCommands)
        {
            this.Revision = Revision;

            InitializeComponent(); Translate();
        }
Exemplo n.º 9
0
        public FormFileHistory(string fileName, GitRevision revision, bool filterByRevision)
            : base(true)
        {
            InitializeComponent();
            syncContext = SynchronizationContext.Current;
            filterBranchHelper = new FilterBranchHelper(toolStripBranches, toolStripDropDownButton2, FileChanges);

            filterRevisionsHelper = new FilterRevisionsHelper(toolStripTextBoxFilter, toolStripDropDownButton1, FileChanges, toolStripLabel2, this);

            FileChanges.SetInitialRevision(revision);
            Translate();

            FileName = fileName;

            Diff.ExtraDiffArgumentsChanged += DiffExtraDiffArgumentsChanged;

            FileChanges.SelectionChanged += FileChangesSelectionChanged;
            FileChanges.DisableContextMenu();

            followFileHistoryToolStripMenuItem.Checked = Settings.FollowRenamesInFileHistory;
            fullHistoryToolStripMenuItem.Checked = Settings.FullHistoryInFileHistory;
            loadHistoryOnShowToolStripMenuItem.Checked = Settings.LoadFileHistoryOnShow;
            loadBlameOnShowToolStripMenuItem.Checked = Settings.LoadBlameOnShow;

            if (filterByRevision && revision != null && revision.Guid != null)
                filterBranchHelper.SetBranchFilter(revision.Guid, false);
        }
Exemplo n.º 10
0
 public void SetRevision(string revision)
 {
     Revision = new GitRevision();
     Revision.Guid = revision;
     Revision.ParentGuids = new string[]{revision + "^"};
     SetRevision(Revision);
 }
        public FormCherryPickCommitSmall(GitRevision revision)
        {
            Revision = revision;
            InitializeComponent();

            Translate();
        }
        public FormRevertCommitSmall(GitUICommands aCommands, GitRevision Revision)
            : base(aCommands)
        {
            this.Revision = Revision;

            InitializeComponent(); Translate();
        }
Exemplo n.º 13
0
        public FormDiff(GitRevision revision)
        {
            InitializeComponent();
            Translate();

            RevisionGrid.SetSelectedRevision(revision);
        }
Exemplo n.º 14
0
 public LanePoint AddPoint(Lane lane, GitRevision revision)
 {
     LanePoint point = lane.AddPoint(lane, Points.Count);
     Points.Add(point);
     point.Revision = revision;
     return point;
 }
Exemplo n.º 15
0
        public void SetRevision(GitRevision revision)
        {
            Revision = revision;
            DiffFiles.GitItemStatuses = null;
            DiffFiles.GitItemStatuses = GitCommandHelpers.GetDiffFiles(revision.Guid + "^", revision.Guid);

            commitInfo.SetRevision(revision.Guid);
        }
Exemplo n.º 16
0
        public void SetRevision(GitRevision revision)
        {
            Revision = revision;
            DiffFiles.GitItemStatuses = null;
            DiffFiles.GitItemStatuses = Settings.Module.GetDiffFiles(revision.Guid, revision.Guid + "^");

            commitInfo.SetRevision(revision.Guid);
        }
        public FormResetCurrentBranch(GitUICommands aCommands, GitRevision Revision)
            : base(aCommands)
        {
            this.Revision = Revision;

            InitializeComponent(); Translate();
            this.checkNoAsk.Checked = false;    // default
        }
Exemplo n.º 18
0
        public FormTagSmall(GitRevision revision)
        {
            InitializeComponent();
            Translate();

            tagMessage.MistakeFont = new Font(SystemFonts.MessageBoxFont, FontStyle.Underline);
            this.revision = revision;
        }
Exemplo n.º 19
0
        public FormCherryPick(GitUICommands aCommands, GitRevision revision)
            : base(aCommands)
        {
            Revision = revision;
            InitializeComponent();

            Translate();
        }
Exemplo n.º 20
0
        public void SetRevision(GitRevision revision)
        {
            Revision = revision;
            DiffFiles.DataSource = null;
            DiffFiles.DisplayMember = "FileNameB";

            DiffFiles.DataSource = GitCommands.GitCommands.GetDiffFiles(revision.Guid, revision.ParentGuids[0]);
        }
        public FormCreateTagAtRevision(GitUICommands aCommands, GitRevision revision)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            tagMessage.MistakeFont = new Font(SystemFonts.MessageBoxFont, FontStyle.Underline);
            this.revision = revision;
        }
        public GitRefListsForRevision(GitRevision revision)
        {
            _allBranches = revision.Refs.Where(h => !h.IsTag && (h.IsHead || h.IsRemote)).ToArray();
            _localBranches = _allBranches.Where(b => !b.IsRemote).ToArray();
            _branchesWithNoIdenticalRemotes = _allBranches.Where(
                b => !b.IsRemote || !_localBranches.Any(lb => lb.TrackingRemote == b.Remote && lb.MergeWith == b.LocalName)).ToArray();

            _tags = revision.Refs.Where(h => h.IsTag).ToArray();
        }
Exemplo n.º 23
0
 private void revisionGrid_DoubleClickRevision(object sender, DoubleClickRevisionEventArgs e)
 {
     if (e.Revision != null)
     {
         SelectedRevision = e.Revision;
         DialogResult     = DialogResult.OK;
         Close();
     }
 }
Exemplo n.º 24
0
        public FormDiff(GitModule module, GitRevision revision)
            : base(true)
        {
            InitializeComponent();
            Translate();

            module_ = module;
            RevisionGrid.SetSelectedRevision(revision);
        }
Exemplo n.º 25
0
 private void revisionGrid_DoubleClickRevision(object sender, UserControls.RevisionGridClasses.DoubleClickRevisionEventArgs e)
 {
     if (e.Revision != null)
     {
         SelectedRevision = e.Revision;
         DialogResult = DialogResult.OK;
         Close();
     }
 }
        public FormCherryPickCommitSmall(GitRevision revision)
        {
            Revision = revision;
            InitializeComponent();

            Translate();

            this.AutoCommit.Checked = true;
            this.Pick.Focus();
        }
Exemplo n.º 27
0
 private void btnChooseRevision_Click(object sender, EventArgs e)
 {
     using (var chooseForm = new FormChooseCommit(UICommands, SelectedRevision.Guid))
     {
         if (chooseForm.ShowDialog(this) == DialogResult.OK && chooseForm.SelectedRevision != null)
         {
             SelectedRevision = chooseForm.SelectedRevision;
         }
     }
 }
Exemplo n.º 28
0
        public FormCreateBranch(GitUICommands aCommands, GitRevision revision)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            commitPickerSmallControl1.UICommandsSource = this;
            if (IsUICommandsInitialized)
                commitPickerSmallControl1.SetSelectedCommitHash(revision == null ? Module.GetCurrentCheckout() : revision.Guid);
        }
Exemplo n.º 29
0
        public void SetRevision(GitRevision revision)
        {
            Revision = revision;
            DiffFiles.GitItemStatusses = null;

            if (revision.ParentGuids.Length > 0)
                DiffFiles.GitItemStatusses = GitCommands.GitCommands.GetDiffFiles(revision.Guid, revision.ParentGuids[0]);

            commitInfo.SetRevision(revision.Guid);
        }
        public void FillBuildReport(GitRevision revision)
        {
            if (EnvUtils.IsMonoRuntime())
                return;

            if (selectedGitRevision != null) selectedGitRevision.PropertyChanged -= RevisionPropertyChanged;
            selectedGitRevision = revision;
            if (selectedGitRevision != null) selectedGitRevision.PropertyChanged += RevisionPropertyChanged;

            var buildInfoIsAvailable =
                !(revision == null || revision.BuildStatus == null || string.IsNullOrEmpty(revision.BuildStatus.Url));

            tabControl.SuspendLayout();

            try
            {
                if (buildInfoIsAvailable)
                {
                    if (buildReportTabPage == null)
                    {
                        CreateBuildReportTabPage(tabControl);
                    }

                    var isFavIconMissing = buildReportTabPage.ImageIndex < 0;

                    if (isFavIconMissing || tabControl.SelectedTab == buildReportTabPage)
                    {
                        buildReportWebBrowser.Navigate(revision.BuildStatus.Url);

                        if (isFavIconMissing)
                        {
                            buildReportWebBrowser.Navigated += BuildReportWebBrowserOnNavigated;
                        }
                    }

                    if (!tabControl.Controls.Contains(buildReportTabPage))
                    {
                        tabControl.Controls.Add(buildReportTabPage);
                    }
                }
                else
                {
                    if (buildReportTabPage != null && tabControl.Controls.Contains(buildReportTabPage))
                    {
                        buildReportWebBrowser.Stop();
                        buildReportWebBrowser.Document.Write(string.Empty);
                        tabControl.Controls.Remove(buildReportTabPage);
                    }
                }
            }
            finally
            {
                tabControl.ResumeLayout();
            }
        }
Exemplo n.º 31
0
        public FormCreateTag(GitUICommands aCommands, GitRevision revision)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            tagMessage.MistakeFont = new Font(SystemFonts.MessageBoxFont, FontStyle.Underline);
            commitPickerSmallControl1.UICommandsSource = this;
            if (IsUICommandsInitialized)
                commitPickerSmallControl1.SetSelectedCommitHash(revision == null ? null : revision.Guid);
        }
Exemplo n.º 32
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var revisions = revisionGrid.GetSelectedRevisions();
            if (1 == revisions.Count)
            {
                SelectedRevision = revisions[0];
                DialogResult = DialogResult.OK;

                Close();
            }
        }
Exemplo n.º 33
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var revisions = revisionGrid.GetSelectedRevisions();

            if (1 == revisions.Count)
            {
                SelectedRevision = revisions[0];
                DialogResult     = DialogResult.OK;

                Close();
            }
        }
Exemplo n.º 34
0
 public abstract bool PassThru(GitRevision rev);
Exemplo n.º 35
0
        void DataReceived(string data)
        {
            if (data.StartsWith(CommitBegin))
            {
                // a new commit finalizes the last revision
                FinishRevision();
                _nextStep = ReadStep.Commit;
            }

            switch (_nextStep)
            {
            case ReadStep.Commit:
                data = GitModule.ReEncodeString(data, GitModule.LosslessEncoding, _module.LogOutputEncoding);

                string[] lines = data.Split(new char[] { '\n' });
                Debug.Assert(lines.Length == 11);
                Debug.Assert(lines[0] == CommitBegin);

                _revision = new GitRevision(_module, null);

                _revision.Guid = lines[1];
                {
                    List <GitRef> gitRefs;
                    if (_refs.TryGetValue(_revision.Guid, out gitRefs))
                    {
                        _revision.Refs.AddRange(gitRefs);
                    }
                }

                // RemoveEmptyEntries is required for root commits. They should have empty list of parents.
                _revision.ParentGuids = lines[2].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                _revision.TreeGuid    = lines[3];

                _revision.Author      = lines[4];
                _revision.AuthorEmail = lines[5];
                {
                    DateTime dateTime;
                    if (DateTimeUtils.TryParseUnixTime(lines[6], out dateTime))
                    {
                        _revision.AuthorDate = dateTime;
                    }
                }

                _revision.Committer      = lines[7];
                _revision.CommitterEmail = lines[8];
                {
                    DateTime dateTime;
                    if (DateTimeUtils.TryParseUnixTime(lines[9], out dateTime))
                    {
                        _revision.CommitDate = dateTime;
                    }
                }

                _revision.MessageEncoding = lines[10];
                break;

            case ReadStep.CommitSubject:
                _revision.Subject = _module.ReEncodeCommitMessage(data, _revision.MessageEncoding);
                break;

            case ReadStep.CommitBody:
                _revision.Body = _module.ReEncodeCommitMessage(data, _revision.MessageEncoding);
                break;

            case ReadStep.FileName:
                if (!string.IsNullOrEmpty(data))
                {
                    // Git adds \n between the format string (ends with \0 in our case)
                    // and the first file name. So, we need to remove it from the file name.
                    _revision.Name = data.TrimStart(new char[] { '\n' });
                }
                break;
            }

            _nextStep++;
        }
Exemplo n.º 36
0
 public RevisionGraphUpdatedEventArgs(GitRevision revision)
 {
     Revision = revision;
 }
Exemplo n.º 37
0
        private static bool TryParseRevision(GitModule module, ArraySegment <byte> chunk, StringPool stringPool, Encoding logOutputEncoding, out GitRevision revision)
        {
            // The 'chunk' of data contains a complete git log item, encoded.
            // This method decodes that chunk and produces a revision object.

            // All values which can be read directly from the byte array are arranged
            // at the beginning of the chunk. The latter part of the chunk will require
            // decoding as a string.

            if (chunk.Count == 0)
            {
                // "git log -z --name-only" returns multiple consecutive null bytes when logging
                // the history of a single file. Haven't worked out why, but it's safe to skip
                // such chunks.
                revision = default;
                return(false);
            }

            #region Object ID, Tree ID, Parent IDs

            // The first 40 bytes are the revision ID and the tree ID back to back
            if (!ObjectId.TryParseAsciiHexBytes(chunk, 0, out var objectId) ||
                !ObjectId.TryParseAsciiHexBytes(chunk, ObjectId.Sha1CharCount, out var treeId))
            {
                revision = default;
                return(false);
            }

            var array      = chunk.Array;
            var offset     = chunk.Offset + (ObjectId.Sha1CharCount * 2);
            var lastOffset = chunk.Offset + chunk.Count;

            // Next we have zero or more parent IDs separated by ' ' and terminated by '\n'
            var parentIds   = new ObjectId[CountParents(offset)];
            var parentIndex = 0;

            int CountParents(int baseOffset)
            {
                if (array[baseOffset] == '\n')
                {
                    return(0);
                }

                var count = 1;

                while (true)
                {
                    baseOffset += ObjectId.Sha1CharCount;
                    var c = array[baseOffset];

                    if (c != ' ')
                    {
                        break;
                    }

                    count++;
                    baseOffset++;
                }

                return(count);
            }

            while (true)
            {
                if (offset >= lastOffset - ObjectId.Sha1CharCount - 1)
                {
                    revision = default;
                    return(false);
                }

                var b = array[offset];

                if (b == '\n')
                {
                    // There are no more parent IDs
                    offset++;
                    break;
                }

                if (b == ' ')
                {
                    // We are starting a new parent ID
                    offset++;
                }

                if (!ObjectId.TryParseAsciiHexBytes(array, offset, out var parentId))
                {
                    // TODO log this parse problem
                    revision = default;
                    return(false);
                }

                parentIds[parentIndex++] = parentId;
                offset += ObjectId.Sha1CharCount;
            }

            #endregion

            #region Timestamps

            // Lines 2 and 3 are timestamps, as decimal ASCII seconds since the unix epoch, each terminated by `\n`
            var authorDate = ParseUnixDateTime();
            var commitDate = ParseUnixDateTime();

            DateTime ParseUnixDateTime()
            {
                long unixTime = 0;

                while (true)
                {
                    var c = array[offset++];

                    if (c == '\n')
                    {
                        return(DateTimeUtils.UnixEpoch.AddTicks(unixTime * TimeSpan.TicksPerSecond).ToLocalTime());
                    }

                    unixTime = (unixTime * 10) + (c - '0');
                }
            }

            #endregion

            #region Encoding

            // Line is the name of the encoding used by git, or an empty string, terminated by `\n`
            string   encodingName;
            Encoding encoding;

            var encodingNameEndOffset = Array.IndexOf(array, (byte)'\n', offset);

            if (encodingNameEndOffset == -1)
            {
                // TODO log this error case
                revision = default;
                return(false);
            }

            if (offset == encodingNameEndOffset)
            {
                // No encoding specified
                encoding     = logOutputEncoding;
                encodingName = null;
            }
            else
            {
                encodingName = logOutputEncoding.GetString(array, offset, encodingNameEndOffset - offset);
                encoding     = module.GetEncodingByGitName(encodingName);
            }

            offset = encodingNameEndOffset + 1;

            #endregion

            #region Encoded string values (names, emails, subject, body)

            // Finally, decode the names, email, subject and body strings using the required text encoding
            var s = encoding.GetString(array, offset, lastOffset - offset);

            var reader = new StringLineReader(s);

            var author         = reader.ReadLine(stringPool);
            var authorEmail    = reader.ReadLine(stringPool);
            var committer      = reader.ReadLine(stringPool);
            var committerEmail = reader.ReadLine(stringPool);

            var subject = reader.ReadLine(advance: false);
            Debug.Assert(subject != null, "subject != null");

            // NOTE the convention is that the Subject string is duplicated at the start of the Body string
            // Therefore we read the subject twice.
            // If there are not enough characters remaining for a body, then just assign the subject string directly.
            var body = reader.Remaining - subject.Length == 2 ? subject : reader.ReadToEnd();
            Debug.Assert(body != null, "body != null");

            if (author == null || authorEmail == null || committer == null || committerEmail == null || subject == null || body == null)
            {
                // TODO log this parse error
                Debug.Fail("Unable to read an entry from the log -- this should not happen");
                revision = default;
                return(false);
            }

            #endregion

            revision = new GitRevision(objectId)
            {
                ParentIds           = parentIds,
                TreeGuid            = treeId,
                Author              = author,
                AuthorEmail         = authorEmail,
                AuthorDate          = authorDate,
                Committer           = committer,
                CommitterEmail      = committerEmail,
                CommitDate          = commitDate,
                MessageEncoding     = encodingName,
                Subject             = subject,
                Body                = body,
                HasMultiLineMessage = !ReferenceEquals(subject, body)
            };

            return(true);
        }