mercurial/exchange.py
changeset 35268 44b8b5ad30eb
parent 35267 cb4dcd7fabe7
child 35305 483b5dd0f1aa
equal deleted inserted replaced
35267:cb4dcd7fabe7 35268:44b8b5ad30eb
  1467     hasbinaryphase = 'heads' in pullop.remotebundle2caps.get('phases', ())
  1467     hasbinaryphase = 'heads' in pullop.remotebundle2caps.get('phases', ())
  1468     if (not legacyphase and hasbinaryphase):
  1468     if (not legacyphase and hasbinaryphase):
  1469         kwargs['phases'] = True
  1469         kwargs['phases'] = True
  1470         pullop.stepsdone.add('phases')
  1470         pullop.stepsdone.add('phases')
  1471 
  1471 
       
  1472     bookmarksrequested = False
       
  1473     legacybookmark = 'bookmarks' in ui.configlist('devel', 'legacy.exchange')
       
  1474     hasbinarybook = 'bookmarks' in pullop.remotebundle2caps
       
  1475 
       
  1476     if pullop.remotebookmarks is not None:
       
  1477         pullop.stepsdone.add('request-bookmarks')
       
  1478 
       
  1479     if ('request-bookmarks' not in pullop.stepsdone
       
  1480         and pullop.remotebookmarks is None
       
  1481         and not legacybookmark and hasbinarybook):
       
  1482         kwargs['bookmarks'] = True
       
  1483         bookmarksrequested = True
       
  1484 
  1472     if 'listkeys' in pullop.remotebundle2caps:
  1485     if 'listkeys' in pullop.remotebundle2caps:
  1473         if 'phases' not in pullop.stepsdone:
  1486         if 'phases' not in pullop.stepsdone:
  1474             kwargs['listkeys'] = ['phases']
  1487             kwargs['listkeys'] = ['phases']
  1475         if pullop.remotebookmarks is None:
  1488         if 'request-bookmarks' not in pullop.stepsdone:
  1476             # make sure to always includes bookmark data when migrating
  1489             # make sure to always includes bookmark data when migrating
  1477             # `hg incoming --bundle` to using this function.
  1490             # `hg incoming --bundle` to using this function.
       
  1491             pullop.stepsdone.add('request-bookmarks')
  1478             kwargs.setdefault('listkeys', []).append('bookmarks')
  1492             kwargs.setdefault('listkeys', []).append('bookmarks')
  1479 
  1493 
  1480     # If this is a full pull / clone and the server supports the clone bundles
  1494     # If this is a full pull / clone and the server supports the clone bundles
  1481     # feature, tell the server whether we attempted a clone bundle. The
  1495     # feature, tell the server whether we attempted a clone bundle. The
  1482     # presence of this flag indicates the client supports clone bundles. This
  1496     # presence of this flag indicates the client supports clone bundles. This
  1500             kwargs['obsmarkers'] = True
  1514             kwargs['obsmarkers'] = True
  1501             pullop.stepsdone.add('obsmarkers')
  1515             pullop.stepsdone.add('obsmarkers')
  1502     _pullbundle2extraprepare(pullop, kwargs)
  1516     _pullbundle2extraprepare(pullop, kwargs)
  1503     bundle = pullop.remote.getbundle('pull', **pycompat.strkwargs(kwargs))
  1517     bundle = pullop.remote.getbundle('pull', **pycompat.strkwargs(kwargs))
  1504     try:
  1518     try:
  1505         op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
  1519         op = bundle2.bundleoperation(pullop.repo, pullop.gettransaction)
       
  1520         op.modes['bookmarks'] = 'records'
       
  1521         bundle2.processbundle(pullop.repo, bundle, op=op)
  1506     except bundle2.AbortFromPart as exc:
  1522     except bundle2.AbortFromPart as exc:
  1507         pullop.repo.ui.status(_('remote: abort: %s\n') % exc)
  1523         pullop.repo.ui.status(_('remote: abort: %s\n') % exc)
  1508         raise error.Abort(_('pull failed on remote'), hint=exc.hint)
  1524         raise error.Abort(_('pull failed on remote'), hint=exc.hint)
  1509     except error.BundleValueError as exc:
  1525     except error.BundleValueError as exc:
  1510         raise error.Abort(_('missing support for %s') % exc)
  1526         raise error.Abort(_('missing support for %s') % exc)
  1516     for namespace, value in op.records['listkeys']:
  1532     for namespace, value in op.records['listkeys']:
  1517         if namespace == 'phases':
  1533         if namespace == 'phases':
  1518             _pullapplyphases(pullop, value)
  1534             _pullapplyphases(pullop, value)
  1519 
  1535 
  1520     # processing bookmark update
  1536     # processing bookmark update
  1521     for namespace, value in op.records['listkeys']:
  1537     if bookmarksrequested:
  1522         if namespace == 'bookmarks':
  1538         books = {}
  1523             pullop.remotebookmarks = bookmod.unhexlifybookmarks(value)
  1539         for record in op.records['bookmarks']:
       
  1540             books[record['bookmark']] = record["node"]
       
  1541         pullop.remotebookmarks = books
       
  1542     else:
       
  1543         for namespace, value in op.records['listkeys']:
       
  1544             if namespace == 'bookmarks':
       
  1545                 pullop.remotebookmarks = bookmod.unhexlifybookmarks(value)
  1524 
  1546 
  1525     # bookmark data were either already there or pulled in the bundle
  1547     # bookmark data were either already there or pulled in the bundle
  1526     if pullop.remotebookmarks is not None:
  1548     if pullop.remotebookmarks is not None:
  1527         _pullbookmarks(pullop)
  1549         _pullbookmarks(pullop)
  1528 
  1550