Exemple #1
0
 public ReferencesData(IList<BranchData> heads, IList<BranchData> remotes, IList<TagData> tags, RevisionData stash)
 {
     _heads = heads;
     _remotes = remotes;
     _tags = tags;
     _stash = stash;
 }
Exemple #2
0
 public ReferencesData(IList <BranchData> heads, IList <BranchData> remotes, IList <TagData> tags, RevisionData stash)
 {
     Heads   = heads;
     Remotes = remotes;
     Tags    = tags;
     Stash   = stash;
 }
 public StashedStateData(int index, RevisionData revision)
 {
     Index    = index;
     Revision = revision;
 }
Exemple #4
0
 public ReflogRecordData(int index, string message, RevisionData revision)
 {
     Index    = index;
     Message  = message;
     Revision = revision;
 }
Exemple #5
0
 public static void UpdateRevision(Revision obj, RevisionData revisionData)
 {
     UpdateRevision(obj, revisionData, true);
 }
Exemple #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;
            }
        }
Exemple #7
0
        public static Revision CreateRevision(Repository repository, RevisionData revisionData)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(revisionData, "revisionData");

            var revisions = repository.Revisions;
            var revision  = revisions.GetOrCreateRevision(revisionData.SHA1);
            var fields    = revisionData.Fields;
            if(!revision.IsLoaded && (fields != RevisionField.SHA1))
            {
                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((fields & RevisionField.Parents) == RevisionField.Parents)
                {
                    foreach(var parentData in revisionData.Parents)
                    {
                        var parent = revisions.GetOrCreateRevision(parentData.SHA1);
                        revision.Parents.AddInternal(parent);
                    }
                }
                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;
            }
            return revision;
        }
Exemple #8
0
 public ReflogRecordData(int index, string message, RevisionData revision)
 {
     _index = index;
     _message = message;
     _revision = revision;
 }
Exemple #9
0
 public StashedStateData(int index, RevisionData revision)
 {
     _index = index;
     _revision = revision;
 }