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

Laurent Charignon lcharignon at fb.com
Tue May 5 16:29:47 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 0af82f6387fce507cd856aa0866534af0be65c98
# Parent  1a06c8c24ea35697471e2108581a6be71773c8e0
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
@@ -1267,6 +1267,12 @@
         if allopt:
             ui.progress('evolve', seen, unit='changesets', total=count)
 
+    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['.'])
+
     # Continuation handling
     if contopt:
         if anyopt:
@@ -1294,12 +1300,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