public virtual void TestMultiRename()
        {
            string    contents = "A";
            RevCommit a        = Commit(Tree(File("a", Blob(contents))));

            // rename a to b
            NGit.Junit.CommitBuilder commitBuilder = CommitBuilder().Parent(a).Add("b", Blob
                                                                                       (contents)).Rm("a");
            RevCommit renameCommit1 = commitBuilder.Create();

            // rename b to c
            commitBuilder = CommitBuilder().Parent(renameCommit1).Add("c", Blob(contents)).Rm
                                ("b");
            RevCommit renameCommit2 = commitBuilder.Create();

            // rename c to a
            commitBuilder = CommitBuilder().Parent(renameCommit2).Add("a", Blob(contents)).Rm
                                ("c");
            RevCommit renameCommit3 = commitBuilder.Create();

            Follow("a");
            MarkStart(renameCommit3);
            AssertCommit(renameCommit3, rw.Next());
            AssertCommit(renameCommit2, rw.Next());
            AssertCommit(renameCommit1, rw.Next());
            AssertCommit(a, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
            AssertRenames("c->a", "b->c", "a->b");
        }
Exemple #2
0
        public virtual void DeleteMergedBranch_historyNotPruned()
        {
            RevCommit parent = tr.Commit().Create();
            RevCommit b1Tip  = tr.Branch("b1").Commit().Parent(parent).Add("x", "x").Create();
            RevCommit b2Tip  = tr.Branch("b2").Commit().Parent(parent).Add("y", "y").Create();
            // merge b1Tip and b2Tip and update refs/heads/b1 to the merge commit
            Merger merger = ((ThreeWayMerger)MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.NewMerger(repo
                                                                                            ));

            merger.Merge(b1Tip, b2Tip);
            NGit.Junit.CommitBuilder cb = tr.Commit();
            cb.Parent(b1Tip).Parent(b2Tip);
            cb.SetTopLevelTree(merger.GetResultTreeId());
            RevCommit mergeCommit = cb.Create();
            RefUpdate u           = repo.UpdateRef("refs/heads/b1");

            u.SetNewObjectId(mergeCommit);
            u.Update();
            RefUpdate update = repo.UpdateRef("refs/heads/b2");

            update.SetForceUpdate(true);
            update.Delete();
            gc.SetExpireAgeMillis(0);
            gc.Prune(Collections.EmptySet <ObjectId>());
            NUnit.Framework.Assert.IsTrue(repo.HasObject(b2Tip));
        }
Exemple #3
0
        /// <exception cref="System.Exception"></exception>
        internal CommitBuilder(TestRepository _enclosing, CommitBuilder
                               prior)
        {
            this._enclosing = _enclosing;
            this.branch     = prior.branch;
            DirCacheBuilder b = this.tree.Builder();

            for (int i = 0; i < prior.tree.GetEntryCount(); i++)
            {
                b.Add(prior.tree.GetEntry(i));
            }
            b.Finish();
            this.parents.AddItem(prior.Create());
        }
        public virtual void TestSingleRename()
        {
            RevCommit a = Commit(Tree(File("a", Blob("A"))));

            // rename a to b
            NGit.Junit.CommitBuilder commitBuilder = CommitBuilder().Parent(a).Add("b", Blob
                                                                                       ("A")).Rm("a");
            RevCommit renameCommit = commitBuilder.Create();

            Follow("b");
            MarkStart(renameCommit);
            AssertCommit(renameCommit, rw.Next());
            AssertCommit(a, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
            AssertRenames("a->b");
        }
Exemple #5
0
			/// <exception cref="System.Exception"></exception>
			internal CommitBuilder(TestRepository _enclosing, CommitBuilder
				 prior)
			{
				this._enclosing = _enclosing;
				this.branch = prior.branch;
				DirCacheBuilder b = this.tree.Builder();
				for (int i = 0; i < prior.tree.GetEntryCount(); i++)
				{
					b.Add(prior.tree.GetEntry(i));
				}
				b.Finish();
				this.parents.AddItem(prior.Create());
			}
Exemple #6
0
			/// <summary>Forcefully update this branch to a particular commit.</summary>
			/// <remarks>Forcefully update this branch to a particular commit.</remarks>
			/// <param name="to">the commit to update to.</param>
			/// <returns>
			/// 
			/// <code>to</code>
			/// .
			/// </returns>
			/// <exception cref="System.Exception">System.Exception</exception>
			public virtual RevCommit Update(CommitBuilder to)
			{
				return this.Update(to.Create());
			}
Exemple #7
0
 /// <summary>Forcefully update this branch to a particular commit.</summary>
 /// <remarks>Forcefully update this branch to a particular commit.</remarks>
 /// <param name="to">the commit to update to.</param>
 /// <returns>
 ///
 /// <code>to</code>
 /// .
 /// </returns>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual RevCommit Update(CommitBuilder to)
 {
     return(this.Update(to.Create()));
 }