public virtual void TestWrite1()
        {
            byte[] bundle;
            // Create a small bundle, an early commit
            bundle = MakeBundle("refs/heads/aa", db.Resolve("a").Name, null);
            // Then we clone a new repo from that bundle and do a simple test. This
            // makes sure
            // we could read the bundle we created.
            Repository  newRepo       = CreateBareRepository();
            FetchResult fetchResult   = FetchFromBundle(newRepo, bundle);
            Ref         advertisedRef = fetchResult.GetAdvertisedRef("refs/heads/aa");

            NUnit.Framework.Assert.AreEqual(db.Resolve("a").Name, advertisedRef.GetObjectId()
                                            .Name);
            NUnit.Framework.Assert.AreEqual(db.Resolve("a").Name, newRepo.Resolve("refs/heads/aa"
                                                                                  ).Name);
            NUnit.Framework.Assert.IsNull(newRepo.Resolve("refs/heads/a"));
            // Next an incremental bundle
            bundle = MakeBundle("refs/heads/cc", db.Resolve("c").Name, new RevWalk(db).ParseCommit
                                    (db.Resolve("a").ToObjectId()));
            fetchResult   = FetchFromBundle(newRepo, bundle);
            advertisedRef = fetchResult.GetAdvertisedRef("refs/heads/cc");
            NUnit.Framework.Assert.AreEqual(db.Resolve("c").Name, advertisedRef.GetObjectId()
                                            .Name);
            NUnit.Framework.Assert.AreEqual(db.Resolve("c").Name, newRepo.Resolve("refs/heads/cc"
                                                                                  ).Name);
            NUnit.Framework.Assert.IsNull(newRepo.Resolve("refs/heads/c"));
            NUnit.Framework.Assert.IsNull(newRepo.Resolve("refs/heads/a"));
            // still unknown
            try
            {
                // Check that we actually needed the first bundle
                Repository newRepo2 = CreateBareRepository();
                fetchResult = FetchFromBundle(newRepo2, bundle);
                NUnit.Framework.Assert.Fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled"
                                            );
            }
            catch (MissingBundlePrerequisiteException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.IndexOf(db.Resolve("refs/heads/a").Name)
                                              >= 0);
            }
        }
示例#2
0
 /// <exception cref="System.IO.IOException"></exception>
 private void DeleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch)
 {
     foreach (Ref @ref in LocalRefs().Values)
     {
         string refname = @ref.GetName();
         foreach (RefSpec spec in toFetch)
         {
             if (spec.MatchDestination(refname))
             {
                 RefSpec s = spec.ExpandFromDestination(refname);
                 if (result.GetAdvertisedRef(s.GetSource()) == null)
                 {
                     DeleteTrackingRef(result, batch, s, @ref);
                 }
             }
         }
     }
 }
        public virtual void TestWrite0()
        {
            // Create a tiny bundle, (well one of) the first commits only
            byte[] bundle = MakeBundle("refs/heads/firstcommit", "42e4e7c5e507e113ebbb7801b16b52cf867b7ce1"
                                       , null);
            // Then we clone a new repo from that bundle and do a simple test. This
            // makes sure
            // we could read the bundle we created.
            Repository  newRepo       = CreateBareRepository();
            FetchResult fetchResult   = FetchFromBundle(newRepo, bundle);
            Ref         advertisedRef = fetchResult.GetAdvertisedRef("refs/heads/firstcommit");

            // We expect firstcommit to appear by id
            NUnit.Framework.Assert.AreEqual("42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", advertisedRef
                                            .GetObjectId().Name);
            // ..and by name as the bundle created a new ref
            NUnit.Framework.Assert.AreEqual("42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", newRepo
                                            .Resolve("refs/heads/firstcommit").Name);
        }
示例#4
0
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private void DeleteStaleTrackingRefs(FetchResult result, RevWalk walk)
        {
            Repository db = transport.local;

            foreach (Ref @ref in db.GetAllRefs().Values)
            {
                string refname = @ref.GetName();
                foreach (RefSpec spec in toFetch)
                {
                    if (spec.MatchDestination(refname))
                    {
                        RefSpec s = spec.ExpandFromDestination(refname);
                        if (result.GetAdvertisedRef(s.GetSource()) == null)
                        {
                            DeleteTrackingRef(result, db, walk, s, @ref);
                        }
                    }
                }
            }
        }
示例#5
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 private void DeleteStaleTrackingRefs(FetchResult result, RevWalk walk)
 {
     Repository db = transport.local;
     foreach (Ref @ref in db.GetAllRefs().Values)
     {
         string refname = @ref.GetName();
         foreach (RefSpec spec in toFetch)
         {
             if (spec.MatchDestination(refname))
             {
                 RefSpec s = spec.ExpandFromDestination(refname);
                 if (result.GetAdvertisedRef(s.GetSource()) == null)
                 {
                     DeleteTrackingRef(result, db, walk, s, @ref);
                 }
             }
         }
     }
 }
示例#6
0
		/// <exception cref="System.IO.IOException"></exception>
		private void DeleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch)
		{
			foreach (Ref @ref in LocalRefs().Values)
			{
				string refname = @ref.GetName();
				foreach (RefSpec spec in toFetch)
				{
					if (spec.MatchDestination(refname))
					{
						RefSpec s = spec.ExpandFromDestination(refname);
						if (result.GetAdvertisedRef(s.GetSource()) == null)
						{
							DeleteTrackingRef(result, batch, s, @ref);
						}
					}
				}
			}
		}