# HG changeset patch # User Patrick Mezard # Date 1345877497 -7200 # Node ID 4602104b190d98197b2db60f7fd050778114ab4f # Parent 8b25e9cf76fdc4ccd52224550054cddf99c4c90e evolve: factor out copy/paste in obssummary() diff -r 8b25e9cf76fd -r 4602104b190d hgext/evolve.py --- a/hgext/evolve.py Sat Aug 25 08:30:02 2012 +0200 +++ b/hgext/evolve.py Sat Aug 25 08:51:37 2012 +0200 @@ -931,22 +931,20 @@ @eh.wrapcommand("summary") def obssummary(orig, ui, repo, *args, **kwargs): + def write(fmt, count): + s = fmt % count + if count: + ui.write(s) + else: + ui.note(s) + ret = orig(ui, repo, *args, **kwargs) nbunstable = len(getobscache(repo, 'unstable')) nblatecomer = len(getobscache(repo, 'latecomer')) nbconflicting = len(getobscache(repo, 'unstable')) - if nbunstable: - ui.write('unstable: %i changesets\n' % nbunstable) - else: - ui.note('unstable: 0 changesets\n') - if nblatecomer: - ui.write('latecomer: %i changesets\n' % nblatecomer) - else: - ui.note('latecomer: 0 changesets\n') - if nbconflicting: - ui.write('conflicting: %i changesets\n' % nbconflicting) - else: - ui.note('conflicting: 0 changesets\n') + write('unstable: %i changesets\n', nbunstable) + write('latecomer: %i changesets\n', nblatecomer) + write('conflicting: %i changesets\n', nbconflicting) return ret