Commits

Patrick Mézard  committed 4602104

evolve: factor out copy/paste in obssummary()

  • Participants
  • Parent commits 8b25e9c

Comments (0)

Files changed (1)

File hgext/evolve.py

 
 @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