How can you get the current state (history of good/bad revisions) of a bisect from mercurial
Asked Answered
G

4

12

When doing an hg bisect in eclipse, I like that I can see all of the bads and goods I've marked in the past.
Is there a way to get that information at the command line?

Giantism answered 13/10, 2011 at 0:38 Comment(0)
P
10

There's a revset predicate for that:

"bisected(string)"  
 Changesets marked in the specified bisect state (good, bad, skip).

source

For future reference, Mercurial 2.0 will introduce an improved version (the old one will continue to work):

"bisect(string)"
  Changesets marked in the specified bisect status:

  - "good", "bad", "skip": csets explicitly marked as good/bad/skip
  - "goods", "bads"      : csets topologicaly good/bad
  - "range"              : csets taking part in the bisection
  - "pruned"             : csets that are goods, bads or skipped
  - "untested"           : csets whose fate is yet unknown
  - "ignored"            : csets ignored due to DAG topology
Piacular answered 13/10, 2011 at 9:3 Comment(8)
+1 for spotting the bisect revset. Any chance of a working example? I would guess something like: hg log -r "bisected(good) or bisected(bad)"?Erik
Thanks! Couple of notes: I had to upgrade from mercurial 1.6 to 1.9 to get this feature. I also can't find a way (in "hg help templates") to see the good or bad in order to do something like icabod suggested. It would be a shame if it required making two separate logs and then sorting them together in order to visualize, but it looks like that's the case. (Any way to get the "good" and "bad" in the log output?)Giantism
Joshua: what icabod wrote will get you both the good and bad changesets. What are you missing?Piacular
The output doesn't say which is which. (Looking for the word "good" in the report of a good one.)Giantism
Yeah, that's not available yet. It will be in 2.0 IIRC, so be sure to check come November. For now, two separate calls is the way.Piacular
Just confirming, in the current version of mercurial, you can now add the following to a log template to get the information I was looking for: {bisect|shortbisect}. Thanks! (In case someone reading this is not up to date, there was an intermediate period where this worked but ran extremely slow.)Giantism
I added another answer with a bash script to format a report using the info from the bisected() predicate.Giantism
@Erik I like this one, from my coworker: hg log -r "bisect(good) or bisect(bad)" --template "{node|short} {bisect}\n" it gives you just the hash and the good/badCubital
B
7

As suggested in a comment by @adambox, this should work:

hg log -r "bisect(good) or bisect(bad)" --template "{rev}:{node|short} {bisect}\n"
Blotto answered 30/9, 2015 at 20:28 Comment(3)
Can you explain why or how is this different/better than the accepted answer?Boule
How to render and see them mixed together is hidden in the comments (@adambox), so I think this is worthwhile. This does what my answer does, and much more simply now that {bisect} is available as a format. I'd just add "or ." to see the current rev which might not be marked yet.Giantism
The currently accepted answer points out only to the documentation. As said by Joshua, the real answer to his question ("is there a way to get that information at the command line?") is in a comment of adambox.Blotto
S
4

In Mercurial 3.8.2 (and probably earlier) you can use this:

hg log --template bisect
Scheer answered 23/6, 2016 at 7:10 Comment(0)
G
0

Here's a bash script (I called it bisectstate) that works now that the bisected() predicate is available.

(I used colorex to pretty it up with colors, but you can take that out if you don't have it installed.)

#!/bin/bash -f
style() {
    echo "{rev}$1 {author|person} {date|shortdate} {desc|firstline}\n"
}

(hg log -r 'not . and bisect(good)' --template "`style -good:`" ; 
 hg log -r '. and bisect(range) and not (bisect(good) or bisect(bad) or bisect(skip))' --template "`style -cur:`" ; 
 hg log -r "not . and bisect(bad)" --template "`style -bad:`" ; 
 hg log -r 'not . and bisect(skip)' --template "`style -skip:`" ; 
 hg log -r '. and bisect(good)' --template "`style -cur=good:`" ;
 hg log -r '. and bisect(bad)' --template "`style -cur=bad:`" ;
 hg log -r '. and bisect(skip)' --template "`style -cur=skip:`" ; 
# Include the intermediate, unmarked changes in the bisect range.
 hg log -r "bisect(range) and not (. or bisect(good) or bisect(bad) or bisect(skip))" --template "`style`"
) \
| sort | colorex -r bad: -b good: -g 'cur[=:]'

The output looks like this:

sample bisectstate output

Giantism answered 14/2, 2013 at 16:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.