hgext3rd/evolve/__init__.py
changeset 3373 3ff0da45d4c7
parent 3369 c7fbb79cd366
child 3374 612b3bd31499
equal deleted inserted replaced
3372:4138771105bb 3373:3ff0da45d4c7
   322     safeguard,
   322     safeguard,
   323     templatekw,
   323     templatekw,
   324     utility,
   324     utility,
   325 )
   325 )
   326 
   326 
       
   327 TROUBLES = compat.TROUBLES
   327 __version__ = metadata.__version__
   328 __version__ = metadata.__version__
   328 testedwith = metadata.testedwith
   329 testedwith = metadata.testedwith
   329 minimumhgversion = metadata.minimumhgversion
   330 minimumhgversion = metadata.minimumhgversion
   330 buglink = metadata.buglink
   331 buglink = metadata.buglink
   331 
   332 
  1368         fm.plain('%s: ' % ctx.hex()[:hashlen])
  1369         fm.plain('%s: ' % ctx.hex()[:hashlen])
  1369         fm.plain('%s\n' % desc)
  1370         fm.plain('%s\n' % desc)
  1370         fm.data(node=ctx.hex(), rev=ctx.rev(), desc=desc, phase=ctx.phasestr())
  1371         fm.data(node=ctx.hex(), rev=ctx.rev(), desc=desc, phase=ctx.phasestr())
  1371 
  1372 
  1372         for unpar in unpars if showunstable else []:
  1373         for unpar in unpars if showunstable else []:
  1373             fm.plain('  orphan: %s (orphan parent)\n' % unpar[:hashlen])
  1374             fm.plain('  %s: %s (%s parent)\n' % (TROUBLES['ORPHAN'],
       
  1375                                                  unpar[:hashlen],
       
  1376                                                  TROUBLES['ORPHAN']))
  1374         for obspar in obspars if showunstable else []:
  1377         for obspar in obspars if showunstable else []:
  1375             fm.plain('  unstable: %s (obsolete parent)\n' % obspar[:hashlen])
  1378             fm.plain('  %s: %s (obsolete parent)\n' % (TROUBLES['ORPHAN'],
       
  1379                                                        obspar[:hashlen]))
  1376         for imprec in imprecs if showbumped else []:
  1380         for imprec in imprecs if showbumped else []:
  1377             fm.plain('  bumped: %s (immutable precursor)\n' % imprec[:hashlen])
  1381             fm.plain('  %s: %s (immutable precursor)\n' %
       
  1382                      (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen]))
  1378 
  1383 
  1379         if dsets and showdivergent:
  1384         if dsets and showdivergent:
  1380             for dset in dsets:
  1385             for dset in dsets:
  1381                 fm.plain('  divergent: ')
  1386                 fm.plain('  %s: ' % TROUBLES['CONTENTDIVERGENT'])
  1382                 first = True
  1387                 first = True
  1383                 for n in dset['divergentnodes']:
  1388                 for n in dset['divergentnodes']:
  1384                     t = "%s (%s)" if first else " %s (%s)"
  1389                     t = "%s (%s)" if first else " %s (%s)"
  1385                     first = False
  1390                     first = False
  1386                     fm.plain(t % (node.hex(n)[:hashlen], repo[n].phasestr()))
  1391                     fm.plain(t % (node.hex(n)[:hashlen], repo[n].phasestr()))
  1390 
  1395 
  1391         # templater-friendly section
  1396         # templater-friendly section
  1392         _formatctx(fm, ctx)
  1397         _formatctx(fm, ctx)
  1393         troubles = []
  1398         troubles = []
  1394         for unpar in unpars:
  1399         for unpar in unpars:
  1395             troubles.append({'troubletype': 'unstable', 'sourcenode': unpar,
  1400             troubles.append({'troubletype': TROUBLES['ORPHAN'],
  1396                              'sourcetype': 'unstableparent'})
  1401                              'sourcenode': unpar, 'sourcetype': 'orphanparent'})
  1397         for obspar in obspars:
  1402         for obspar in obspars:
  1398             troubles.append({'troubletype': 'unstable', 'sourcenode': obspar,
  1403             troubles.append({'troubletype': TROUBLES['ORPHAN'],
       
  1404                              'sourcenode': obspar,
  1399                              'sourcetype': 'obsoleteparent'})
  1405                              'sourcetype': 'obsoleteparent'})
  1400         for imprec in imprecs:
  1406         for imprec in imprecs:
  1401             troubles.append({'troubletype': 'bumped', 'sourcenode': imprec,
  1407             troubles.append({'troubletype': TROUBLES['PHASEDIVERGENT'],
       
  1408                              'sourcenode': imprec,
  1402                              'sourcetype': 'immutableprecursor'})
  1409                              'sourcetype': 'immutableprecursor'})
  1403         for dset in dsets:
  1410         for dset in dsets:
  1404             divnodes = [{'node': node.hex(n),
  1411             divnodes = [{'node': node.hex(n),
  1405                          'phase': repo[n].phasestr(),
  1412                          'phase': repo[n].phasestr(),
  1406                         } for n in dset['divergentnodes']]
  1413                         } for n in dset['divergentnodes']]
  1407             troubles.append({'troubletype': 'divergent',
  1414             troubles.append({'troubletype': TROUBLES['CONTENTDIVERGENT'],
  1408                              'commonprecursor': node.hex(dset['commonprecursor']),
  1415                              'commonprecursor': node.hex(dset['commonprecursor']),
  1409                              'divergentnodes': divnodes})
  1416                              'divergentnodes': divnodes})
  1410         fm.data(troubles=troubles)
  1417         fm.data(troubles=troubles)
  1411 
  1418 
  1412     fm.end()
  1419     fm.end()
  1793     if dryrun:
  1800     if dryrun:
  1794         todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1())
  1801         todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1())
  1795         repo.ui.write(todo)
  1802         repo.ui.write(todo)
  1796         repo.ui.write(('hg update %s;\n' % prec))
  1803         repo.ui.write(('hg update %s;\n' % prec))
  1797         repo.ui.write(('hg revert --all --rev %s;\n' % bumped))
  1804         repo.ui.write(('hg revert --all --rev %s;\n' % bumped))
  1798         repo.ui.write(('hg commit --msg "bumped update to %s"'))
  1805         repo.ui.write(('hg commit --msg "%s update to %s"\n' %
       
  1806                        (TROUBLES['PHASEDIVERGENT'], bumped)))
  1799         return 0
  1807         return 0
  1800     if progresscb:
  1808     if progresscb:
  1801         progresscb()
  1809         progresscb()
  1802     newid = tmpctx = None
  1810     newid = tmpctx = None
  1803     tmpctx = bumped
  1811     tmpctx = bumped
  1875     repo = repo.unfiltered()
  1883     repo = repo.unfiltered()
  1876     divergent = repo[divergent.rev()]
  1884     divergent = repo[divergent.rev()]
  1877     base, others = divergentdata(divergent)
  1885     base, others = divergentdata(divergent)
  1878     if len(others) > 1:
  1886     if len(others) > 1:
  1879         othersstr = "[%s]" % (','.join([str(i) for i in others]))
  1887         othersstr = "[%s]" % (','.join([str(i) for i in others]))
  1880         msg = _("skipping %d:divergent with a changeset that got split"
  1888         msg = _("skipping %d:%s with a changeset that got split"
  1881                 " into multiple ones:\n"
  1889                 " into multiple ones:\n"
  1882                 "|[%s]\n"
  1890                 "|[%s]\n"
  1883                 "| This is not handled by automatic evolution yet\n"
  1891                 "| This is not handled by automatic evolution yet\n"
  1884                 "| You have to fallback to manual handling with commands "
  1892                 "| You have to fallback to manual handling with commands "
  1885                 "such as:\n"
  1893                 "such as:\n"
  1886                 "| - hg touch -D\n"
  1894                 "| - hg touch -D\n"
  1887                 "| - hg prune\n"
  1895                 "| - hg prune\n"
  1888                 "| \n"
  1896                 "| \n"
  1889                 "| You should contact your local evolution Guru for help.\n"
  1897                 "| You should contact your local evolution Guru for help.\n"
  1890                 ) % (divergent, othersstr)
  1898                 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr)
  1891         ui.write_err(msg)
  1899         ui.write_err(msg)
  1892         return 2
  1900         return 2
  1893     other = others[0]
  1901     other = others[0]
  1894     if len(other.parents()) > 1:
  1902     if len(other.parents()) > 1:
  1895         msg = _("skipping %s: divergent changeset can't be "
  1903         msg = _("skipping %s: %s changeset can't be "
  1896                 "a merge (yet)\n") % divergent
  1904                 "a merge (yet)\n") % (divergent, TROUBLES['CONTENTDIVERGENT'])
  1897         ui.write_err(msg)
  1905         ui.write_err(msg)
  1898         hint = _("You have to fallback to solving this by hand...\n"
  1906         hint = _("You have to fallback to solving this by hand...\n"
  1899                  "| This probably means redoing the merge and using \n"
  1907                  "| This probably means redoing the merge and using \n"
  1900                  "| `hg prune` to kill older version.\n")
  1908                  "| `hg prune` to kill older version.\n")
  1901         ui.write_err(hint)
  1909         ui.write_err(hint)
  1936                  % divergent))
  1944                  % divergent))
  1937         return
  1945         return
  1938     if divergent not in repo[None].parents():
  1946     if divergent not in repo[None].parents():
  1939         repo.ui.status(_('updating to "local" conflict\n'))
  1947         repo.ui.status(_('updating to "local" conflict\n'))
  1940         hg.update(repo, divergent.rev())
  1948         hg.update(repo, divergent.rev())
  1941     repo.ui.note(_('merging divergent changeset\n'))
  1949     repo.ui.note(_('merging %s changeset\n') % TROUBLES['CONTENTDIVERGENT'])
  1942     if progresscb:
  1950     if progresscb:
  1943         progresscb()
  1951         progresscb()
  1944     stats = merge.update(repo,
  1952     stats = merge.update(repo,
  1945                          other.node(),
  1953                          other.node(),
  1946                          branchmerge=True,
  1954                          branchmerge=True,