/// <summary> /// Mark an object to not produce in the output. /// <para /> /// Uninteresting objects denote not just themselves but also their entire /// reachable chain, back until the merge base of an uninteresting commit and /// an otherwise interesting commit. /// <para /> /// Callers are encouraged to use <see cref="RevWalk.parseAny(AnyObjectId)"/> /// instead of <see cref="RevWalk.lookupAny(AnyObjectId, int)"/>, as this method /// requires the object to be parsed before it can be added as a root for the /// traversal. /// <para /> /// The method will automatically parse an unparsed object, but error /// handling may be more difficult for the application to explain why a /// RevObject is not actually valid. The object pool of this walker would /// also be 'poisoned' by the invalid <see cref="RevObject"/>. /// <para /> /// This method will automatically call <see cref="RevWalk.markStart(RevCommit)"/> /// if passed RevCommit instance, or a <see cref="RevTag"/> that directly (or indirectly) /// references a <see cref="RevCommit"/>. /// </summary> /// <param name="o"> /// The object to start traversing from. The object passed must be /// from this same revision walker. /// </param> /// <exception cref="MissingObjectException"> /// The object supplied is not available from the object /// database. This usually indicates the supplied object is /// invalid, but the reference was constructed during an earlier /// invocation to <see cref="RevWalk.lookupAny(AnyObjectId, int)"/>. /// </exception> /// <exception cref="IncorrectObjectTypeException"> /// The object was not parsed yet and it was discovered during /// parsing that it is not actually the type of the instance /// passed in. This usually indicates the caller used the wrong /// type in a <see cref="RevWalk.lookupAny(AnyObjectId, int)"/> call. /// </exception> /// <exception cref="Exception"> /// A pack file or loose object could not be Read. /// </exception> public void markUninteresting(RevObject o) { RevTag oTag = (o as RevTag); while (oTag != null) { o.Flags |= UNINTERESTING; if (hasRevSort(RevSort.BOUNDARY)) { AddObject(o); } o = oTag.getObject(); parseHeaders(o); } RevCommit oComm = (o as RevCommit); if (oComm != null) { base.markUninteresting(oComm); } else if (o is RevTree) { MarkTreeUninteresting(o); } else { o.Flags |= UNINTERESTING; } if (o.Type != Constants.OBJ_COMMIT && hasRevSort(RevSort.BOUNDARY)) { AddObject(o); } }
public override void setUp() { base.setUp(); diskRepo = createBareRepository(); refdir = (RefDirectory)diskRepo.RefDatabase; repo = new TestRepository(diskRepo); A = repo.commit().create(); B = repo.commit(repo.getRevWalk().parseCommit(A)); v1_0 = repo.tag("v1_0", B); repo.getRevWalk().parseBody(v1_0); }
/// <summary> /// Mark an object or commit to start graph traversal from. /// <para /> /// Callers are encouraged to use <see cref="RevWalk.parseAny(AnyObjectId)"/> /// instead of <see cref="RevWalk.lookupAny(AnyObjectId, int)"/>, as this method /// requires the object to be parsed before it can be added as a root for the /// traversal. /// <para /> /// The method will automatically parse an unparsed object, but error /// handling may be more difficult for the application to explain why a /// RevObject is not actually valid. The object pool of this walker would /// also be 'poisoned' by the invalid <see cref="RevObject"/>. /// <para /> /// This method will automatically call <see cref="RevWalk.markStart(RevCommit)"/> /// if passed RevCommit instance, or a <see cref="RevTag"/> that directly (or indirectly) /// references a <see cref="RevCommit"/>. /// </summary> /// <param name="o"> /// The object to start traversing from. The object passed must be /// from this same revision walker. /// </param> /// <exception cref="MissingObjectException"> /// The object supplied is not available from the object /// database. This usually indicates the supplied object is /// invalid, but the reference was constructed during an earlier /// invocation to <see cref="RevWalk.lookupAny(AnyObjectId, int)"/>. /// </exception> /// <exception cref="IncorrectObjectTypeException"> /// The object was not parsed yet and it was discovered during /// parsing that it is not actually the type of the instance /// passed in. This usually indicates the caller used the wrong /// type in a <see cref="RevWalk.lookupAny(AnyObjectId, int)"/> call. /// </exception> /// <exception cref="Exception"> /// A pack file or loose object could not be Read. /// </exception> public void markStart(RevObject o) { RevTag oTag = (o as RevTag); while (oTag != null) { AddObject(o); o = oTag.getObject(); parseHeaders(o); } RevCommit oComm = (o as RevCommit); if (oComm != null) { base.markStart(oComm); } else { AddObject(o); } }
public void testParseAllFields() { ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); const string name = "v1.2.3.4.5"; const string taggerName = "A U. Thor"; const string taggerEmail = "*****@*****.**"; const int taggerTime = 1218123387; var body = new StringBuilder(); body.Append("object "); body.Append(treeId.Name); body.Append("\n"); body.Append("type tree\n"); body.Append("tag "); body.Append(name); body.Append("\n"); body.Append("tagger "); body.Append(taggerName); body.Append(" <"); body.Append(taggerEmail); body.Append("> "); body.Append(taggerTime); body.Append(" +0700\n"); body.Append("\n"); var rw = new Core.RevWalk.RevWalk(db); var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, body.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(treeId, c.getObject().getId()); Assert.AreSame(rw.lookupTree(treeId), c.getObject()); Assert.IsNotNull(c.getTagName()); Assert.AreEqual(name, c.getTagName()); Assert.AreEqual(string.Empty, c.getFullMessage()); PersonIdent cTagger = c.getTaggerIdent(); Assert.IsNotNull(cTagger); Assert.AreEqual(taggerName, cTagger.Name); Assert.AreEqual(taggerEmail, cTagger.EmailAddress); }
private void testOneType(int typeCode) { ObjectId locId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); var b = new StringBuilder(); b.Append("object " + locId.Name + "\n"); b.Append("type " + Constants.typeString(typeCode) + "\n"); b.Append("tag v1.2.3.4.5\n"); b.Append("tagger A U. Thor <*****@*****.**> 1218123387 +0700\n"); b.Append("\n"); var rw = new Core.RevWalk.RevWalk(db); var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, b.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(locId, c.getObject().getId()); Assert.AreSame(rw.lookupAny(locId, typeCode), c.getObject()); }
private RevTag create(string msg) { var b = new StringBuilder(); b.Append("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"); b.Append("type tree\n"); b.Append("tag v1.2.3.4.5\n"); b.Append("tagger A U. Thor <*****@*****.**> 1218123387 +0700\n"); b.Append("\n"); b.Append(msg); var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), b.ToString().getBytes("UTF-8")); return c; }
public void testParse_implicit_UTF8_encoded() { RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); b.Write("type tree\n".getBytes("UTF-8")); b.Write("tag v1.2.3.4.5\n".getBytes("UTF-8")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("Sm\u00f6rg\u00e5sbord\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray()); } Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name); Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); }
public void testParse_implicit_mixed_encoded() { RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); b.Write("type tree\n".getBytes("UTF-8")); b.Write("tag v1.2.3.4.5\n".getBytes("UTF-8")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("ISO-8859-1")); b.Write("\n".getBytes("UTF-8")); b.Write("Sm\u00f6rg\u00e5sbord\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray()); } AssertHelper.IgnoreOnMono(() => Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name), "Will fail in mono due to https://bugzilla.novell.com/show_bug.cgi?id=549914"); Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); }
public void testParse_explicit_encoded() { Assert.Ignore("We are going to deal with encoding problems later. For now, they are only disturbing the build."); RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("EUC-JP")); b.Write("type tree\n".getBytes("EUC-JP")); b.Write("tag v1.2.3.4.5\n".getBytes("EUC-JP")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("EUC-JP")); b.Write("encoding euc_JP\n".getBytes("EUC-JP")); b.Write("\n".getBytes("EUC-JP")); b.Write("\u304d\u308c\u3044\n".getBytes("EUC-JP")); b.Write("\n".getBytes("EUC-JP")); b.Write("Hi\n".getBytes("EUC-JP")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray()); } Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name); Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage()); Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage()); }
private void advertiseTag(RevTag tag, string refName) { RevObject o = tag; do { RevObject target = ((RevTag)o).getObject(); try { _walk.parseHeaders(target); } catch (IOException) { return; } target.add(ADVERTISED); o = target; } while (o is RevTag); advertiseAny(tag.getObject(), refName); }
private void advertiseTag(RevTag tag, string refName) { RevObject o = tag; do { // Fully unwrap here so later on we have these already parsed. RevObject target = (((RevTag)o).getObject()); try { _walk.parseHeaders(target); } catch (IOException) { return; } target.add(ADVERTISED); o = target; } while (o is RevTag); advertiseAny(tag.getObject(), refName); }
public void testParseOldStyleNoTagger() { ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); string name = "v1.2.3.4.5"; string message = "test\n" // + "\n" // + "-----BEGIN PGP SIGNATURE-----\n" // + "Version: GnuPG v1.4.1 (GNU/Linux)\n" // + "\n" // + "iD8DBQBC0b9oF3Y\n" // + "-----END PGP SIGNATURE------n"; var body = new StringBuilder(); body.Append("object "); body.Append(treeId.Name); body.Append("\n"); body.Append("type tree\n"); body.Append("tag "); body.Append(name); body.Append("\n"); body.Append("\n"); body.Append(message); var rw = new Core.RevWalk.RevWalk(db); RevTag c; c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, body.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(treeId, c.getObject().getId()); Assert.AreSame(rw.lookupTree(treeId), c.getObject()); Assert.IsNotNull(c.getTagName()); Assert.AreEqual(name, c.getTagName()); Assert.AreEqual("test", c.getShortMessage()); Assert.AreEqual(message, c.getFullMessage()); Assert.IsNull(c.getTaggerIdent()); }