hgext/evolve.py
changeset 1158 0f6c97421cd9
parent 1157 5951969400ce
child 1159 04bd66779a1f
child 1160 e29a813f6af5
equal deleted inserted replaced
1145:fb51113a1c08 1158:0f6c97421cd9
    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 testedwith = '3.2'
    23 testedwith = '3.2'
    23 buglink = 'http://bz.selenic.com/'
    24 buglink = 'http://bz.selenic.com/'
    24 
    25 
    25 import sys, os
    26 import sys, os
    26 import random
    27 import random
    83     oldmemfilectx = context.memfilectx
    84     oldmemfilectx = context.memfilectx
    84     def memfilectx(repo, *args, **kwargs):
    85     def memfilectx(repo, *args, **kwargs):
    85         return oldmemfilectx(*args, **kwargs)
    86         return oldmemfilectx(*args, **kwargs)
    86 else:
    87 else:
    87     raise util.Abort('Your Mercurial is too old for this version of Evolve\n'
    88     raise util.Abort('Your Mercurial is too old for this version of Evolve\n'
    88                      'requires version 3.2 or above')
    89                      'requires version %s or above' % min(testedwith.split()))
    89 
    90 
    90 
    91 
    91 # This extension contains the following code
    92 # This extension contains the following code
    92 #
    93 #
    93 # - Extension Helper code
    94 # - Extension Helper code
  1188                 ui.status(_('update:'))
  1189                 ui.status(_('update:'))
  1189                 if not ui.quiet:
  1190                 if not ui.quiet:
  1190                     displayer.show(ctx)
  1191                     displayer.show(ctx)
  1191 
  1192 
  1192                 if dryrunopt:
  1193                 if dryrunopt:
  1193                     print 'hg update %s' % ctx.rev()
       
  1194                     return 0
  1194                     return 0
  1195                 else:
  1195                 else:
  1196                     res = hg.update(repo, ctx.rev())
  1196                     res = hg.update(repo, ctx.rev())
  1197                     if ctx != startnode:
  1197                     if ctx != startnode:
  1198                         ui.status(_('working directory is now at %s\n') % ctx)
  1198                         ui.status(_('working directory is now at %s\n') % ctx)
  1300             for prec in repo.set('allprecursors(%d)', ctx):
  1300             for prec in repo.set('allprecursors(%d)', ctx):
  1301                 yield prec
  1301                 yield prec
  1302 
  1302 
  1303     # Look for an unstable which can be stabilized as a child of
  1303     # Look for an unstable which can be stabilized as a child of
  1304     # node. The unstable must be a child of one of node predecessors.
  1304     # node. The unstable must be a child of one of node predecessors.
       
  1305     directdesc = set([pctx.rev()])
  1305     for ctx in selfanddescendants(repo, pctx):
  1306     for ctx in selfanddescendants(repo, pctx):
  1306         for child in ctx.children():
  1307         for child in ctx.children():
  1307             if child.unstable():
  1308             if ctx.rev() in directdesc and not child.obsolete():
       
  1309                 directdesc.add(child.rev())
       
  1310             elif child.unstable():
  1308                 return child
  1311                 return child
  1309     return None
  1312     return None
  1310 
  1313 
  1311 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
  1314 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
  1312                    progresscb=None):
  1315                    progresscb=None):
  1313     """Stabilize a unstable changeset"""
  1316     """Stabilize a unstable changeset"""
  1314     obs = orig.parents()[0]
  1317     obs = orig.parents()[0]
  1315     if not obs.obsolete():
  1318     if not obs.obsolete():
  1316         print obs.rev(), orig.parents()
  1319         obs = orig.parents()[1] # second parent is obsolete ?
  1317         print orig.rev()
       
  1318         obs = orig.parents()[1]
       
  1319     assert obs.obsolete()
  1320     assert obs.obsolete()
  1320     newer = obsolete.successorssets(repo, obs.node())
  1321     newer = obsolete.successorssets(repo, obs.node())
  1321     # search of a parent which is not killed
  1322     # search of a parent which is not killed
  1322     while not newer or newer == [()]:
  1323     while not newer or newer == [()]:
  1323         ui.debug("stabilize target %s is plain dead,"
  1324         ui.debug("stabilize target %s is plain dead,"
  1412         # Create the new commit context
  1413         # Create the new commit context
  1413         repo.ui.status(_('computing new diff\n'))
  1414         repo.ui.status(_('computing new diff\n'))
  1414         files = set()
  1415         files = set()
  1415         copied = copies.pathcopies(prec, bumped)
  1416         copied = copies.pathcopies(prec, bumped)
  1416         precmanifest = prec.manifest()
  1417         precmanifest = prec.manifest()
  1417         for key, val in bumped.manifest().iteritems():
  1418         for key, val in bumped.manifest().items():
  1418             if precmanifest.pop(key, None) != val:
  1419             if precmanifest.pop(key, None) != val:
  1419                 files.add(key)
  1420                 files.add(key)
  1420         files.update(precmanifest)  # add missing files
  1421         files.update(precmanifest)  # add missing files
  1421         # commit it
  1422         # commit it
  1422         if files: # something to commit!
  1423         if files: # something to commit!
  1486                     hint="You have to fallback to solving this by hand...\n"
  1487                     hint="You have to fallback to solving this by hand...\n"
  1487                          "| This probably means redoing the merge and using "
  1488                          "| This probably means redoing the merge and using "
  1488                          "| `hg prune` to kill older version.")
  1489                          "| `hg prune` to kill older version.")
  1489     if other.p1() not in divergent.parents():
  1490     if other.p1() not in divergent.parents():
  1490         raise util.Abort("parents are not common (not handled yet)",
  1491         raise util.Abort("parents are not common (not handled yet)",
  1491                     hint="| %(d)s, %(o)s are not based on the same changeset."
  1492                     hint="| %(d)s, %(o)s are not based on the same changeset.\n"
  1492                          "| With the current state of its implementation, "
  1493                          "| With the current state of its implementation, \n"
  1493                          "| evolve does not work in that case.\n"
  1494                          "| evolve does not work in that case.\n"
  1494                          "| rebase one of them next to the other and run "
  1495                          "| rebase one of them next to the other and run \n"
  1495                          "| this command again.\n"
  1496                          "| this command again.\n"
  1496                          "| - either: hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1497                          "| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n"
  1497                          "| - or:     hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1498                          "| - or:     hg rebase --dest 'p1(%(o)s)' -r %(d)s"
  1498                               % {'d': divergent, 'o': other})
  1499                               % {'d': divergent, 'o': other})
  1499 
  1500 
  1500     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1501     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1501     if not ui.quiet or confirm:
  1502     if not ui.quiet or confirm:
  1502         ui.write(_('merge:'))
  1503         ui.write(_('merge:'))