changeset 513:4602104b190d stable

evolve: factor out copy/paste in obssummary()
author Patrick Mezard <patrick@mezard.eu>
date Sat, 25 Aug 2012 08:51:37 +0200
parents 8b25e9cf76fd
children ea667749ccd1
files hgext/evolve.py
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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