discovery: only calculate closed branches if required

Authored by pulkit.

Description

discovery: only calculate closed branches if required

The number of new closed branches is required for printing in error message. So
let's only calculate them if we need to print error about new branches.

Differential Revision: https://phab.mercurial-scm.org/D6314

Details