public virtual void TestCull() { RevBlob f1 = Blob("1"); RevBlob f2 = Blob("2"); RevBlob f3 = Blob("3"); RevBlob f4 = Blob("4"); RevTree ta = Tree(File("a/1", f1), File("c/3", f3)); RevCommit a = Commit(ta); RevTree tb = Tree(File("a/1", f2), File("c/3", f3)); RevCommit b1 = Commit(tb, a); RevCommit b2 = Commit(tb, b1); RevTree tc = Tree(File("a/1", f4)); RevCommit c1 = Commit(tc, a); RevCommit c2 = Commit(tc, c1); MarkStart(b2); MarkUninteresting(c2); AssertCommit(b2, objw.Next()); AssertCommit(b1, objw.Next()); NUnit.Framework.Assert.IsNull(objw.Next()); NUnit.Framework.Assert.IsTrue(a.Has(RevFlag.UNINTERESTING)); NUnit.Framework.Assert.IsTrue(ta.Has(RevFlag.UNINTERESTING)); NUnit.Framework.Assert.IsTrue(f1.Has(RevFlag.UNINTERESTING)); NUnit.Framework.Assert.IsTrue(f3.Has(RevFlag.UNINTERESTING)); NUnit.Framework.Assert.AreSame(tb, objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(tb, "a"), objw.NextObject()); NUnit.Framework.Assert.AreSame(f2, objw.NextObject()); NUnit.Framework.Assert.IsNull(objw.NextObject()); }
public override void SetUp() { base.SetUp(); // Test graph was stolen from git-core t6012-rev-list-simplify // (by Junio C Hamano in 65347030590bcc251a9ff2ed96487a0f1b9e9fa8) // RevBlob zF = Blob("zF"); RevBlob zH = Blob("zH"); RevBlob zI = Blob("zI"); RevBlob zS = Blob("zS"); RevBlob zY = Blob("zY"); a = Commit(Tree(File(pF, zH))); b = Commit(Tree(File(pF, zI)), a); c = Commit(Tree(File(pF, zI)), a); d = Commit(Tree(File(pA, zS), File(pF, zI)), c); ParseBody(d); e = Commit(d.Tree, d, b); f = Commit(Tree(File(pA, zS), File(pE, zY), File(pF, zI)), e); ParseBody(f); g = Commit(Tree(File(pE, zY), File(pF, zI)), b); h = Commit(f.Tree, g, f); i = Commit(Tree(File(pA, zS), File(pE, zY), File(pF, zF)), h); byName = new Dictionary <RevCommit, string>(); foreach (FieldInfo z in Sharpen.Runtime.GetDeclaredFields(typeof(RevWalkPathFilter6012Test ))) { if (z.FieldType == typeof(RevCommit)) { byName.Put((RevCommit)z.GetValue(this), z.Name); } } }
public override void SetUp() { base.SetUp(); tr = new TestRepository<Repository>(db); reader = db.NewObjectReader(); inserter = db.NewObjectInserter(); merger = new DefaultNoteMerger(); noteOn = tr.Blob("a"); baseNote = NewNote("data"); }
public virtual void TestOneCommitOneTreeTwoBlob() { RevBlob f0 = Blob("0"); RevBlob f1 = Blob("1"); RevTree t = Tree(File("0", f0), File("1", f1), File("2", f1)); RevCommit a = Commit(t); MarkStart(a); AssertCommit(a, objw.Next()); NUnit.Framework.Assert.IsNull(objw.Next()); NUnit.Framework.Assert.AreSame(t, objw.NextObject()); NUnit.Framework.Assert.AreSame(f0, objw.NextObject()); NUnit.Framework.Assert.AreSame(f1, objw.NextObject()); NUnit.Framework.Assert.IsNull(objw.NextObject()); }
public virtual void TestTwoCommitTwoTreeTwoBlob() { RevBlob f0 = Blob("0"); RevBlob f1 = Blob("1"); RevBlob f2 = Blob("0v2"); RevTree ta = Tree(File("0", f0), File("1", f1), File("2", f1)); RevTree tb = Tree(File("0", f2), File("1", f1), File("2", f1)); RevCommit a = Commit(ta); RevCommit b = Commit(tb, a); MarkStart(b); AssertCommit(b, objw.Next()); AssertCommit(a, objw.Next()); NUnit.Framework.Assert.IsNull(objw.Next()); NUnit.Framework.Assert.AreSame(tb, objw.NextObject()); NUnit.Framework.Assert.AreSame(f2, objw.NextObject()); NUnit.Framework.Assert.AreSame(f1, objw.NextObject()); NUnit.Framework.Assert.AreSame(ta, objw.NextObject()); NUnit.Framework.Assert.AreSame(f0, objw.NextObject()); NUnit.Framework.Assert.IsNull(objw.NextObject()); }
public virtual void TestTwoCommitDeepTree2() { RevBlob f1 = Blob("1"); RevTree ta = Tree(File("a/b/0", f1), File("a/c/q", f1)); RevTree tb = Tree(File("a/b/1", f1), File("a/c/q", f1)); RevCommit a = Commit(ta); RevCommit b = Commit(tb, a); MarkStart(b); AssertCommit(b, objw.Next()); AssertCommit(a, objw.Next()); NUnit.Framework.Assert.IsNull(objw.Next()); NUnit.Framework.Assert.AreSame(tb, objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(tb, "a"), objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(tb, "a/b"), objw.NextObject()); NUnit.Framework.Assert.AreSame(f1, objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(tb, "a/c"), objw.NextObject()); NUnit.Framework.Assert.AreSame(ta, objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(ta, "a"), objw.NextObject()); NUnit.Framework.Assert.AreSame(Get(ta, "a/b"), objw.NextObject()); NUnit.Framework.Assert.IsNull(objw.NextObject()); }
public _PathEdit_322(RevBlob gitmodulesBlob, string baseArg1) : base(baseArg1) { this.gitmodulesBlob = gitmodulesBlob; }
public override void SetUp() { base.SetUp(); src = CreateBareRepository(); dst = CreateBareRepository(); // Fill dst with a some common history. // TestRepository d = new TestRepository<Repository>(dst); a = d.Blob("a"); A = d.Commit(d.Tree(d.File("a", a))); B = d.Commit().Parent(A).Create(); d.Update(R_MASTER, B); // Clone from dst into src // NGit.Transport.Transport t = NGit.Transport.Transport.Open(src, UriOf(dst)); try { t.Fetch(PM, Collections.Singleton(new RefSpec("+refs/*:refs/*"))); NUnit.Framework.Assert.AreEqual(B, src.Resolve(R_MASTER)); } finally { t.Close(); } // Now put private stuff into dst. // b = d.Blob("b"); P = d.Commit(d.Tree(d.File("b", b)), A); d.Update(R_PRIVATE, P); }
/// <exception cref="System.Exception"></exception> protected internal virtual DirCacheEntry File(string path, RevBlob blob) { return(util.File(path, blob)); }
/// <summary>Pop the next most recent object.</summary> /// <remarks>Pop the next most recent object.</remarks> /// <returns>next most recent object; null if traversal is over.</returns> /// <exception cref="NGit.Errors.MissingObjectException"> /// one or or more of the next objects are not available from the /// object database, but were thought to be candidates for /// traversal. This usually indicates a broken link. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// one or or more of the objects in a tree do not match the type /// indicated. /// </exception> /// <exception cref="System.IO.IOException">a pack file or loose object could not be read. /// </exception> public virtual RevObject NextObject() { pathLen = 0; ObjectWalk.TreeVisit tv = currVisit; while (tv != null) { byte[] buf = tv.buf; for (int ptr = tv.ptr; ptr < buf.Length; ) { int startPtr = ptr; ptr = FindObjectId(buf, ptr); idBuffer.FromRaw(buf, ptr); ptr += ID_SZ; RevObject obj = objects.Get(idBuffer); if (obj != null && (obj.flags & SEEN) != 0) { continue; } int mode = ParseMode(buf, startPtr, ptr, tv); int flags; switch ((int)(((uint)mode) >> TYPE_SHIFT)) { case TYPE_FILE: case TYPE_SYMLINK: { if (obj == null) { obj = new RevBlob(idBuffer); obj.flags = SEEN; objects.Add(obj); return obj; } if (!(obj is RevBlob)) { throw new IncorrectObjectTypeException(obj, Constants.OBJ_BLOB); } obj.flags = flags = obj.flags | SEEN; if ((flags & UNINTERESTING) == 0) { return obj; } if (boundary) { return obj; } continue; goto case TYPE_TREE; } case TYPE_TREE: { if (obj == null) { obj = new RevTree(idBuffer); obj.flags = SEEN; objects.Add(obj); return EnterTree(obj); } if (!(obj is RevTree)) { throw new IncorrectObjectTypeException(obj, Constants.OBJ_TREE); } obj.flags = flags = obj.flags | SEEN; if ((flags & UNINTERESTING) == 0) { return EnterTree(obj); } if (boundary) { return EnterTree(obj); } continue; goto case TYPE_GITLINK; } case TYPE_GITLINK: { continue; goto default; } default: { throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3 , string.Format("%o", Sharpen.Extensions.ValueOf(mode)), idBuffer.Name, RawParseUtils .Decode(buf, tv.namePtr, tv.nameEnd), tv.obj)); } } } currVisit = tv.parent; ReleaseTreeVisit(tv); tv = currVisit; } for (; ; ) { RevObject o = pendingObjects.Next(); if (o == null) { reader.WalkAdviceEnd(); return null; } int flags = o.flags; if ((flags & SEEN) != 0) { continue; } flags |= SEEN; o.flags = flags; if ((flags & UNINTERESTING) == 0 | boundary) { if (o is RevTree) { tv = NewTreeVisit(o); tv.parent = null; currVisit = tv; } return o; } } }
/// <summary> /// Add a regular file, mode is /// <see cref="FileMode.REGULAR_FILE">FileMode.REGULAR_FILE</see> /// . /// </summary> /// <param name="name">name of the entry.</param> /// <param name="blob">the ObjectId to store in this entry.</param> public virtual void Append(string name, RevBlob blob) { Append(name, FileMode.REGULAR_FILE, blob); }
public _PathEdit_820(RevBlob id, string baseArg1) : base(baseArg1) { this.id = id; }
/// <exception cref="System.Exception"></exception> public virtual CommitBuilder Add(string path, RevBlob id) { return this.Edit(new _PathEdit_820(id, path)); }
public override void SetUp() { base.SetUp(); tr = new TestRepository<Repository>(db); reader = db.NewObjectReader(); inserter = db.NewObjectInserter(); noRoot = NoteMap.NewMap(null, reader); empty = NoteMap.NewEmptyMap(); noteAId = tr.Blob("a"); noteAContent = "noteAContent"; noteABlob = tr.Blob(noteAContent); sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create(); tr.ParseBody(sampleTree_a); map_a = NoteMap.Read(reader, sampleTree_a); noteBId = tr.Blob("b"); noteBContent = "noteBContent"; noteBBlob = tr.Blob(noteBContent); sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob ).Create(); tr.ParseBody(sampleTree_a_b); map_a_b = NoteMap.Read(reader, sampleTree_a_b); }
/// <summary>Pop the next most recent object.</summary> /// <remarks>Pop the next most recent object.</remarks> /// <returns>next most recent object; null if traversal is over.</returns> /// <exception cref="NGit.Errors.MissingObjectException"> /// one or or more of the next objects are not available from the /// object database, but were thought to be candidates for /// traversal. This usually indicates a broken link. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// one or or more of the objects in a tree do not match the type /// indicated. /// </exception> /// <exception cref="System.IO.IOException">a pack file or loose object could not be read. /// </exception> public virtual RevObject NextObject() { pathLen = 0; ObjectWalk.TreeVisit tv = currVisit; while (tv != null) { byte[] buf = tv.buf; for (int ptr = tv.ptr; ptr < buf.Length;) { int startPtr = ptr; ptr = FindObjectId(buf, ptr); idBuffer.FromRaw(buf, ptr); ptr += ID_SZ; RevObject obj = objects.Get(idBuffer); if (obj != null && (obj.flags & SEEN) != 0) { continue; } int mode = ParseMode(buf, startPtr, ptr, tv); int flags; switch ((int)(((uint)mode) >> TYPE_SHIFT)) { case TYPE_FILE: case TYPE_SYMLINK: { if (obj == null) { obj = new RevBlob(idBuffer); obj.flags = SEEN; objects.Add(obj); return(obj); } if (!(obj is RevBlob)) { throw new IncorrectObjectTypeException(obj, Constants.OBJ_BLOB); } obj.flags = flags = obj.flags | SEEN; if ((flags & UNINTERESTING) == 0) { return(obj); } if (boundary) { return(obj); } continue; goto case TYPE_TREE; } case TYPE_TREE: { if (obj == null) { obj = new RevTree(idBuffer); obj.flags = SEEN; objects.Add(obj); return(EnterTree(obj)); } if (!(obj is RevTree)) { throw new IncorrectObjectTypeException(obj, Constants.OBJ_TREE); } obj.flags = flags = obj.flags | SEEN; if ((flags & UNINTERESTING) == 0) { return(EnterTree(obj)); } if (boundary) { return(EnterTree(obj)); } continue; goto case TYPE_GITLINK; } case TYPE_GITLINK: { continue; goto default; } default: { throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3 , string.Format("%o", Sharpen.Extensions.ValueOf(mode)), idBuffer.Name, RawParseUtils .Decode(buf, tv.namePtr, tv.nameEnd), tv.obj)); } } } currVisit = tv.parent; ReleaseTreeVisit(tv); tv = currVisit; } for (; ;) { RevObject o = pendingObjects.Next(); if (o == null) { reader.WalkAdviceEnd(); return(null); } int flags = o.flags; if ((flags & SEEN) != 0) { continue; } flags |= SEEN; o.flags = flags; if ((flags & UNINTERESTING) == 0 | boundary) { if (o is RevTree) { tv = NewTreeVisit(o); tv.parent = null; currVisit = tv; } return(o); } } }
/// <summary>Pop the next most recent object.</summary> /// <remarks>Pop the next most recent object.</remarks> /// <returns>next most recent object; null if traversal is over.</returns> /// <exception cref="NGit.Errors.MissingObjectException"> /// one or or more of the next objects are not available from the /// object database, but were thought to be candidates for /// traversal. This usually indicates a broken link. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// one or or more of the objects in a tree do not match the type /// indicated. /// </exception> /// <exception cref="System.IO.IOException">a pack file or loose object could not be read. /// </exception> public virtual RevObject NextObject() { if (last != null) { treeWalk = last is RevTree?Enter(last) : treeWalk.Next(); } while (!treeWalk.Eof) { FileMode mode = treeWalk.EntryFileMode; switch (mode.GetObjectType()) { case Constants.OBJ_BLOB: { treeWalk.GetEntryObjectId(idBuffer); RevBlob o = LookupBlob(idBuffer); if ((o.flags & SEEN) != 0) { break; } o.flags |= SEEN; if (ShouldSkipObject(o)) { break; } last = o; return(o); } case Constants.OBJ_TREE: { treeWalk.GetEntryObjectId(idBuffer); RevTree o = LookupTree(idBuffer); if ((o.flags & SEEN) != 0) { break; } o.flags |= SEEN; if (ShouldSkipObject(o)) { break; } last = o; return(o); } default: { if (FileMode.GITLINK.Equals(mode)) { break; } treeWalk.GetEntryObjectId(idBuffer); throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3 , mode, idBuffer.Name, treeWalk.EntryPathString, currentTree.Name)); } } treeWalk = treeWalk.Next(); } if (firstCommit != null) { reader.WalkAdviceBeginTrees(this, firstCommit, lastCommit); firstCommit = null; lastCommit = null; } last = null; for (; ;) { RevObject o = pendingObjects.Next(); if (o == null) { reader.WalkAdviceEnd(); return(null); } if ((o.flags & SEEN) != 0) { continue; } o.flags |= SEEN; if (ShouldSkipObject(o)) { continue; } if (o is RevTree) { currentTree = (RevTree)o; treeWalk = treeWalk.ResetRoot(reader, currentTree); } return(o); } }