hgext/evolve.py
changeset 1171 d14537d7dca9
parent 1170 4697f23e0ede
parent 1168 2187f7c88ff6
child 1172 8d28bb4fc127
equal deleted inserted replaced
1170:4697f23e0ede 1171:d14537d7dca9
    17     - alters core commands and extensions that rewrite history to use
    17     - alters core commands and extensions that rewrite history to use
    18       this feature,
    18       this feature,
    19     - improves some aspect of the early implementation in Mercurial core
    19     - improves some aspect of the early implementation in Mercurial core
    20 '''
    20 '''
    21 
    21 
    22 __version__ = '5.1.0'
    22 __version__ = '5.0.0'
    23 testedwith = '3.2'
    23 testedwith = '3.2'
    24 buglink = 'http://bz.selenic.com/'
    24 buglink = 'http://bz.selenic.com/'
    25 
    25 
    26 import sys, os
    26 import sys, os
    27 import random
    27 import random
   882 
   882 
   883 @eh.uisetup
   883 @eh.uisetup
   884 def _installimportobsolete(ui):
   884 def _installimportobsolete(ui):
   885     entry = cmdutil.findcmd('import', commands.table)[1]
   885     entry = cmdutil.findcmd('import', commands.table)[1]
   886     entry[1].append(('', 'obsolete', False,
   886     entry[1].append(('', 'obsolete', False,
   887                     _('mark the old node as obsoleted by'
   887                     _('mark the old node as obsoleted by '
   888                       'the created commit')))
   888                       'the created commit')))
   889 
   889 
   890 @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
   890 @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
   891 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
   891 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
   892     extracted = patch.extract(ui, hunk)
   892     extracted = patch.extract(ui, hunk)
  1116                         '(implies any)'),
  1116                         '(implies any)'),
  1117     ('c', 'continue', False, 'continue an interrupted evolution'),
  1117     ('c', 'continue', False, 'continue an interrupted evolution'),
  1118     ] + mergetoolopts,
  1118     ] + mergetoolopts,
  1119     _('[OPTIONS]...'))
  1119     _('[OPTIONS]...'))
  1120 def evolve(ui, repo, **opts):
  1120 def evolve(ui, repo, **opts):
  1121     """Solve trouble in your repository
  1121     """solve trouble in your repository
  1122 
  1122 
  1123     - rebase unstable changesets to make them stable again,
  1123     - rebase unstable changesets to make them stable again,
  1124     - create proper diffs from bumped changesets,
  1124     - create proper diffs from bumped changesets,
  1125     - merge divergent changesets,
  1125     - merge divergent changesets,
  1126     - update to a successor if the working directory parent is
  1126     - update to a successor if the working directory parent is
  1582 
  1582 
  1583 
  1583 
  1584 shorttemplate = '[{rev}] {desc|firstline}\n'
  1584 shorttemplate = '[{rev}] {desc|firstline}\n'
  1585 
  1585 
  1586 @command('^previous',
  1586 @command('^previous',
  1587          [],
  1587          [('B', 'move-bookmark', False,
  1588          '')
  1588              _('Move current active bookmark after update'))],
  1589 def cmdprevious(ui, repo):
  1589          '[-B]')
       
  1590 def cmdprevious(ui, repo, **opts):
  1590     """update to parent and display summary lines"""
  1591     """update to parent and display summary lines"""
  1591     wkctx = repo[None]
  1592     wkctx = repo[None]
  1592     wparents = wkctx.parents()
  1593     wparents = wkctx.parents()
  1593     if len(wparents) != 1:
  1594     if len(wparents) != 1:
  1594         raise util.Abort('merge in progress')
  1595         raise util.Abort('merge in progress')
  1596     parents = wparents[0].parents()
  1597     parents = wparents[0].parents()
  1597     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1598     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1598     if len(parents) == 1:
  1599     if len(parents) == 1:
  1599         p = parents[0]
  1600         p = parents[0]
  1600         bm = bookmarks.readcurrent(repo)
  1601         bm = bookmarks.readcurrent(repo)
  1601         shouldmove = bm is not None and bookmarks.iscurrent(repo, bm)
  1602         shouldmove = opts.get('move_bookmark') and bm is not None
  1602         ret = hg.update(repo, p.rev())
  1603         ret = hg.update(repo, p.rev())
  1603         if not ret and shouldmove:
  1604         if not ret:
  1604             repo._bookmarks[bm] = p.node()
  1605             if shouldmove:
  1605             repo._bookmarks.write()
  1606                 repo._bookmarks[bm] = p.node()
       
  1607                 repo._bookmarks.write()
       
  1608             else:
       
  1609                 bookmarks.unsetcurrent(repo)
  1606         displayer.show(p)
  1610         displayer.show(p)
  1607         return 0
  1611         return 0
  1608     else:
  1612     else:
  1609         for p in parents:
  1613         for p in parents:
  1610             displayer.show(p)
  1614             displayer.show(p)
  1611         ui.warn(_('multiple parents, explicitly update to one\n'))
  1615         ui.warn(_('multiple parents, explicitly update to one\n'))
  1612         return 1
  1616         return 1
  1613 
  1617 
  1614 @command('^next',
  1618 @command('^next',
  1615          [],
  1619          [('B', 'move-bookmark', False,
  1616          '')
  1620              _('Move current active bookmark after update'))],
  1617 def cmdnext(ui, repo):
  1621          '[-B]')
       
  1622 def cmdnext(ui, repo, **opts):
  1618     """update to child and display summary lines"""
  1623     """update to child and display summary lines"""
  1619     wkctx = repo[None]
  1624     wkctx = repo[None]
  1620     wparents = wkctx.parents()
  1625     wparents = wkctx.parents()
  1621     if len(wparents) != 1:
  1626     if len(wparents) != 1:
  1622         raise util.Abort('merge in progress')
  1627         raise util.Abort('merge in progress')
  1627         ui.warn(_('no non-obsolete children\n'))
  1632         ui.warn(_('no non-obsolete children\n'))
  1628         return 1
  1633         return 1
  1629     if len(children) == 1:
  1634     if len(children) == 1:
  1630         c = children[0]
  1635         c = children[0]
  1631         bm = bookmarks.readcurrent(repo)
  1636         bm = bookmarks.readcurrent(repo)
  1632         shouldmove = bm is not None and bookmarks.iscurrent(repo, bm)
  1637         shouldmove = opts.get('move_bookmark') and bm is not None
  1633         ret = hg.update(repo, c.rev())
  1638         ret = hg.update(repo, c.rev())
  1634         if not ret and shouldmove:
  1639         if not ret:
  1635             repo._bookmarks[bm] = c.node()
  1640             if shouldmove:
  1636             repo._bookmarks.write()
  1641                 repo._bookmarks[bm] = c.node()
       
  1642                 repo._bookmarks.write()
       
  1643             else:
       
  1644                 bookmarks.unsetcurrent(repo)
  1637         displayer.show(c)
  1645         displayer.show(c)
  1638         return 0
  1646         return 0
  1639     else:
  1647     else:
  1640         for c in children:
  1648         for c in children:
  1641             displayer.show(c)
  1649             displayer.show(c)
  2052      ('D', 'duplicate', False,
  2060      ('D', 'duplicate', False,
  2053       'do not mark the new revision as successor of the old one')],
  2061       'do not mark the new revision as successor of the old one')],
  2054     # allow to choose the seed ?
  2062     # allow to choose the seed ?
  2055     _('[-r] revs'))
  2063     _('[-r] revs'))
  2056 def touch(ui, repo, *revs, **opts):
  2064 def touch(ui, repo, *revs, **opts):
  2057     """Create successors that are identical to their predecessors except for the changeset ID
  2065     """create successors that are identical to their predecessors except for the changeset ID
  2058 
  2066 
  2059     This is used to "resurrect" changesets
  2067     This is used to "resurrect" changesets
  2060     """
  2068     """
  2061     duplicate = opts['duplicate']
  2069     duplicate = opts['duplicate']
  2062     revs = list(revs)
  2070     revs = list(revs)