Example #1
0
        private void want(Ref src, RefSpec spec)
        {
            ObjectId newId = src.ObjectId;

            if (spec.Destination != null)
            {
                try
                {
                    TrackingRefUpdate tru = createUpdate(spec, newId);
                    if (newId.Equals(tru.OldObjectId))
                    {
                        return;
                    }
                    _localUpdates.Add(tru);
                }
                catch (System.IO.IOException err)
                {
                    // Bad symbolic ref? That is the most likely cause.
                    throw new TransportException("Cannot resolve" + " local tracking ref " + spec.Destination + " for updating.", err);
                }
            }

            _askFor.Add(newId, src);

            FetchHeadRecord fhr = new FetchHeadRecord(newId, spec.Destination != null, src.Name, _transport.Uri);

            _fetchHeadUpdates.Add(fhr);
        }
Example #2
0
        public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
        {
            if (remoteName == null)
            {
                throw new ArgumentException("Remote name can't be null.");
            }

            SourceRef   = srcRef;
            NewObjectId = (srcRef == null ? ObjectId.ZeroId : localDb.Resolve(srcRef));
            if (NewObjectId == null)
            {
                throw new IOException("Source ref " + srcRef + " doesn't resolve to any object.");
            }
            RemoteName  = remoteName;
            ForceUpdate = forceUpdate;
            if (localName != null && localDb != null)
            {
                TrackingRefUpdate = new TrackingRefUpdate(localDb, localName, remoteName, true, NewObjectId, "push");
            }
            else
            {
                TrackingRefUpdate = null;
            }
            this._localDb       = localDb;
            ExpectedOldObjectId = expectedOldObjectId;
            Status = UpdateStatus.NOT_ATTEMPTED;
        }
Example #3
0
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;

            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                case RefUpdate.RefUpdateResult.New:
                case RefUpdate.RefUpdateResult.NoChange:
                case RefUpdate.RefUpdateResult.FastForward:
                case RefUpdate.RefUpdateResult.Forced:
                    break;

                default:
                    throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + u.Result.ToString());
                }
            }
            catch (System.IO.IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
Example #4
0
        public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
        {
            if (remoteName == null)
                throw new ArgumentException("Remote name can't be null.");

            SourceRef = srcRef;
            NewObjectId = (srcRef == null ? ObjectId.ZeroId : localDb.Resolve(srcRef));
            if (NewObjectId == null)
            {
                throw new IOException("Source ref " + srcRef + " doesn't resolve to any object.");
            }
            RemoteName = remoteName;
            ForceUpdate = forceUpdate;
            if (localName != null && localDb != null)
            {
                TrackingRefUpdate = new TrackingRefUpdate(localDb, localName, remoteName, true, NewObjectId, "push");
            }
            else
            {
                TrackingRefUpdate = null;
            }
            this._localDb = localDb;
            ExpectedOldObjectId = expectedOldObjectId;
            Status = UpdateStatus.NOT_ATTEMPTED;
        }
Example #5
0
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;

            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                case RefUpdate.RefUpdateResult.NEW:
                case RefUpdate.RefUpdateResult.NO_CHANGE:
                case RefUpdate.RefUpdateResult.FAST_FORWARD:
                case RefUpdate.RefUpdateResult.FORCED:
                    break;

                default:
                    throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + Enum.GetName(typeof(RefUpdate.RefUpdateResult), u.Result));
                }
            }
            catch (IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
Example #6
0
 protected internal void updateTrackingRef(RevWalk.RevWalk walk)
 {
     if (IsDelete)
     {
         TrackingRefUpdate.Delete(walk);
     }
     else
     {
         TrackingRefUpdate.Update(walk);
     }
 }
Example #7
0
        private PushResult PrepareOperationResult()
        {
            var result = new PushResult();

            result.SetAdvertisedRefs(_transport.Uri, _connection.RefsMap);
            result.SetRemoteUpdates(_toPush);

            foreach (RemoteRefUpdate rru in _toPush.Values)
            {
                TrackingRefUpdate tru = rru.TrackingRefUpdate;
                if (tru != null)
                {
                    result.Add(tru);
                }
            }
            return(result);
        }
Example #8
0
        private string longTypeOf(TrackingRefUpdate u)
        {
            RefUpdate.RefUpdateResult r = u.Result;
            if (r == RefUpdate.RefUpdateResult.LOCK_FAILURE)
                return "[lock fail]";
            if (r == RefUpdate.RefUpdateResult.IO_FAILURE)
                return "[i/o error]";
            if (r == RefUpdate.RefUpdateResult.REJECTED)
                return "[rejected]";
            if (ObjectId.ZeroId.Equals(u.NewObjectId))
                return "[deleted]";

            if (r == RefUpdate.RefUpdateResult.NEW)
            {
                if (u.RemoteName.StartsWith(Constants.R_HEADS))
                    return "[new branch]";
                if (u.LocalName.StartsWith(Constants.R_TAGS))
                    return "[new tag]";
                return "[new]";
            }

            if (r == RefUpdate.RefUpdateResult.FORCED)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository).name();
                string aNew = u.NewObjectId.Abbreviate(Repository).name();
                return aOld + "..." + aNew;
            }

            if (r == RefUpdate.RefUpdateResult.FAST_FORWARD)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository).name();
                string aNew = u.NewObjectId.Abbreviate(Repository).name();
                return aOld + ".." + aNew;
            }

            if (r == RefUpdate.RefUpdateResult.NO_CHANGE)
                return "[up to date]";

            return "[" + r + "]";
        }
Example #9
0
        private string longTypeOf(TrackingRefUpdate u)
        {
            RefUpdate.RefUpdateResult r = u.Result;
            if (r == RefUpdate.RefUpdateResult.LockFailure)
                return "[lock fail]";
            if (r == RefUpdate.RefUpdateResult.IOFailure)
                return "[i/o error]";
            if (r == RefUpdate.RefUpdateResult.Rejected)
                return "[rejected]";
            if (ObjectId.ZeroId.Equals(u.NewObjectId))
                return "[deleted]";

            if (r == RefUpdate.RefUpdateResult.New)
            {
                if (u.RemoteName.StartsWith(Constants.R_HEADS))
                    return "[new branch]";
                if (u.LocalName.StartsWith(Constants.R_TAGS))
                    return "[new tag]";
                return "[new]";
            }

            if (r == RefUpdate.RefUpdateResult.Forced)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository._internal_repo).name();
                string aNew = u.NewObjectId.Abbreviate(Repository._internal_repo).name();
                return aOld + "..." + aNew;
            }

            if (r == RefUpdate.RefUpdateResult.FastForward)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository._internal_repo).name();
                string aNew = u.NewObjectId.Abbreviate(Repository._internal_repo).name();
                return aOld + ".." + aNew;
            }

            if (r == RefUpdate.RefUpdateResult.NoChange)
                return "[up to date]";

            return "[" + r + "]";
        }
Example #10
0
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;
            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                    case RefUpdate.RefUpdateResult.New:
                    case RefUpdate.RefUpdateResult.NoChange:
                    case RefUpdate.RefUpdateResult.FastForward:
                    case RefUpdate.RefUpdateResult.Forced:
                        break;

                    default:
                        throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + u.Result.ToString());
                }
            }
            catch (System.IO.IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
Example #11
0
 public void Add(TrackingRefUpdate u)
 {
     updates.Add(u.LocalName, u);
 }
Example #12
0
 public void Add(TrackingRefUpdate u)
 {
     updates.Add(u.LocalName, u);
 }
Example #13
0
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;
            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                    case RefUpdate.RefUpdateResult.NEW:
                    case RefUpdate.RefUpdateResult.NO_CHANGE:
                    case RefUpdate.RefUpdateResult.FAST_FORWARD:
                    case RefUpdate.RefUpdateResult.FORCED:
                        break;

                    default:
                        throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + Enum.GetName(typeof(RefUpdate.RefUpdateResult), u.Result));
                }
            }
            catch (IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
Example #14
0
 public void Add(TrackingRefUpdate u)
 {
     _updates.put(u.LocalName, u);
 }
Example #15
0
 public void Add(TrackingRefUpdate u)
 {
     _updates.put(u.LocalName, u);
 }