# HG changeset patch # User Pierre-Yves David # Date 1435202277 25200 # Node ID a73d1ee480033c93064e530d8309255817460867 # Parent 6fd6c98f9f70c7658444c81dcecb7567352a2072 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. diff -r 6fd6c98f9f70 -r a73d1ee48003 hgext/evolve.py --- 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