hgext/evolve.py
changeset 1500 b4dfafda72c2
parent 1499 c936a243346a
child 1502 094b54a72c1d
equal deleted inserted replaced
1499:c936a243346a 1500:b4dfafda72c2
  1986 shorttemplate = '[{rev}] {desc|firstline}\n'
  1986 shorttemplate = '[{rev}] {desc|firstline}\n'
  1987 
  1987 
  1988 @command('^previous',
  1988 @command('^previous',
  1989          [('B', 'move-bookmark', False,
  1989          [('B', 'move-bookmark', False,
  1990              _('move active bookmark after update')),
  1990              _('move active bookmark after update')),
  1991           ('', 'merge', False, _('bring uncommitted change along'))],
  1991           ('', 'merge', False, _('bring uncommitted change along')),
  1992          '[-B]')
  1992           ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))],
       
  1993          '[OPTION]...')
  1993 def cmdprevious(ui, repo, **opts):
  1994 def cmdprevious(ui, repo, **opts):
  1994     """update to parent and display summary lines"""
  1995     """update to parent and display summary lines"""
  1995     wkctx = repo[None]
  1996     wkctx = repo[None]
  1996     wparents = wkctx.parents()
  1997     wparents = wkctx.parents()
       
  1998     dryrunopt = opts['dry_run']
  1997     if len(wparents) != 1:
  1999     if len(wparents) != 1:
  1998         raise util.Abort('merge in progress')
  2000         raise util.Abort('merge in progress')
  1999     if not opts['merge']:
  2001     if not opts['merge']:
  2000         try:
  2002         try:
  2001             cmdutil.bailifchanged(repo)
  2003             cmdutil.bailifchanged(repo)
  2007     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2009     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2008     if len(parents) == 1:
  2010     if len(parents) == 1:
  2009         p = parents[0]
  2011         p = parents[0]
  2010         bm = bmactive(repo)
  2012         bm = bmactive(repo)
  2011         shouldmove = opts.get('move_bookmark') and bm is not None
  2013         shouldmove = opts.get('move_bookmark') and bm is not None
  2012         ret = hg.update(repo, p.rev())
  2014         if dryrunopt:
  2013         if not ret:
  2015             ui.write('hg update %s;\n' % p.rev())
  2014             if shouldmove:
  2016             if shouldmove:
  2015                 repo._bookmarks[bm] = p.node()
  2017                 ui.write('hg bookmark %s -r %s;\n' % (bm, p.rev()))
  2016                 repo._bookmarks.write()
  2018         else:
  2017             else:
  2019             ret = hg.update(repo, p.rev())
  2018                 bmdeactivate(repo)
  2020             if not ret:
       
  2021                 if shouldmove:
       
  2022                     repo._bookmarks[bm] = p.node()
       
  2023                     repo._bookmarks.write()
       
  2024                 else:
       
  2025                     bmdeactivate(repo)
  2019         displayer.show(p)
  2026         displayer.show(p)
  2020         return 0
  2027         return 0
  2021     else:
  2028     else:
  2022         for p in parents:
  2029         for p in parents:
  2023             displayer.show(p)
  2030             displayer.show(p)
  2026 
  2033 
  2027 @command('^next',
  2034 @command('^next',
  2028          [('B', 'move-bookmark', False,
  2035          [('B', 'move-bookmark', False,
  2029              _('move active bookmark after update')),
  2036              _('move active bookmark after update')),
  2030           ('', 'merge', False, _('bring uncommitted change along')),
  2037           ('', 'merge', False, _('bring uncommitted change along')),
  2031           ('', 'evolve', False, _('evolve the next changeset if necessary'))],
  2038           ('', 'evolve', False, _('evolve the next changeset if necessary')),
  2032          '[-B]')
  2039           ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))],
       
  2040          '[OPTION]...')
  2033 def cmdnext(ui, repo, **opts):
  2041 def cmdnext(ui, repo, **opts):
  2034     """update to next child
  2042     """update to next child
  2035 
  2043 
  2036     You can use the --evolve flag to get unstable children evolved on demand.
  2044     You can use the --evolve flag to get unstable children evolved on demand.
  2037 
  2045 
  2038     The summary line of the destination is displayed for clarity"""
  2046     The summary line of the destination is displayed for clarity"""
  2039     wkctx = repo[None]
  2047     wkctx = repo[None]
  2040     wparents = wkctx.parents()
  2048     wparents = wkctx.parents()
       
  2049     dryrunopt = opts['dry_run']
  2041     if len(wparents) != 1:
  2050     if len(wparents) != 1:
  2042         raise util.Abort('merge in progress')
  2051         raise util.Abort('merge in progress')
  2043     if not opts['merge']:
  2052     if not opts['merge']:
  2044         try:
  2053         try:
  2045             cmdutil.bailifchanged(repo)
  2054             cmdutil.bailifchanged(repo)
  2051     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2060     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  2052     if len(children) == 1:
  2061     if len(children) == 1:
  2053         c = children[0]
  2062         c = children[0]
  2054         bm = bmactive(repo)
  2063         bm = bmactive(repo)
  2055         shouldmove = opts.get('move_bookmark') and bm is not None
  2064         shouldmove = opts.get('move_bookmark') and bm is not None
  2056         ret = hg.update(repo, c.rev())
  2065         if dryrunopt:
  2057         if not ret:
  2066             ui.write('hg update %s;\n' % c.rev())
  2058             if shouldmove:
  2067             if shouldmove:
  2059                 repo._bookmarks[bm] = c.node()
  2068                 ui.write('hg bookmark %s -r %s;\n' % (bm, c.rev()))
  2060                 repo._bookmarks.write()
  2069         else:
  2061             else:
  2070             ret = hg.update(repo, c.rev())
  2062                 bmdeactivate(repo)
  2071             if not ret:
       
  2072                 if shouldmove:
       
  2073                     repo._bookmarks[bm] = c.node()
       
  2074                     repo._bookmarks.write()
       
  2075                 else:
       
  2076                     bmdeactivate(repo)
  2063         displayer.show(c)
  2077         displayer.show(c)
  2064         result = 0
  2078         result = 0
  2065     elif children:
  2079     elif children:
  2066         ui.warn("ambigious next changeset:\n")
  2080         ui.warn("ambigious next changeset:\n")
  2067         for c in children:
  2081         for c in children:
  2083                 displayer.show(repo[c])
  2097                 displayer.show(repo[c])
  2084             ui.warn(_('(run "hg evolve --rev REV" on one of them)\n'))
  2098             ui.warn(_('(run "hg evolve --rev REV" on one of them)\n'))
  2085             return 1
  2099             return 1
  2086         else:
  2100         else:
  2087             cmdutil.bailifchanged(repo)
  2101             cmdutil.bailifchanged(repo)
  2088             result = _solveone(ui, repo, repo[aspchildren[0]], False,
  2102             result = _solveone(ui, repo, repo[aspchildren[0]], dryrunopt,
  2089                                False, lambda:None, category='unstable')
  2103                                False, lambda:None, category='unstable')
  2090             if not result:
  2104             if not result:
  2091                 ui.status(_('working directory now at %s\n') % repo['.'])
  2105                 ui.status(_('working directory now at %s\n') % repo['.'])
  2092             return result
  2106             return result
  2093         return 1
  2107         return 1