/// <summary>Compute the next available segment and return the first index.</summary>
        /// <remarks>
        /// Compute the next available segment and return the first index.
        /// <p>
        /// Computes one segment and returns to the caller the first index that is
        /// available. After return the caller can also inspect
        /// <see cref="LastLength()">LastLength()</see>
        /// to determine how many lines of the result were computed.
        /// </remarks>
        /// <returns>index that is now available. -1 if no more are available.</returns>
        /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
        public virtual int ComputeNext()
        {
            BlameGenerator gen = generator;

            if (gen == null)
            {
                return(-1);
            }
            if (gen.Next())
            {
                LoadFrom(gen);
                lastLength = gen.GetRegionLength();
                return(gen.GetResultStart());
            }
            else
            {
                gen.Release();
                generator = null;
                return(-1);
            }
        }
        /// <summary>Compute all pending information.</summary>
        /// <remarks>Compute all pending information.</remarks>
        /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
        public virtual void ComputeAll()
        {
            BlameGenerator gen = generator;

            if (gen == null)
            {
                return;
            }
            try
            {
                while (gen.Next())
                {
                    LoadFrom(gen);
                }
            }
            finally
            {
                gen.Release();
                generator = null;
            }
        }
        /// <summary>Compute until the entire range has been populated.</summary>
        /// <remarks>Compute until the entire range has been populated.</remarks>
        /// <param name="start">first index to examine.</param>
        /// <param name="end">last index to examine.</param>
        /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
        public virtual void ComputeRange(int start, int end)
        {
            BlameGenerator gen = generator;

            if (gen == null)
            {
                return;
            }
            while (start < end)
            {
                if (HasSourceData(start, end))
                {
                    return;
                }
                if (!gen.Next())
                {
                    gen.Release();
                    generator = null;
                    return;
                }
                LoadFrom(gen);
                // If the result contains either end of our current range bounds,
                // update the bounds to avoid scanning that section during the
                // next loop iteration.
                int resLine = gen.GetResultStart();
                int resEnd  = gen.GetResultEnd();
                if (resLine <= start && start < resEnd)
                {
                    start = resEnd;
                }
                if (resLine <= end && end < resEnd)
                {
                    end = resLine;
                }
            }
        }