Exemple #1
0
        /// <summary>
        /// Objects known to exist but not expressed by
        /// <see cref="NGit.Repository.GetAllRefs()">NGit.Repository.GetAllRefs()</see>
        /// .
        /// <p>
        /// When a repository borrows objects from another repository, it can
        /// advertise that it safely has that other repository's references, without
        /// exposing any other details about the other repository.  This may help
        /// a client trying to push changes avoid pushing more than it needs to.
        /// </summary>
        /// <returns>unmodifiable collection of other known objects.</returns>
        public override ICollection <ObjectId> GetAdditionalHaves()
        {
            HashSet <ObjectId> r = new HashSet <ObjectId>();

            foreach (FileObjectDatabase.AlternateHandle d in objectDatabase.MyAlternates())
            {
                if (d is FileObjectDatabase.AlternateRepository)
                {
                    Repository repo;
                    repo = ((FileObjectDatabase.AlternateRepository)d).repository;
                    foreach (Ref @ref in repo.GetAllRefs().Values)
                    {
                        if (@ref.GetObjectId() != null)
                        {
                            r.AddItem(@ref.GetObjectId());
                        }
                        if (@ref.GetPeeledObjectId() != null)
                        {
                            r.AddItem(@ref.GetPeeledObjectId());
                        }
                    }
                    Sharpen.Collections.AddAll(r, repo.GetAdditionalHaves());
                }
            }
            return(r);
        }
Exemple #2
0
 internal override FileObjectDatabase.AlternateHandle[] MyAlternates()
 {
     if (alts == null)
     {
         FileObjectDatabase.AlternateHandle[] src = wrapped.MyAlternates();
         alts = new FileObjectDatabase.AlternateHandle[src.Length];
         for (int i = 0; i < alts.Length; i++)
         {
             FileObjectDatabase s = src[i].db;
             alts[i] = new FileObjectDatabase.AlternateHandle(s.NewCachedFileObjectDatabase());
         }
     }
     return(alts);
 }