Exemple #1
0
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="NGit.Api.Errors.JGitInternalException"></exception>
 private NGit.Api.LogCommand Add(bool include, AnyObjectId start)
 {
     CheckCallable();
     try
     {
         if (include)
         {
             walk.MarkStart(walk.LookupCommit(start));
             startSpecified = true;
         }
         else
         {
             walk.MarkUninteresting(walk.LookupCommit(start));
         }
         return(this);
     }
     catch (MissingObjectException e)
     {
         throw;
     }
     catch (IncorrectObjectTypeException e)
     {
         throw;
     }
     catch (IOException e)
     {
         throw new JGitInternalException(MessageFormat.Format(JGitText.Get().exceptionOccuredDuringAddingOfOptionToALogCommand
                                                              , start), e);
     }
 }
Exemple #2
0
 /// <summary>Configure the generator to compute reverse blame (history of deletes).</summary>
 /// <remarks>
 /// Configure the generator to compute reverse blame (history of deletes).
 /// <p>
 /// This method is expensive as it immediately runs a RevWalk over the
 /// history spanning the expression
 /// <code>start..end</code>
 /// (end being more recent
 /// than start) and then performs the equivalent operation as
 /// <see cref="Push(string, NGit.AnyObjectId)">Push(string, NGit.AnyObjectId)</see>
 /// to begin blame traversal from the
 /// commit named by
 /// <code>start</code>
 /// walking forwards through history until
 /// <code>end</code>
 /// blaming line deletions.
 /// <p>
 /// A reverse blame may produce multiple sources for the same result line,
 /// each of these is a descendant commit that removed the line, typically
 /// this occurs when the same deletion appears in multiple side branches such
 /// as due to a cherry-pick. Applications relying on reverse should use
 /// <see cref="BlameResult">BlameResult</see>
 /// as it filters these duplicate sources and only
 /// remembers the first (oldest) deletion.
 /// </remarks>
 /// <param name="start">
 /// oldest commit to traverse from. The result file will be loaded
 /// from this commit's tree.
 /// </param>
 /// <param name="end">
 /// most recent commits to stop traversal at. Usually an active
 /// branch tip, tag, or HEAD.
 /// </param>
 /// <returns>
 ///
 /// <code>this</code>
 /// </returns>
 /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
 public virtual NGit.Blame.BlameGenerator Reverse <_T0>(AnyObjectId start, ICollection
                                                        <_T0> end) where _T0 : ObjectId
 {
     InitRevPool(true);
     ReverseWalk.ReverseCommit result = (ReverseWalk.ReverseCommit)revPool.ParseCommit
                                            (start);
     if (!Find(result, resultPath))
     {
         return(this);
     }
     revPool.MarkUninteresting(result);
     foreach (ObjectId id in end)
     {
         revPool.MarkStart(revPool.ParseCommit(id));
     }
     while (revPool.Next() != null)
     {
     }
     // just pump the queue
     Candidate.ReverseCandidate c = new Candidate.ReverseCandidate(result, resultPath);
     c.sourceBlob = idBuf.ToObjectId();
     c.LoadText(reader);
     c.regionList = new Region(0, 0, c.sourceText.Size());
     remaining    = c.sourceText.Size();
     Push(c);
     return(this);
 }
Exemple #3
0
        /// <summary>
        /// Find commits that are reachable from <code>start</code> until a commit
        /// that is reachable from <code>end</code> is encountered.
        /// </summary>
        /// <remarks>
        /// Find commits that are reachable from <code>start</code> until a commit
        /// that is reachable from <code>end</code> is encountered. In other words,
        /// Find of commits that are in <code>start</code>, but not in
        /// <code>end</code>.
        /// <p>
        /// Note that this method calls
        /// <see cref="RevWalk.Reset()">RevWalk.Reset()</see>
        /// at the beginning.
        /// Also note that the existing rev filter on the walk is left as-is, so be
        /// sure to set the right rev filter before calling this method.
        /// </remarks>
        /// <param name="walk">the rev walk to use</param>
        /// <param name="start">the commit to start counting from</param>
        /// <param name="end">
        /// the commit where counting should end, or null if counting
        /// should be done until there are no more commits
        /// </param>
        /// <returns>the commits found</returns>
        /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
        ///     </exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
        ///     </exception>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public static IList <RevCommit> Find(RevWalk walk, RevCommit start, RevCommit end)
        {
            walk.Reset();
            walk.MarkStart(start);
            if (end != null)
            {
                walk.MarkUninteresting(end);
            }
            IList <RevCommit> commits = new AList <RevCommit>();

            foreach (RevCommit c in walk)
            {
                commits.AddItem(c);
            }
            return(commits);
        }
Exemple #4
0
 /// <summary>
 /// Find commits that are reachable from <code>start</code> until a commit
 /// that is reachable from <code>end</code> is encountered.
 /// </summary>
 /// <remarks>
 /// Find commits that are reachable from <code>start</code> until a commit
 /// that is reachable from <code>end</code> is encountered. In other words,
 /// Find of commits that are in <code>start</code>, but not in
 /// <code>end</code>.
 /// <p>
 /// Note that this method calls
 /// <see cref="RevWalk.Reset()">RevWalk.Reset()</see>
 /// at the beginning.
 /// Also note that the existing rev filter on the walk is left as-is, so be
 /// sure to set the right rev filter before calling this method.
 /// </remarks>
 /// <param name="walk">the rev walk to use</param>
 /// <param name="start">the commit to start counting from</param>
 /// <param name="end">
 /// the commit where counting should end, or null if counting
 /// should be done until there are no more commits
 /// </param>
 /// <returns>the commits found</returns>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 /// 	</exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public static IList<RevCommit> Find(RevWalk walk, RevCommit start, RevCommit end)
 {
     walk.Reset();
     walk.MarkStart(start);
     if (end != null)
     {
         walk.MarkUninteresting(end);
     }
     IList<RevCommit> commits = new AList<RevCommit>();
     foreach (RevCommit c in walk)
     {
         commits.AddItem(c);
     }
     return commits;
 }
Exemple #5
0
 /// <exception cref="System.Exception"></exception>
 protected internal virtual void MarkUninteresting(RevCommit commit)
 {
     rw.MarkUninteresting(commit);
 }
Exemple #6
0
		// Utility class
		/// <summary>
		/// Count the number of commits that are reachable from <code>start</code>
		/// until a commit that is reachable from <code>end</code> is encountered.
		/// </summary>
		/// <remarks>
		/// Count the number of commits that are reachable from <code>start</code>
		/// until a commit that is reachable from <code>end</code> is encountered. In
		/// other words, count the number of commits that are in <code>start</code>,
		/// but not in <code>end</code>.
		/// <p>
		/// Note that this method calls
		/// <see cref="RevWalk.Reset()">RevWalk.Reset()</see>
		/// at the beginning.
		/// Also note that the existing rev filter on the walk is left as-is, so be
		/// sure to set the right rev filter before calling this method.
		/// </remarks>
		/// <param name="walk">the rev walk to use</param>
		/// <param name="start">the commit to start counting from</param>
		/// <param name="end">
		/// the commit where counting should end, or null if counting
		/// should be done until there are no more commits
		/// </param>
		/// <returns>the number of commits</returns>
		/// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
		/// 	</exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
		/// 	</exception>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public static int Count(RevWalk walk, RevCommit start, RevCommit end)
		{
			walk.Reset();
			walk.MarkStart(start);
			if (end != null)
			{
				walk.MarkUninteresting(end);
			}
			int count = 0;
			for (RevCommit c = walk.Next(); c != null; c = walk.Next())
			{
				count++;
			}
			return count;
		}