comparison hgext/evolve.py @ 1449:9be1cadf7a07

next: add a --evolve option When on a topological head, this option will trigger the evolution of a unstable changeset that will result in a children of the current working copy parent. This should ease stacked changesets workflow by allowing to stick to prev and next to move through a stack of diff, evolving part of it on demand when needed. In case of ambiguity, the command will ask the user to choose. We need a better definition of "the stack of changesets I'm working on" to be able to seamlessly handling branching.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 24 Jun 2015 20:06:45 -0700
parents 3c113c097339
children 73eb4f33f9dc
comparison
equal deleted inserted replaced
1448:3c113c097339 1449:9be1cadf7a07
2003 return 1 2003 return 1
2004 2004
2005 @command('^next', 2005 @command('^next',
2006 [('B', 'move-bookmark', False, 2006 [('B', 'move-bookmark', False,
2007 _('Move active bookmark after update')), 2007 _('Move active bookmark after update')),
2008 ('', 'merge', False, _('bring uncommited change along'))], 2008 ('', 'merge', False, _('bring uncommited change along')),
2009 ('', 'evolve', False, _('evolve the next changeset if necessary'))],
2009 '[-B]') 2010 '[-B]')
2010 def cmdnext(ui, repo, **opts): 2011 def cmdnext(ui, repo, **opts):
2011 """update to child and display summary lines""" 2012 """update to next child
2013
2014 You can use the --evolve flag to get unstable children evolved on demand.
2015
2016 The summary line of the destination is displayed for clarity"""
2012 wkctx = repo[None] 2017 wkctx = repo[None]
2013 wparents = wkctx.parents() 2018 wparents = wkctx.parents()
2014 if len(wparents) != 1: 2019 if len(wparents) != 1:
2015 raise util.Abort('merge in progress') 2020 raise util.Abort('merge in progress')
2016 if not opts['merge']: 2021 if not opts['merge']:
2040 for c in children: 2045 for c in children:
2041 displayer.show(c) 2046 displayer.show(c)
2042 ui.warn(_('explicitly update to one of them\n')) 2047 ui.warn(_('explicitly update to one of them\n'))
2043 result = 1 2048 result = 1
2044 else: 2049 else:
2045 ui.warn(_('no children\n'))
2046 aspchildren = _aspiringchildren(repo, [repo['.'].rev()]) 2050 aspchildren = _aspiringchildren(repo, [repo['.'].rev()])
2047 if aspchildren: 2051 if not opts['evolve']:
2048 msg = _('(%i unstable changesets to be evolved here, ' 2052 ui.warn(_('no children\n'))
2049 'do you want to evolve?)\n') 2053 if aspchildren:
2050 ui.warn(msg % len(aspchildren)) 2054 msg = _('(%i unstable changesets to be evolved here, '
2051 result = 1 2055 'do you want --evolve?)\n')
2056 ui.warn(msg % len(aspchildren))
2057 result = 1
2058 elif 1 < len(aspchildren):
2059 ui.warn("ambigious next (unstable) changeset:\n")
2060 for c in aspchildren:
2061 displayer.show(repo[c])
2062 ui.warn(_('(run "hg evolve --rev REV" on one of them)\n'))
2063 return 1
2064 else:
2065 cmdutil.bailifchanged(repo)
2066 result = _solveone(ui, repo, repo[aspchildren[0]], False,
2067 False, lambda:None, category='unstable')
2068 if not result:
2069 ui.status(_('working directory now at %s\n') % repo['.'])
2070 return result
2071 return 1
2052 return result 2072 return result
2053 2073
2054 def _reachablefrombookmark(repo, revs, mark): 2074 def _reachablefrombookmark(repo, revs, mark):
2055 """filter revisions and bookmarks reachable from the given bookmark 2075 """filter revisions and bookmarks reachable from the given bookmark
2056 yoinked from mq.py 2076 yoinked from mq.py