changeset 1446:a73d1ee48003

next: refactor the command code We make the conditional flatter and the return more straight forward. This will make addition of more complex cases more straightforward in future changesets.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 24 Jun 2015 20:17:57 -0700
parents 6fd6c98f9f70
children 09206bdc2db4
files hgext/evolve.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Wed Jun 24 21:16:57 2015 -0700
+++ b/hgext/evolve.py	Wed Jun 24 20:17:57 2015 -0700
@@ -2022,9 +2022,6 @@
 
     children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
-    if not children:
-        ui.warn(_('no non-obsolete children\n'))
-        return 1
     if len(children) == 1:
         c = children[0]
         bm = bmactive(repo)
@@ -2037,13 +2034,17 @@
             else:
                 bmdeactivate(repo)
         displayer.show(c)
-        return 0
-    else:
+        result = 0
+    elif children:
         for c in children:
             displayer.show(c)
         ui.warn(_('multiple non-obsolete children, '
-            'explicitly update to one of them\n'))
-        return 1
+                  'explicitly update to one of them\n'))
+        result = 1
+    else:
+        ui.warn(_('no non-obsolete children\n'))
+        result = 1
+    return result
 
 def _reachablefrombookmark(repo, revs, mark):
     """filter revisions and bookmarks reachable from the given bookmark