Example #1
0
        internal StashedState(Repository repository, int index, Revision revision)
            : base(repository, index.ToString().SurroundWith(GitConstants.StashName + "@{", "}"))
        {
            Verify.Argument.IsNotNull(revision, "revision");
            Verify.Argument.IsNotNegative(index, "index");

            _revision = revision;
        }
Example #2
0
        /// <summary>Initializes a new instance of the <see cref="ReflogRecord"/> class.</summary>
        /// <param name="repository">Host repository.</param>
        /// <param name="reflog">Owner reflog.</param>
        /// <param name="revision">Target revision.</param>
        /// <param name="message">Reflog record message.</param>
        /// <param name="index">Reflog record index.</param>
        internal ReflogRecord(Repository repository, Reflog reflog, Revision revision, string message, int index)
            : base(repository)
        {
            Verify.Argument.IsNotNull(reflog, "reflog");
            Verify.Argument.IsNotNull(revision, "revision");
            Verify.Argument.IsNotNull(message, "message");
            Verify.Argument.IsNotNegative(index, "index");

            _reflog = reflog;
            _revision = revision;
            _message = message;
            _index = index;
        }
Example #3
0
        public IList<Revision> GetParents(Revision revision)
        {
            Verify.Argument.IsNotNull(revision, "revision");

            if(_parents == null)
            {
                return revision.Parents;
            }
            else
            {
                IList<Revision> parents;
                if(_parents.TryGetValue(revision, out parents))
                {
                    return parents;
                }
                else
                {
                    return new Revision[0];
                }
            }
        }
Example #4
0
 public virtual Revision Dereference()
 {
     if(_revision == null)
     {
         var rev = Repository.Accessor.Dereference.Invoke(
             new DereferenceParameters(Pointer));
         lock(Repository.Revisions.SyncRoot)
         {
             _revision = Repository.Revisions.GetOrCreateRevision(rev.SHA1);
         }
     }
     return _revision;
 }
Example #5
0
 public static void UpdateRevision(Revision obj, RevisionData revisionData)
 {
     UpdateRevision(obj, revisionData, true);
 }
Example #6
0
        public static void UpdateRevision(Revision revision, RevisionData revisionData, bool updateParents)
        {
            Verify.Argument.IsNotNull(revision, "revision");
            Verify.Argument.IsNotNull(revisionData, "revisionData");

            var fields = revisionData.Fields;
            if(fields != RevisionField.SHA1)
            {
                var repository = revision.Repository;
                if((fields & RevisionField.Subject) == RevisionField.Subject)
                {
                    revision.Subject = revisionData.Subject;
                }
                if((fields & RevisionField.Body) == RevisionField.Body)
                {
                    revision.Body = revisionData.Body;
                }
                if((fields & RevisionField.TreeHash) == RevisionField.TreeHash)
                {
                    revision.TreeHash = revisionData.TreeHash;
                }
                if(updateParents && ((fields & RevisionField.Parents) == RevisionField.Parents))
                {
                    HashSet<Revision> hset = null;
                    if(revision.Parents.Count != 0)
                    {
                        hset = new HashSet<Revision>(revision.Parents);
                    }
                    int id = 0;
                    foreach(var info in revisionData.Parents)
                    {
                        bool found = false;
                        for(int i = id; i < revision.Parents.Count; ++i)
                        {
                            if(revision.Parents[i].Hash == info.SHA1)
                            {
                                if(i != id)
                                {
                                    var temp = revision.Parents[i];
                                    revision.Parents[i] = revision.Parents[id];
                                    revision.Parents[id] = temp;
                                }
                                if(hset != null)
                                {
                                    hset.Remove(revision.Parents[id]);
                                }
                                found = true;
                                break;
                            }
                        }
                        if(!found)
                        {
                            var obj = CreateRevision(repository, info);
                            revision.Parents.InsertInternal(id, obj);
                        }
                        ++id;
                    }
                    if(hset != null && hset.Count != 0)
                    {
                        foreach(var obj in hset)
                        {
                            revision.Parents.RemoveInternal(obj);
                        }
                    }
                }
                if((fields & RevisionField.CommitDate) == RevisionField.CommitDate)
                {
                    revision.CommitDate = revisionData.CommitDate;
                }
                if((fields & (RevisionField.CommitterName | RevisionField.CommitterEmail)) ==
                    (RevisionField.CommitterName | RevisionField.CommitterEmail))
                {
                    revision.Committer = repository.Users.GetOrCreateUser(
                        revisionData.CommitterName, revisionData.CommitterEmail);
                }
                if((fields & RevisionField.AuthorDate) == RevisionField.AuthorDate)
                {
                    revision.AuthorDate = revisionData.AuthorDate;
                }
                if((fields & (RevisionField.AuthorName | RevisionField.AuthorEmail)) ==
                    (RevisionField.AuthorName | RevisionField.AuthorEmail))
                {
                    revision.Author = repository.Users.GetOrCreateUser(
                        revisionData.AuthorName, revisionData.AuthorEmail);
                }

                revision.IsLoaded = true;
            }
        }
Example #7
0
 /// <summary>Called when this <see cref="Reference"/> is moved away from <paramref name="revision"/>.</summary>
 /// <param name="pointer"><see cref="Revision"/>, which this <see cref="Reference"/> was pointing to.</param>
 protected virtual void LeaveRevision(Revision revision)
 {
     revision.References.Remove(this);
 }
Example #8
0
 /// <summary>Invoke <see cref="PositionChanged"/>.</summary>
 protected void InvokePositionChanged(Revision oldPos, Revision newPos)
 {
     var handler = PositionChanged;
     if(handler != null) handler(this, new RevisionChangedEventArgs(oldPos, newPos));
 }
Example #9
0
 /// <summary>Called when this <see cref="Reference"/> is moved to <paramref name="Revision"/>.</summary>
 /// <param name="pointer"><see cref="Revision"/>, which this <see cref="Reference"/> will be pointing to.</param>
 protected virtual void EnterRevision(Revision revision)
 {
     revision.References.Add(this);
 }
Example #10
0
 internal void OnCommitCreated(Revision revision)
 {
     var handler = CommitCreated;
     if(handler != null) handler(this, new RevisionEventArgs(revision));
 }