// Ignore the deletion failure. We probably are
        // already failing and were just trying to pick
        // up after ourselves.
        private void DeleteCommand(RemoteRefUpdate u)
        {
            Ref r = Sharpen.Collections.Remove(newRefs, u.GetRemoteName());

            if (r == null)
            {
                // Already gone.
                //
                u.SetStatus(RemoteRefUpdate.Status.OK);
                return;
            }
            if (r.GetStorage().IsPacked())
            {
                packedRefUpdates.AddItem(u);
            }
            if (r.GetStorage().IsLoose())
            {
                try
                {
                    dest.DeleteRef(u.GetRemoteName());
                    u.SetStatus(RemoteRefUpdate.Status.OK);
                }
                catch (IOException e)
                {
                    u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
                    u.SetMessage(e.Message);
                }
            }
            try
            {
                dest.DeleteRefLog(u.GetRemoteName());
            }
            catch (IOException e)
            {
                u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
                u.SetMessage(e.Message);
            }
        }
 private void UpdateCommand(RemoteRefUpdate u)
 {
     try
     {
         dest.WriteRef(u.GetRemoteName(), u.GetNewObjectId());
         newRefs.Put(u.GetRemoteName(), new ObjectIdRef.Unpeeled(RefStorage.LOOSE, u.GetRemoteName
                                                                     (), u.GetNewObjectId()));
         u.SetStatus(RemoteRefUpdate.Status.OK);
     }
     catch (IOException e)
     {
         u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
         u.SetMessage(e.Message);
     }
 }
Пример #3
0
        /// <exception cref="System.IO.IOException"></exception>
        private void ReadStatusReport(IDictionary <string, RemoteRefUpdate> refUpdates)
        {
            string unpackLine = ReadStringLongTimeout();

            if (!unpackLine.StartsWith("unpack "))
            {
                throw new PackProtocolException(uri, MessageFormat.Format(JGitText.Get().unexpectedReportLine
                                                                          , unpackLine));
            }
            string unpackStatus = Sharpen.Runtime.Substring(unpackLine, "unpack ".Length);

            if (!unpackStatus.Equals("ok"))
            {
                throw new TransportException(uri, MessageFormat.Format(JGitText.Get().errorOccurredDuringUnpackingOnTheRemoteEnd
                                                                       , unpackStatus));
            }
            string refLine;

            while ((refLine = pckIn.ReadString()) != PacketLineIn.END)
            {
                bool ok         = false;
                int  refNameEnd = -1;
                if (refLine.StartsWith("ok "))
                {
                    ok         = true;
                    refNameEnd = refLine.Length;
                }
                else
                {
                    if (refLine.StartsWith("ng "))
                    {
                        ok         = false;
                        refNameEnd = refLine.IndexOf(" ", 3);
                    }
                }
                if (refNameEnd == -1)
                {
                    throw new PackProtocolException(MessageFormat.Format(JGitText.Get().unexpectedReportLine2
                                                                         , uri, refLine));
                }
                string          refName = Sharpen.Runtime.Substring(refLine, 3, refNameEnd);
                string          message = (ok ? null : Sharpen.Runtime.Substring(refLine, refNameEnd + 1));
                RemoteRefUpdate rru     = refUpdates.Get(refName);
                if (rru == null)
                {
                    throw new PackProtocolException(MessageFormat.Format(JGitText.Get().unexpectedRefReport
                                                                         , uri, refName));
                }
                if (ok)
                {
                    rru.SetStatus(RemoteRefUpdate.Status.OK);
                }
                else
                {
                    rru.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
                    rru.SetMessage(message);
                }
            }
            foreach (RemoteRefUpdate rru_1 in refUpdates.Values)
            {
                if (rru_1.GetStatus() == RemoteRefUpdate.Status.AWAITING_REPORT)
                {
                    throw new PackProtocolException(MessageFormat.Format(JGitText.Get().expectedReportForRefNotReceived
                                                                         , uri, rru_1.GetRemoteName()));
                }
            }
        }
Пример #4
0
		private void UpdateCommand(RemoteRefUpdate u)
		{
			try
			{
				dest.WriteRef(u.GetRemoteName(), u.GetNewObjectId());
				newRefs.Put(u.GetRemoteName(), new ObjectIdRef.Unpeeled(RefStorage.LOOSE, u.GetRemoteName
					(), u.GetNewObjectId()));
				u.SetStatus(RemoteRefUpdate.Status.OK);
			}
			catch (IOException e)
			{
				u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
				u.SetMessage(e.Message);
			}
		}
Пример #5
0
		// Ignore the deletion failure. We probably are
		// already failing and were just trying to pick
		// up after ourselves.
		private void DeleteCommand(RemoteRefUpdate u)
		{
			Ref r = Sharpen.Collections.Remove(newRefs, u.GetRemoteName());
			if (r == null)
			{
				// Already gone.
				//
				u.SetStatus(RemoteRefUpdate.Status.OK);
				return;
			}
			if (r.GetStorage().IsPacked())
			{
				packedRefUpdates.AddItem(u);
			}
			if (r.GetStorage().IsLoose())
			{
				try
				{
					dest.DeleteRef(u.GetRemoteName());
					u.SetStatus(RemoteRefUpdate.Status.OK);
				}
				catch (IOException e)
				{
					u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
					u.SetMessage(e.Message);
				}
			}
			try
			{
				dest.DeleteRefLog(u.GetRemoteName());
			}
			catch (IOException e)
			{
				u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
				u.SetMessage(e.Message);
			}
		}