Beispiel #1
0
        public void Push(ProgressMonitor monitor, IDictionary <string, RemoteRefUpdate> refUpdates)
        {
            if (refUpdates == null)
            {
                throw new ArgumentNullException("refUpdates");
            }

            markStartedOperation();
            _packNames        = null;
            _newRefs          = new Dictionary <string, Ref>(RefsMap);
            _packedRefUpdates = new List <RemoteRefUpdate>(refUpdates.Count);

            // Filter the commands and issue all deletes first. This way we
            // can correctly handle a directory being cleared out and a new
            // ref using the directory name being created.
            //
            var updates = new List <RemoteRefUpdate>();

            foreach (RemoteRefUpdate u in refUpdates.Values)
            {
                string n = u.RemoteName;
                if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
                {
                    u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = "funny refname";
                    continue;
                }

                if (AnyObjectId.equals(ObjectId.ZeroId, u.NewObjectId))
                {
                    DeleteCommand(u);
                }
                else
                {
                    updates.Add(u);
                }
            }

            // If we have any updates we need to upload the objects first, to
            // prevent creating refs pointing at non-existent data. Then we
            // can update the refs, and the info-refs file for dumb transports.
            //
            if (!updates.isEmpty())
            {
                Sendpack(updates, monitor);
            }
            foreach (RemoteRefUpdate u in updates)
            {
                UpdateCommand(u);
            }

            // Is this a new repository? If so we should create additional
            // metadata files so it is properly initialized during the push.
            //
            if (!updates.isEmpty() && IsNewRepository)
            {
                CreateNewRepository(updates);
            }

            RefWriter refWriter = new PushRefWriter(_newRefs.Values, _dest);

            if (_packedRefUpdates.Count > 0)
            {
                try
                {
                    refWriter.writePackedRefs();
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.OK;
                    }
                }
                catch (IOException e)
                {
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                        u.Message = e.Message;
                    }
                    throw new TransportException(_uri, "failed updating refs", e);
                }
            }

            try
            {
                refWriter.writeInfoRefs();
            }
            catch (IOException err)
            {
                throw new TransportException(_uri, "failed updating refs", err);
            }
        }
        public void Push(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate> refUpdates)
        {
            markStartedOperation();
            _packNames = null;
            _newRefs = new Dictionary<string, Ref>();
            _packedRefUpdates = new List<RemoteRefUpdate>();

            var updates = new List<RemoteRefUpdate>();
            foreach (RemoteRefUpdate u in refUpdates.Values)
            {
                string n = u.RemoteName;
                if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
                {
                    u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = "funny refname";
                    continue;
                }

                if (ObjectId.ZeroId.Equals(u.NewObjectId))
                {
                    DeleteCommand(u);
                }
                else
                {
                    updates.Add(u);
                }
            }

            if (updates.Count > 0)
            {
                Sendpack(updates, monitor);
            }
            foreach (RemoteRefUpdate u in updates)
            {
                UpdateCommand(u);
            }

            if (updates.Count > 0 && IsNewRepository)
            {
                CreateNewRepository(updates);
            }

            RefWriter refWriter = new PushRefWriter(_newRefs.Values, _dest);
            if (_packedRefUpdates.Count > 0)
            {
                try
                {
                    refWriter.writePackedRefs();
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.OK;
                    }
                }
                catch (IOException e)
                {
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                        u.Message = e.Message;
                    }
                    throw new TransportException(_uri, "failed updating refs", e);
                }
            }

            try
            {
                refWriter.writeInfoRefs();
            }
            catch (IOException err)
            {
                throw new TransportException(_uri, "failed updating refs", err);
            }
        }
        public void Push(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate> refUpdates)
        {
            if (refUpdates == null)
                throw new ArgumentNullException("refUpdates");

            markStartedOperation();
            _packNames = null;
            _newRefs = new Dictionary<string, Ref>(RefsMap);
            _packedRefUpdates = new List<RemoteRefUpdate>(refUpdates.Count);

            // Filter the commands and issue all deletes first. This way we
            // can correctly handle a directory being cleared out and a new
            // ref using the directory name being created.
            //
            var updates = new List<RemoteRefUpdate>();
            foreach (RemoteRefUpdate u in refUpdates.Values)
            {
                string n = u.RemoteName;
                if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
                {
                    u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = "funny refname";
                    continue;
                }

                if (AnyObjectId.equals(ObjectId.ZeroId, u.NewObjectId))
                {
                    DeleteCommand(u);
                }
                else
                {
                    updates.Add(u);
                }
            }

            // If we have any updates we need to upload the objects first, to
            // prevent creating refs pointing at non-existent data. Then we
            // can update the refs, and the info-refs file for dumb transports.
            //
            if (!updates.isEmpty())
            {
                Sendpack(updates, monitor);
            }
            foreach (RemoteRefUpdate u in updates)
            {
                UpdateCommand(u);
            }

            // Is this a new repository? If so we should create additional
            // metadata files so it is properly initialized during the push.
            //
            if (!updates.isEmpty() && IsNewRepository)
            {
                CreateNewRepository(updates);
            }

            RefWriter refWriter = new PushRefWriter(_newRefs.Values, _dest);
            if (_packedRefUpdates.Count > 0)
            {
                try
                {
                    refWriter.writePackedRefs();
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.OK;
                    }
                }
                catch (IOException e)
                {
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                        u.Message = e.Message;
                    }
                    throw new TransportException(_uri, "failed updating refs", e);
                }
            }

            try
            {
                refWriter.writeInfoRefs();
            }
            catch (IOException err)
            {
                throw new TransportException(_uri, "failed updating refs", err);
            }
        }
Beispiel #4
0
        public void Push(ProgressMonitor monitor, IDictionary <string, RemoteRefUpdate> refUpdates)
        {
            markStartedOperation();
            _packNames        = null;
            _newRefs          = new Dictionary <string, Ref>();
            _packedRefUpdates = new List <RemoteRefUpdate>();

            var updates = new List <RemoteRefUpdate>();

            foreach (RemoteRefUpdate u in refUpdates.Values)
            {
                string n = u.RemoteName;
                if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
                {
                    u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = "funny refname";
                    continue;
                }

                if (ObjectId.ZeroId.Equals(u.NewObjectId))
                {
                    DeleteCommand(u);
                }
                else
                {
                    updates.Add(u);
                }
            }

            if (updates.Count > 0)
            {
                Sendpack(updates, monitor);
            }
            foreach (RemoteRefUpdate u in updates)
            {
                UpdateCommand(u);
            }

            if (updates.Count > 0 && IsNewRepository)
            {
                CreateNewRepository(updates);
            }

            RefWriter refWriter = new PushRefWriter(_newRefs.Values, _dest);

            if (_packedRefUpdates.Count > 0)
            {
                try
                {
                    refWriter.writePackedRefs();
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status = RemoteRefUpdate.UpdateStatus.OK;
                    }
                }
                catch (IOException e)
                {
                    foreach (RemoteRefUpdate u in _packedRefUpdates)
                    {
                        u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                        u.Message = e.Message;
                    }
                    throw new TransportException(_uri, "failed updating refs", e);
                }
            }

            try
            {
                refWriter.writeInfoRefs();
            }
            catch (IOException err)
            {
                throw new TransportException(_uri, "failed updating refs", err);
            }
        }