Exemple #1
0
		/// <exception cref="System.IO.IOException"></exception>
		private bool WantSatisfied(RevObject want)
		{
			if (want.Has(SATISFIED))
			{
				return true;
			}
			walk.ResetRetain(SAVE);
			walk.MarkStart((RevCommit)want);
			if (oldestTime != 0)
			{
				walk.SetRevFilter(CommitTimeRevFilter.After(oldestTime * 1000L));
			}
			for (; ; )
			{
				RevCommit c = walk.Next();
				if (c == null)
				{
					break;
				}
				if (c.Has(PEER_HAS))
				{
					AddCommonBase(c);
					want.Add(SATISFIED);
					return true;
				}
			}
			return false;
		}
Exemple #2
0
			/// <summary>
			/// Mark an element which used to be shallow in the client, but which
			/// should now be considered a full commit.
			/// </summary>
			/// <remarks>
			/// Mark an element which used to be shallow in the client, but which
			/// should now be considered a full commit. Any ancestors of this commit
			/// should be included in the walk, even if they are the ancestor of an
			/// uninteresting commit.
			/// </remarks>
			/// <param name="c">Commit to mark</param>
			/// <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 virtual void MarkUnshallow(RevObject c)
			{
				if (c is RevCommit)
				{
					c.Add(UNSHALLOW);
				}
				base.MarkStart(c);
			}
		/// <exception cref="System.IO.IOException"></exception>
		private void MarkLocalObjComplete(RevObject obj)
		{
			while (obj.Type == Constants.OBJ_TAG)
			{
				obj.Add(COMPLETE);
				obj = ((RevTag)obj).GetObject();
				revWalk.ParseHeaders(obj);
			}
			switch (obj.Type)
			{
				case Constants.OBJ_BLOB:
				{
					obj.Add(COMPLETE);
					break;
				}

				case Constants.OBJ_COMMIT:
				{
					PushLocalCommit((RevCommit)obj);
					break;
				}

				case Constants.OBJ_TREE:
				{
					MarkTreeComplete((RevTree)obj);
					break;
				}
			}
		}
Exemple #4
0
		private void AddCommonBase(RevObject o)
		{
			if (!o.Has(COMMON))
			{
				o.Add(COMMON);
				commonBase.AddItem(o);
				okToGiveUp = null;
			}
		}
		private void ProcessTag(RevObject obj)
		{
			RevTag tag = (RevTag)obj;
			Needs(tag.GetObject());
			obj.Add(COMPLETE);
		}
		private void Needs(RevObject obj)
		{
			if (obj.Has(COMPLETE))
			{
				return;
			}
			if (!obj.Has(IN_WORK_QUEUE))
			{
				obj.Add(IN_WORK_QUEUE);
				workQueue.AddItem(obj);
			}
		}
		/// <exception cref="NGit.Errors.TransportException"></exception>
		private void ProcessCommit(RevObject obj)
		{
			RevCommit commit = (RevCommit)obj;
			MarkLocalCommitsComplete(commit.CommitTime);
			Needs(commit.Tree);
			foreach (RevCommit p in commit.Parents)
			{
				Needs(p);
			}
			obj.Add(COMPLETE);
		}
		/// <exception cref="NGit.Errors.TransportException"></exception>
		private void ProcessTree(RevObject obj)
		{
			try
			{
				treeWalk.Reset(obj);
				while (treeWalk.Next())
				{
					FileMode mode = treeWalk.GetFileMode(0);
					int sType = mode.GetObjectType();
					switch (sType)
					{
						case Constants.OBJ_BLOB:
						case Constants.OBJ_TREE:
						{
							treeWalk.GetObjectId(idBuffer, 0);
							Needs(revWalk.LookupAny(idBuffer, sType));
							continue;
							goto default;
						}

						default:
						{
							if (FileMode.GITLINK.Equals(mode))
							{
								continue;
							}
							treeWalk.GetObjectId(idBuffer, 0);
							throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().invalidModeFor
								, mode, idBuffer.Name, treeWalk.PathString, obj.Id.Name));
						}
					}
				}
			}
			catch (IOException ioe)
			{
				throw new TransportException(MessageFormat.Format(JGitText.Get().cannotReadTree, 
					obj.Name), ioe);
			}
			obj.Add(COMPLETE);
		}
		/// <exception cref="NGit.Errors.TransportException"></exception>
		private void ProcessBlob(RevObject obj)
		{
			try
			{
				if (reader.Has(obj, Constants.OBJ_BLOB))
				{
					obj.Add(COMPLETE);
				}
				else
				{
					throw new TransportException(MessageFormat.Format(JGitText.Get().cannotReadBlob, 
						obj.Name), new MissingObjectException(obj, Constants.TYPE_BLOB));
				}
			}
			catch (IOException error)
			{
				throw new TransportException(MessageFormat.Format(JGitText.Get().cannotReadBlob, 
					obj.Name), error);
			}
		}
		/// <exception cref="System.IO.IOException"></exception>
		private void AdvertiseAny(RevObject obj, string refName)
		{
			obj.Add(ADVERTISED);
			AdvertiseId(obj, refName);
		}
Exemple #11
0
		/// <exception cref="System.IO.IOException"></exception>
		private bool WantSatisfied(RevObject want)
		{
			if (want.Has(SATISFIED))
			{
				return true;
			}
			if (!(want is RevCommit))
			{
				want.Add(SATISFIED);
				return true;
			}
			walk.ResetRetain(SAVE);
			walk.MarkStart((RevCommit)want);
			for (; ; )
			{
				RevCommit c = walk.Next();
				if (c == null)
				{
					break;
				}
				if (c.Has(PEER_HAS))
				{
					AddCommonBase(c);
					want.Add(SATISFIED);
					return true;
				}
			}
			return false;
		}