# HG changeset patch # User "Yann E. MORIN" # Date 1316648161 -7200 # Node ID f4a8d754cd0a601deb290d5b76dd5b40b93d3872 # Parent aa2e908c521e4041e99e2a48742a4d411d8d1bb9 templates: add 'bisect' keyword to return a cset's bisect status This new 'bisect' template expands to a cset's bisection status (good, bad and so on...). There is also a new 'shortbisect' filter that yields a single char representing the cset's bisection status. It uses the two recently-added hbisect.label() and .shortlabel() functions. Example output using the repository in test-bisect2.t, and some made-up state of the 'end at merge' test (with graphlog, it's so explicit): $ hg glog --template '{rev}:{node|short} {bisect}\n' \ -r 'bisect(range)|bisect(ignored)' o 17:228c06deef46: bad | o 16:609d82a7ebae: bad (implicit) | o 15:857b178a7cf3: bad |\ | o 13:b0a32c86eb31: good | | | o 12:9f259202bbe7: good (implicit) | | | o 11:82ca6f06eccd: good | | @ | 10:429fcd26f52d: untested |\ \ | o | 9:3c77083deb4a: skipped | |/ | o 8:dab8161ac8fc: good | | o | 6:a214d5d3811a: ignored |\ \ | o | 5:385a529b6670: ignored | | | o | | 4:5c668c22234f: ignored | | | o | | 3:0950834f0a9c: ignored |/ / o / 2:051e12f87bf1: ignored |/ And now the same with the short label: $ hg log --template '{bisect|shortbisect} {rev}:{node|short}\n' 18:d42e18c7bc9b B 17:228c06deef46 B 16:609d82a7ebae B 15:857b178a7cf3 14:faa450606157 G 13:b0a32c86eb31 G 12:9f259202bbe7 G 11:82ca6f06eccd U 10:429fcd26f52d S 9:3c77083deb4a G 8:dab8161ac8fc 7:50c76098bbf2 I 6:a214d5d3811a I 5:385a529b6670 I 4:5c668c22234f I 3:0950834f0a9c I 2:051e12f87bf1 1:4ca5088da217 0:33b1f9bc8bc5 Signed-off-by: "Yann E. MORIN" diff -r aa2e908c521e -r f4a8d754cd0a mercurial/templatefilters.py --- a/mercurial/templatefilters.py Thu Sep 22 23:28:49 2011 +0200 +++ b/mercurial/templatefilters.py Thu Sep 22 01:36:01 2011 +0200 @@ -7,6 +7,7 @@ import cgi, re, os, time, urllib import encoding, node, util +import hbisect def addbreaks(text): """:addbreaks: Any text. Add an XHTML "
" tag before the end of @@ -268,6 +269,14 @@ """ return text[:12] +def shortbisect(text): + """:shortbisect: Any text. Treats `text` as a bisection status, and + returns a single-character representing the status (G: good, B: bad, + S: skipped, U: untested, I: ignored). Returns single space if `text` + is not a valid bisection status. + """ + return hbisect.shortlabel(text) or ' ' + def shortdate(text): """:shortdate: Date. Returns a date like "2006-09-18".""" return util.shortdate(text) @@ -347,6 +356,7 @@ "rfc3339date": rfc3339date, "rfc822date": rfc822date, "short": short, + "shortbisect": shortbisect, "shortdate": shortdate, "stringescape": stringescape, "stringify": stringify, diff -r aa2e908c521e -r f4a8d754cd0a mercurial/templatekw.py --- a/mercurial/templatekw.py Thu Sep 22 23:28:49 2011 +0200 +++ b/mercurial/templatekw.py Thu Sep 22 01:36:01 2011 +0200 @@ -7,6 +7,7 @@ from node import hex import patch, util, error +import hbisect def showlist(name, values, plural=None, **args): '''expand set of values. @@ -145,6 +146,10 @@ """:author: String. The unmodified author of the changeset.""" return ctx.user() +def showbisect(repo, ctx, templ, **args): + """:bisect: String. The changeset bisection status.""" + return hbisect.label(repo, ctx.node()) + def showbranch(**args): """:branch: String. The name of the branch on which the changeset was committed. @@ -288,6 +293,7 @@ # revcache - a cache dictionary for the current revision keywords = { 'author': showauthor, + 'bisect': showbisect, 'branch': showbranch, 'branches': showbranches, 'bookmarks': showbookmarks, diff -r aa2e908c521e -r f4a8d754cd0a tests/test-bisect3.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-bisect3.t Thu Sep 22 01:36:01 2011 +0200 @@ -0,0 +1,117 @@ +# Here we create a simple DAG which has just enough of the required +# topology to test all the bisection status labels: +# +# 13--14 +# / +# 0--1--2--3---------9--10--11--12 +# \ / +# 4--5--6--7--8 + + + $ hg init + + $ echo '0' >a + $ hg add a + $ hg ci -u test -d '0 0' -m '0' + $ echo '1' >a + $ hg ci -u test -d '0 1' -m '1' + +branch 2-3 + + $ echo '2' >b + $ hg add b + $ hg ci -u test -d '0 2' -m '2' + $ echo '3' >b + $ hg ci -u test -d '0 3' -m '3' + +branch 4-8 + + $ hg up -r 1 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo '4' >c + $ hg add c + $ hg ci -u test -d '0 4' -m '4' + created new head + $ echo '5' >c + $ hg ci -u test -d '0 5' -m '5' + $ echo '6' >c + $ hg ci -u test -d '0 6' -m '6' + $ echo '7' >c + $ hg ci -u test -d '0 7' -m '7' + $ echo '8' >c + $ hg ci -u test -d '0 8' -m '8' + +merge + + $ hg merge -r 3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg ci -u test -d '0 9' -m '9=8+3' + + $ echo '10' >a + $ hg ci -u test -d '0 10' -m '10' + $ echo '11' >a + $ hg ci -u test -d '0 11' -m '11' + $ echo '12' >a + $ hg ci -u test -d '0 12' -m '12' + +unrelated branch + + $ hg up -r 3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo '13' >d + $ hg add d + $ hg ci -u test -d '0 13' -m '13' + created new head + $ echo '14' >d + $ hg ci -u test -d '0 14' -m '14' + +mark changesets + + $ hg bisect --reset + $ hg bisect --good 4 + $ hg bisect --good 6 + $ hg bisect --bad 12 + Testing changeset 9:8bcbdb072033 (6 changesets remaining, ~2 tests) + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg bisect --bad 10 + Testing changeset 8:3cd112f87d77 (4 changesets remaining, ~2 tests) + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg bisect --skip 7 + Testing changeset 8:3cd112f87d77 (4 changesets remaining, ~2 tests) + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + +test template + + $ hg log --template '{rev}:{node|short} {bisect}\n' + 14:cecd84203acc + 13:86f7c8cdb6df + 12:a76089b5f47c bad + 11:5c3eb122d29c bad (implicit) + 10:b097cef2be03 bad + 9:8bcbdb072033 untested + 8:3cd112f87d77 untested + 7:577e237a73bd skipped + 6:e597fa2707c5 good + 5:b9cea37a76bc good (implicit) + 4:da6b357259d7 good + 3:e7f031aee8ca ignored + 2:b1ad1b6bcc5c ignored + 1:37f42ae8b45e good (implicit) + 0:b4e73ffab476 good (implicit) + $ hg log --template '{bisect|shortbisect} {rev}:{node|short}\n' + 14:cecd84203acc + 13:86f7c8cdb6df + B 12:a76089b5f47c + B 11:5c3eb122d29c + B 10:b097cef2be03 + U 9:8bcbdb072033 + U 8:3cd112f87d77 + S 7:577e237a73bd + G 6:e597fa2707c5 + G 5:b9cea37a76bc + G 4:da6b357259d7 + I 3:e7f031aee8ca + I 2:b1ad1b6bcc5c + G 1:37f42ae8b45e + G 0:b4e73ffab476