[PATCH 4 of 5 evolve-ext-V2] evolve: extract cleanup logic in the evolve function

Laurent Charignon lcharignon at fb.com
Tue May 5 19:42:35 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1430861135 25200
#      Tue May 05 14:25:35 2015 -0700
# Node ID c7f15e4ef7bd4b6aa617061a1cf06418d3fa770f
# Parent  d443bbbe9a7d0a55e1e4027204b56c639f5074a9
evolve: extract cleanup logic in the evolve function

We are going to need to reuse the cleanup logic when introducing --rev, so
we extract it in a method to avoid code duplication.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1215,6 +1215,14 @@
     else:
         ui.write_err(_('no troubled changesets\n'))
         return 1
+
+def _cleanup(ui, repo, startnode, showprogress):
+    if showprogress:
+        ui.progress('evolve', None)
+    if repo['.'] != startnode:
+        ui.status(_('working directory is now at %s\n') % repo['.'])
+
+
 @command('^evolve|stabilize|solve',
     [('n', 'dry-run', False,
         'do not perform actions, just print what would be done'),
@@ -1296,12 +1304,7 @@
         # Resolving a single trouble
         _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
 
-    # Cleanup
-    if showprogress:
-        ui.progress('evolve', None)
-
-    if repo['.'] != startnode:
-        ui.status(_('working directory is now at %s\n') % repo['.'])
+    _cleanup(ui, repo, startnode, showprogress)
 
 
 def _evolveany(ui, repo, tro, dryrunopt, confirmopt, progresscb):


More information about the Mercurial-devel mailing list