示例#1
0
        private void execute()
        {
            try
            {
                RevisionCount = 0;

                heads = GitCommandHelpers.GetHeads(true);

                string formatString =
                    /* <COMMIT>       */ COMMIT_BEGIN + "%n" +
                    /* Hash           */ "%H%n" +
                    /* Parents        */ "%P%n";
                if (!ShaOnly)
                {
                    formatString +=
                        /* Tree           */ "%T%n" +
                        /* Author Name    */ "%aN%n" +
                        /* Author Date    */ "%ai%n" +
                        /* Committer Name */ "%cN%n" +
                        /* Committer Date */ "%ci%n" +
                        /* Commit Message */ "%s";
                }

                // NOTE:
                // when called from FileHistory and FollowRenamesInFileHistory is enabled the "--name-only" argument is set.
                // the filename is the next line after the commit-format defined above.

                if (Settings.OrderRevisionByDate)
                {
                    LogParam = " --date-order " + LogParam;
                }
                else
                {
                    LogParam = " --topo-order " + LogParam;
                }

                string arguments = String.Format(CultureInfo.InvariantCulture,
                                                 "log -z {2} --pretty=format:\"{1}\" {0}",
                                                 LogParam,
                                                 formatString,
                                                 BranchFilter);

                gitGetGraphCommand = new GitCommandsInstance();
                gitGetGraphCommand.StreamOutput  = true;
                gitGetGraphCommand.CollectOutput = false;
                Process p = gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

                string line;
                do
                {
                    line = p.StandardOutput.ReadLine();

                    if (line != null)
                    {
                        foreach (string entry in line.Split('\0'))
                        {
                            dataReceived(entry);
                        }
                    }
                } while (line != null);
                finishRevision();
            }
            catch (ThreadAbortException)
            {
                //Silently ignore this exception...
            }
            catch (Exception ex)
            {
                if (Error != null)
                {
                    Error(this, EventArgs.Empty);
                }
                MessageBox.Show("Cannot load commit log." + Environment.NewLine + Environment.NewLine + ex.ToString());
                return;
            }

            if (Exited != null)
            {
                Exited(this, EventArgs.Empty);
            }
        }