comparison mercurial/exchange.py @ 22242:ed222ebd61be

push: add bookmarks to the unified bundle2 push We use the `pushkey` part to exchange bookmark updates within the unified bundle2 push. Note that this only applies on update (moving a bookmark known on both sides) since bookmark export (creation of a new bookmark on remote) is apparently done outside of the _push function.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 15 Aug 2014 19:03:42 -0700
parents d092f4b68fb6
children 728669a41947
comparison
equal deleted inserted replaced
22241:3dc3cf8d0e73 22242:ed222ebd61be
420 msg = _('updating %s to public failed!\n') % node 420 msg = _('updating %s to public failed!\n') % node
421 if msg is not None: 421 if msg is not None:
422 pushop.ui.warn(msg) 422 pushop.ui.warn(msg)
423 return handlereply 423 return handlereply
424 424
425 @b2partsgenerator('bookmarks')
426 def _pushb2bookmarks(pushop, bundler):
427 """handle phase push through bundle2"""
428 if 'bookmarks' in pushop.stepsdone:
429 return
430 b2caps = bundle2.bundle2caps(pushop.remote)
431 if 'b2x:pushkey' not in b2caps:
432 return
433 pushop.stepsdone.add('bookmarks')
434 part2book = []
435 enc = pushkey.encode
436 for book, old, new in pushop.outbookmarks:
437 part = bundler.newpart('b2x:pushkey')
438 part.addparam('namespace', enc('bookmarks'))
439 part.addparam('key', enc(book))
440 part.addparam('old', enc(old))
441 part.addparam('new', enc(new))
442 part2book.append((part.id, book))
443 def handlereply(op):
444 for partid, book in part2book:
445 partrep = op.records.getreplies(partid)
446 results = partrep['pushkey']
447 assert len(results) <= 1
448 if not results:
449 pushop.ui.warn(_('server ignored bookmark %s update\n') % book)
450 else:
451 ret = int(results[0]['return'])
452 if ret:
453 pushop.ui.status(_("updating bookmark %s\n") % book)
454 else:
455 pushop.ui.warn(_('updating bookmark %s failed!\n') % book)
456 return handlereply
457
458
425 def _pushbundle2(pushop): 459 def _pushbundle2(pushop):
426 """push data to the remote using bundle2 460 """push data to the remote using bundle2
427 461
428 The only currently supported type of data is changegroup but this will 462 The only currently supported type of data is changegroup but this will
429 evolve in the future.""" 463 evolve in the future."""