comparison mercurial/exchange.py @ 20901:a26dfa7f534c

pull: add a set of steps that remain to be done during the pull With bundle2 we'll slowly move current steps into a single bundle2 building and call (changegroup, phases, obsmarkers, bookmarks). But we need to keep the old methods around for servers that do not support bundle2. So we introduce this set of steps that remains to be done.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 01 Apr 2014 18:56:19 -0700
parents cb37fb91bc5a
children e10000369b47
comparison
equal deleted inserted replaced
20900:cb37fb91bc5a 20901:a26dfa7f534c
401 self.rheads = None 401 self.rheads = None
402 # list of missing changeset to fetch remotly 402 # list of missing changeset to fetch remotly
403 self.fetch = None 403 self.fetch = None
404 # result of changegroup pulling (used as returng code by pull) 404 # result of changegroup pulling (used as returng code by pull)
405 self.cgresult = None 405 self.cgresult = None
406 # list of step remaining todo (related to future bundle2 usage)
407 self.todosteps = set(['changegroup', 'phases', 'obsmarkers'])
406 408
407 @util.propertycache 409 @util.propertycache
408 def pulledsubset(self): 410 def pulledsubset(self):
409 """heads of the set of changeset target by the pull""" 411 """heads of the set of changeset target by the pull"""
410 # compute target subset 412 # compute target subset
449 raise util.Abort(msg) 451 raise util.Abort(msg)
450 452
451 lock = pullop.repo.lock() 453 lock = pullop.repo.lock()
452 try: 454 try:
453 _pulldiscovery(pullop) 455 _pulldiscovery(pullop)
454 _pullchangeset(pullop) 456 if 'changegroup' in pullop.todosteps:
455 _pullphase(pullop) 457 _pullchangeset(pullop)
456 _pullobsolete(pullop) 458 if 'phases' in pullop.todosteps:
459 _pullphase(pullop)
460 if 'obsmarkers' in pullop.todosteps:
461 _pullobsolete(pullop)
457 pullop.closetransaction() 462 pullop.closetransaction()
458 finally: 463 finally:
459 pullop.releasetransaction() 464 pullop.releasetransaction()
460 lock.release() 465 lock.release()
461 466
475 def _pullchangeset(pullop): 480 def _pullchangeset(pullop):
476 """pull changeset from unbundle into the local repo""" 481 """pull changeset from unbundle into the local repo"""
477 # We delay the open of the transaction as late as possible so we 482 # We delay the open of the transaction as late as possible so we
478 # don't open transaction for nothing or you break future useful 483 # don't open transaction for nothing or you break future useful
479 # rollback call 484 # rollback call
485 pullop.todosteps.remove('changegroup')
480 if not pullop.fetch: 486 if not pullop.fetch:
481 pullop.repo.ui.status(_("no changes found\n")) 487 pullop.repo.ui.status(_("no changes found\n"))
482 pullop.cgresult = 0 488 pullop.cgresult = 0
483 return 489 return
484 pullop.gettransaction() 490 pullop.gettransaction()
503 pullop.cgresult = pullop.repo.addchangegroup(cg, 'pull', 509 pullop.cgresult = pullop.repo.addchangegroup(cg, 'pull',
504 pullop.remote.url()) 510 pullop.remote.url())
505 511
506 def _pullphase(pullop): 512 def _pullphase(pullop):
507 # Get remote phases data from remote 513 # Get remote phases data from remote
514 pullop.todosteps.remove('phases')
508 remotephases = pullop.remote.listkeys('phases') 515 remotephases = pullop.remote.listkeys('phases')
509 publishing = bool(remotephases.get('publishing', False)) 516 publishing = bool(remotephases.get('publishing', False))
510 if remotephases and not publishing: 517 if remotephases and not publishing:
511 # remote is new and unpublishing 518 # remote is new and unpublishing
512 pheads, _dr = phases.analyzeremotephases(pullop.repo, 519 pheads, _dr = phases.analyzeremotephases(pullop.repo,
527 The `gettransaction` is function that return the pull transaction, creating 534 The `gettransaction` is function that return the pull transaction, creating
528 one if necessary. We return the transaction to inform the calling code that 535 one if necessary. We return the transaction to inform the calling code that
529 a new transaction have been created (when applicable). 536 a new transaction have been created (when applicable).
530 537
531 Exists mostly to allow overriding for experimentation purpose""" 538 Exists mostly to allow overriding for experimentation purpose"""
539 pullop.todosteps.remove('obsmarkers')
532 tr = None 540 tr = None
533 if obsolete._enabled: 541 if obsolete._enabled:
534 pullop.repo.ui.debug('fetching remote obsolete markers\n') 542 pullop.repo.ui.debug('fetching remote obsolete markers\n')
535 remoteobs = pullop.remote.listkeys('obsolete') 543 remoteobs = pullop.remote.listkeys('obsolete')
536 if 'dump0' in remoteobs: 544 if 'dump0' in remoteobs: