Ejemplo n.º 1
0
        // expected
        /// <exception cref="System.IO.IOException"></exception>
        private int CountPicks()
        {
            int            count    = 0;
            FilePath       todoFile = new FilePath(db.Directory, "rebase-merge/git-rebase-todo");
            BufferedReader br       = new BufferedReader(new InputStreamReader(new FileInputStream(
                                                                                   todoFile), "UTF-8"));

            try
            {
                string line = br.ReadLine();
                while (line != null)
                {
                    string actionToken          = Sharpen.Runtime.Substring(line, 0, line.IndexOf(' '));
                    RebaseCommand.Action action = null;
                    try
                    {
                        action = RebaseCommand.Action.Parse(actionToken);
                    }
                    catch (Exception)
                    {
                    }
                    // ignore
                    if (action != null)
                    {
                        count++;
                    }
                    line = br.ReadLine();
                }
                return(count);
            }
            finally
            {
                br.Close();
            }
        }
Ejemplo n.º 2
0
        /// <exception cref="System.IO.IOException"></exception>
        private IList <RebaseCommand.Step> LoadSteps()
        {
            byte[] buf                   = IOUtil.ReadFully(new FilePath(rebaseDir, GIT_REBASE_TODO));
            int    ptr                   = 0;
            int    tokenBegin            = 0;
            AList <RebaseCommand.Step> r = new AList <RebaseCommand.Step>();

            while (ptr < buf.Length)
            {
                tokenBegin = ptr;
                ptr        = RawParseUtils.NextLF(buf, ptr);
                int nextSpace              = 0;
                int tokenCount             = 0;
                RebaseCommand.Step current = null;
                while (tokenCount < 3 && nextSpace < ptr)
                {
                    switch (tokenCount)
                    {
                    case 0:
                    {
                        nextSpace = RawParseUtils.Next(buf, tokenBegin, ' ');
                        string actionToken = Sharpen.Runtime.GetStringForBytes(buf, tokenBegin, nextSpace
                                                                               - tokenBegin - 1);
                        tokenBegin = nextSpace;
                        if (actionToken[0] == '#')
                        {
                            tokenCount = 3;
                            break;
                        }
                        RebaseCommand.Action action = RebaseCommand.Action.Parse(actionToken);
                        if (action != null)
                        {
                            current = new RebaseCommand.Step(RebaseCommand.Action.Parse(actionToken));
                        }
                        break;
                    }

                    case 1:
                    {
                        if (current == null)
                        {
                            break;
                        }
                        nextSpace = RawParseUtils.Next(buf, tokenBegin, ' ');
                        string commitToken = Sharpen.Runtime.GetStringForBytes(buf, tokenBegin, nextSpace
                                                                               - tokenBegin - 1);
                        tokenBegin     = nextSpace;
                        current.commit = AbbreviatedObjectId.FromString(commitToken);
                        break;
                    }

                    case 2:
                    {
                        if (current == null)
                        {
                            break;
                        }
                        nextSpace = ptr;
                        int length = ptr - tokenBegin;
                        current.shortMessage = new byte[length];
                        System.Array.Copy(buf, tokenBegin, current.shortMessage, 0, length);
                        r.AddItem(current);
                        break;
                    }
                    }
                    tokenCount++;
                }
            }
            return(r);
        }
Ejemplo n.º 3
0
 internal Step(RebaseCommand.Action action)
 {
     this.action = action;
 }