# HG changeset patch # User Sushil khanchi # Date 1541861405 -3600 # Node ID df22f010cf2473047a458442404666565bb92717 # Parent 323b3dac5bba6bd6c24c82fb4c1cdb61e80c2f9f next: make next command --evolve by default Before this patch, if we need to evolve to update to the next child, we were suggesting the user to use --evolve flag. This patch make some changes to evolve by default in that conditions. After making next command to evolve by default we have to consider the following points: 1) If we don't need to evolve while updating to the next child: a) And if wdir is dirty, we suggest to use --merge flag b) if wdir is clean, we simply update to next child (if ambiguous, prompt the user to select one) 2) If we need to evolve: a) when wdir is dirty, we suggest the user to use `hg shelve` first, to make wdir clean. As we don't support --merge while evovling. b) when wdir is clean, we evolve the next cset. Changes made in test-prev-next.t reflect the changed behaviour. diff -r 323b3dac5bba -r df22f010cf24 hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py Sat Nov 10 16:05:34 2018 +0100 +++ b/hgext3rd/evolve/__init__.py Sat Nov 10 15:50:05 2018 +0100 @@ -1105,7 +1105,7 @@ [('B', 'move-bookmark', False, _('move active bookmark after update')), ('m', 'merge', False, _('bring uncommitted change along')), - ('', 'evolve', False, _('evolve the next changeset if necessary')), + ('', 'evolve', True, _('evolve the next changeset if necessary')), ('', 'no-topic', False, _('ignore topic and move topologically')), ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], @@ -1128,11 +1128,6 @@ if len(wparents) != 1: raise error.Abort(_('merge in progress')) - # check for dirty wdir if --evolve is passed - if opts['evolve']: - hint = _('use `hg amend`, `hg revert` or `hg shelve`') - cmdutil.bailifchanged(repo, hint=hint) - children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] topic = _getcurrenttopic(repo) filtered = set() @@ -1144,13 +1139,21 @@ displayer = compat.changesetdisplayer(ui, repo, {'template': template}) # check if we need to evolve while updating to the next child revision + needevolve = False aspchildren = evolvecmd._aspiringchildren(repo, [repo['.'].rev()]) if topic: filtered.update(repo[c] for c in aspchildren if repo[c].topic() != topic) aspchildren = [ctx for ctx in aspchildren if ctx not in filtered] + if aspchildren: + needevolve = True - if not opts['merge']: + # check if working directory is clean before we evolve the next cset + if needevolve: + hint = _('use `hg amend`, `hg revert` or `hg shelve`') + cmdutil.bailifchanged(repo, hint=hint) + + if not opts['merge'] and not needevolve: # we only skip the check if noconflict is set if ui.config('commands', 'update.check') == 'noconflict': pass @@ -1173,16 +1176,12 @@ else: return _updatetonext(ui, repo, repo[choosedrev], displayer, opts) else: - if not opts['evolve'] or not aspchildren: + if not aspchildren: if filtered: ui.warn(_('no children on topic "%s"\n') % topic) ui.warn(_('do you want --no-topic\n')) else: ui.warn(_('no children\n')) - if aspchildren: - msg = _('(%i unstable changesets to be evolved here, ' - 'do you want --evolve?)\n') - ui.warn(msg % len(aspchildren)) return 1 elif 1 < len(aspchildren): cheader = _("ambiguous next (unstable) changeset, choose one to"