First line: --from Second line: --to Numbers: revision height, greater means newer 1 2 3 > forward 4 5 6 > 1 2 3 > forward 3 4 5 > 1 2 3 > forward 2 3 4 > 1 2 3 > forward 1 2 3 4 > 1 2 3 > log these revs just like --revision would do, 1 2 3 > ie. look at --next / --last 1 2 X 4 > merge the sets and log just like --revision would do 1 Y 3 4 > ie. look at --next / --last 1 2 3 4 > backward 1 2 3 > 2 3 4 > backward 1 2 3 > 3 4 5 > backward 1 2 3 > 4 5 6 > backward 1 2 3 > pseudo algorithm: min_height(set) = height(take_first(toposort(set))) max_height(set) = height(take_last(toposort(set))) if (min_height(__from) <= min_height(__to) && max_height(__from) < max_height(__to)) direction = forward else if (min_height(__from) >= min_height(__to) && max_height(__from) > max_height(__to)) direction = backward; else direction = next >= 0 ? forward : backward;