hgext/evolve.py
changeset 1628 db19b1dc5c45
parent 1627 a91115687a7e
child 1629 548195454683
equal deleted inserted replaced
1627:a91115687a7e 1628:db19b1dc5c45
  2077 
  2077 
  2078 @command('^previous',
  2078 @command('^previous',
  2079          [('B', 'move-bookmark', False,
  2079          [('B', 'move-bookmark', False,
  2080              _('move active bookmark after update')),
  2080              _('move active bookmark after update')),
  2081           ('', 'merge', False, _('bring uncommitted change along')),
  2081           ('', 'merge', False, _('bring uncommitted change along')),
       
  2082           ('', 'no-topic', False, _('ignore topic and move topologically')),
  2082           ('n', 'dry-run', False,
  2083           ('n', 'dry-run', False,
  2083              _('do not perform actions, just print what would be done'))],
  2084              _('do not perform actions, just print what would be done'))],
  2084          '[OPTION]...')
  2085          '[OPTION]...')
  2085 def cmdprevious(ui, repo, **opts):
  2086 def cmdprevious(ui, repo, **opts):
  2086     """update to parent revision
  2087     """update to parent revision
  2158         except error.Abort as exc:
  2159         except error.Abort as exc:
  2159             exc.hint = _('do you want --merge?')
  2160             exc.hint = _('do you want --merge?')
  2160             raise
  2161             raise
  2161 
  2162 
  2162     children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
  2163     children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
       
  2164     topic = getattr(repo, 'currenttopic', '')
       
  2165     filtered = []
       
  2166     if topic and not opts.get("no_topic", False):
       
  2167         filtered = [ctx for ctx in children if ctx.topic() != topic]
       
  2168         # XXX N-square membership on children
       
  2169         children = [ctx for ctx in children if ctx not in filtered]
  2163     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2170     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2164     if len(children) == 1:
  2171     if len(children) == 1:
  2165         c = children[0]
  2172         c = children[0]
  2166         bm = bmactive(repo)
  2173         bm = bmactive(repo)
  2167         shouldmove = opts.get('move_bookmark') and bm is not None
  2174         shouldmove = opts.get('move_bookmark') and bm is not None
  2193             displayer.show(c)
  2200             displayer.show(c)
  2194         ui.warn(_('explicitly update to one of them\n'))
  2201         ui.warn(_('explicitly update to one of them\n'))
  2195         result = 1
  2202         result = 1
  2196     else:
  2203     else:
  2197         aspchildren = _aspiringchildren(repo, [repo['.'].rev()])
  2204         aspchildren = _aspiringchildren(repo, [repo['.'].rev()])
       
  2205         if topic:
       
  2206             filtered.extend(repo[c] for c in children
       
  2207                             if repo[c].topic() != topic)
       
  2208             # XXX N-square membership on children
       
  2209             aspchildren = [ctx for ctx in aspchildren if ctx not in filtered]
  2198         if not opts['evolve'] or not aspchildren:
  2210         if not opts['evolve'] or not aspchildren:
  2199             ui.warn(_('no children\n'))
  2211             if filtered:
       
  2212                 ui.warn(_('no children on topic "%s"\n') % topic)
       
  2213                 ui.warn(_('do you want --no-topic\n'))
       
  2214             else:
       
  2215                 ui.warn(_('no children\n'))
  2200             if aspchildren:
  2216             if aspchildren:
  2201                 msg = _('(%i unstable changesets to be evolved here, '
  2217                 msg = _('(%i unstable changesets to be evolved here, '
  2202                         'do you want --evolve?)\n')
  2218                         'do you want --evolve?)\n')
  2203                 ui.warn(msg % len(aspchildren))
  2219                 ui.warn(msg % len(aspchildren))
  2204             result = 1
  2220             result = 1