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.
--- 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