コード例 #1
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        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);
        }
コード例 #2
0
ファイル: RemoteRefUpdate.cs プロジェクト: kkl713/GitSharp
        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;
        }
コード例 #3
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        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);
            }
        }
コード例 #4
0
ファイル: RemoteRefUpdate.cs プロジェクト: jagregory/GitSharp
        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;
        }
コード例 #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);
            }
        }
コード例 #6
0
ファイル: RemoteRefUpdate.cs プロジェクト: kkl713/GitSharp
 protected internal void updateTrackingRef(RevWalk.RevWalk walk)
 {
     if (IsDelete)
     {
         TrackingRefUpdate.Delete(walk);
     }
     else
     {
         TrackingRefUpdate.Update(walk);
     }
 }
コード例 #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);
        }
コード例 #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 + "]";
        }
コード例 #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 + "]";
        }
コード例 #10
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
        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);
            }
        }
コード例 #11
0
ファイル: OperationResult.cs プロジェクト: kkl713/GitSharp
 public void Add(TrackingRefUpdate u)
 {
     updates.Add(u.LocalName, u);
 }
コード例 #12
0
ファイル: OperationResult.cs プロジェクト: georgeck/GitSharp
 public void Add(TrackingRefUpdate u)
 {
     updates.Add(u.LocalName, u);
 }
コード例 #13
0
ファイル: FetchProcess.cs プロジェクト: dev218/GitSharp
        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);
            }
        }
コード例 #14
0
 public void Add(TrackingRefUpdate u)
 {
     _updates.put(u.LocalName, u);
 }
コード例 #15
0
ファイル: OperationResult.cs プロジェクト: dev218/GitSharp
 public void Add(TrackingRefUpdate u)
 {
     _updates.put(u.LocalName, u);
 }