hgext/evolve.py
changeset 1069 356552e55489
parent 1068 9f87b103f7b5
child 1070 527b12a59628
equal deleted inserted replaced
1068:9f87b103f7b5 1069:356552e55489
    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 testedwith = '3.0.1 3.1'
    22 testedwith = ''
    23 buglink = 'http://bz.selenic.com/'
    23 buglink = 'http://bz.selenic.com/'
    24 
    24 
    25 import sys
    25 import sys
    26 import random
    26 import random
    27 from StringIO import StringIO
    27 from StringIO import StringIO
    90 #
    90 #
    91 # - Extension Helper code
    91 # - Extension Helper code
    92 # - Obsolescence cache
    92 # - Obsolescence cache
    93 # - ...
    93 # - ...
    94 # - Older format compat
    94 # - Older format compat
    95 
       
    96 
       
    97 #####################################################################
       
    98 ### Compatibility with core                                       ###
       
    99 #####################################################################
       
   100 
       
   101 
       
   102 def retractboundary(repo, tr, targetphase, nodes):
       
   103     """Older mercurial version does not move phase within a transaction"""
       
   104     try:
       
   105         return phases.retractboundary(repo, tr, targetphase, nodes)
       
   106     except TypeError:
       
   107         return phases.retractboundary(repo, targetphase, nodes)
       
   108 
    95 
   109 
    96 
   110 #####################################################################
    97 #####################################################################
   111 ### Extension helper                                              ###
    98 ### Extension helper                                              ###
   112 #####################################################################
    99 #####################################################################
   907                 pass
   894                 pass
   908             exc.__class__ = LocalMergeFailure
   895             exc.__class__ = LocalMergeFailure
   909             raise
   896             raise
   910         oldbookmarks = repo.nodebookmarks(nodesrc)
   897         oldbookmarks = repo.nodebookmarks(nodesrc)
   911         if nodenew is not None:
   898         if nodenew is not None:
   912             retractboundary(repo, tr, destphase, [nodenew])
   899             phases.retractboundary(repo, tr, destphase, [nodenew])
   913             createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
   900             createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
   914             for book in oldbookmarks:
   901             for book in oldbookmarks:
   915                 repo._bookmarks[book] = nodenew
   902                 repo._bookmarks[book] = nodenew
   916         else:
   903         else:
   917             createmarkers(repo, [(repo[nodesrc], ())])
   904             createmarkers(repo, [(repo[nodesrc], ())])
  1512             newid = repo.commitctx(new)
  1499             newid = repo.commitctx(new)
  1513         if newid is None:
  1500         if newid is None:
  1514             createmarkers(repo, [(tmpctx, ())])
  1501             createmarkers(repo, [(tmpctx, ())])
  1515             newid = prec.node()
  1502             newid = prec.node()
  1516         else:
  1503         else:
  1517             retractboundary(repo, tr, bumped.phase(), [newid])
  1504             phases.retractboundary(repo, tr, bumped.phase(), [newid])
  1518             createmarkers(repo, [(tmpctx, (repo[newid],))],
  1505             createmarkers(repo, [(tmpctx, (repo[newid],))],
  1519                                    flag=obsolete.bumpedfix)
  1506                                    flag=obsolete.bumpedfix)
  1520         bmupdate(newid)
  1507         bmupdate(newid)
  1521         tr.close()
  1508         tr.close()
  1522         repo.ui.status(_('committed as %s\n') % node.short(newid))
  1509         repo.ui.status(_('committed as %s\n') % node.short(newid))
  1618             new = divergent
  1605             new = divergent
  1619             # no changes
  1606             # no changes
  1620         else:
  1607         else:
  1621             new = repo['.']
  1608             new = repo['.']
  1622         createmarkers(repo, [(other, (new,))])
  1609         createmarkers(repo, [(other, (new,))])
  1623         retractboundary(repo, tr, other.phase(), [new.node()])
  1610         phases.retractboundary(repo, tr, other.phase(), [new.node()])
  1624         tr.close()
  1611         tr.close()
  1625     finally:
  1612     finally:
  1626         tr.release()
  1613         tr.release()
  1627 
  1614 
  1628 def divergentdata(ctx):
  1615 def divergentdata(ctx):
  2049         if newid is None:
  2036         if newid is None:
  2050             raise util.Abort(_('nothing to uncommit'),
  2037             raise util.Abort(_('nothing to uncommit'),
  2051                              hint=_("use --all to uncommit all files"))
  2038                              hint=_("use --all to uncommit all files"))
  2052         # Move local changes on filtered changeset
  2039         # Move local changes on filtered changeset
  2053         createmarkers(repo, [(old, (repo[newid],))])
  2040         createmarkers(repo, [(old, (repo[newid],))])
  2054         retractboundary(repo, tr, oldphase, [newid])
  2041         phases.retractboundary(repo, tr, oldphase, [newid])
  2055         repo.dirstate.setparents(newid, node.nullid)
  2042         repo.dirstate.setparents(newid, node.nullid)
  2056         _uncommitdirstate(repo, old, match)
  2043         _uncommitdirstate(repo, old, match)
  2057         updatebookmarks(newid)
  2044         updatebookmarks(newid)
  2058         if not repo[newid].files():
  2045         if not repo[newid].files():
  2059             ui.warn(_("new changeset is empty\n"))
  2046             ui.warn(_("new changeset is empty\n"))
  2135                                               commitopts={'extra': extra})
  2122                                               commitopts={'extra': extra})
  2136                 # store touched version to help potential children
  2123                 # store touched version to help potential children
  2137                 newmapping[ctx.node()] = new
  2124                 newmapping[ctx.node()] = new
  2138                 if not duplicate:
  2125                 if not duplicate:
  2139                     createmarkers(repo, [(ctx, (repo[new],))])
  2126                     createmarkers(repo, [(ctx, (repo[new],))])
  2140                 retractboundary(repo, tr, ctx.phase(), [new])
  2127                 phases.retractboundary(repo, tr, ctx.phase(), [new])
  2141                 if ctx in repo[None].parents():
  2128                 if ctx in repo[None].parents():
  2142                     repo.dirstate.setparents(new, node.nullid)
  2129                     repo.dirstate.setparents(new, node.nullid)
  2143             tr.close()
  2130             tr.close()
  2144         finally:
  2131         finally:
  2145             tr.release()
  2132             tr.release()
  2238                 commitopts['edit'] = True
  2225                 commitopts['edit'] = True
  2239 
  2226 
  2240             newid, unusedvariable = rewrite(repo, root, allctx, head,
  2227             newid, unusedvariable = rewrite(repo, root, allctx, head,
  2241                                             [root.p1().node(), root.p2().node()],
  2228                                             [root.p1().node(), root.p2().node()],
  2242                                             commitopts=commitopts)
  2229                                             commitopts=commitopts)
  2243             retractboundary(repo, tr, targetphase, [newid])
  2230             phases.retractboundary(repo, tr, targetphase, [newid])
  2244             createmarkers(repo, [(ctx, (repo[newid],))
  2231             createmarkers(repo, [(ctx, (repo[newid],))
  2245                                  for ctx in allctx])
  2232                                  for ctx in allctx])
  2246             tr.close()
  2233             tr.close()
  2247         finally:
  2234         finally:
  2248             tr.release()
  2235             tr.release()