Mercurial > hg
comparison mercurial/exchange.py @ 20489:7b5ec1c7e8e2
pull: move changeset pulling in its own function
pull: move changeset pulling in its own function
Now that every necessary information is held in the `pulloperation` object, we
can finally extract the changeset pulling to it's own function.
This changeset is pure code movement only.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 31 Jan 2014 01:39:59 -0800 |
parents | 76e66654f74e |
children | 004a1744088d |
comparison
equal
deleted
inserted
replaced
20488:76e66654f74e | 20489:7b5ec1c7e8e2 |
---|---|
450 pullop.common, pullop.fetch, pullop.rheads = tmp | 450 pullop.common, pullop.fetch, pullop.rheads = tmp |
451 if not pullop.fetch: | 451 if not pullop.fetch: |
452 pullop.repo.ui.status(_("no changes found\n")) | 452 pullop.repo.ui.status(_("no changes found\n")) |
453 result = 0 | 453 result = 0 |
454 else: | 454 else: |
455 # We delay the open of the transaction as late as possible so we | 455 result = _pullchangeset(pullop) |
456 # don't open transaction for nothing or you break future useful | |
457 # rollback call | |
458 pullop.gettransaction() | |
459 if pullop.heads is None and list(pullop.common) == [nullid]: | |
460 pullop.repo.ui.status(_("requesting all changes\n")) | |
461 elif (pullop.heads is None | |
462 and pullop.remote.capable('changegroupsubset')): | |
463 # issue1320, avoid a race if remote changed after discovery | |
464 pullop.heads = pullop.rheads | |
465 | |
466 if pullop.remote.capable('getbundle'): | |
467 # TODO: get bundlecaps from remote | |
468 cg = pullop.remote.getbundle('pull', | |
469 common=pullop.common, | |
470 heads=(pullop.heads | |
471 or pullop.rheads)) | |
472 elif pullop.heads is None: | |
473 cg = pullop.remote.changegroup(pullop.fetch, 'pull') | |
474 elif not pullop.remote.capable('changegroupsubset'): | |
475 raise util.Abort(_("partial pull cannot be done because " | |
476 "other repository doesn't support " | |
477 "changegroupsubset.")) | |
478 else: | |
479 cg = pullop.remote.changegroupsubset(pullop.fetch, | |
480 pullop.heads, | |
481 'pull') | |
482 result = pullop.repo.addchangegroup(cg, 'pull', | |
483 pullop.remote.url()) | |
484 | 456 |
485 _pullphase(pullop) | 457 _pullphase(pullop) |
486 _pullobsolete(pullop) | 458 _pullobsolete(pullop) |
487 pullop.closetransaction() | 459 pullop.closetransaction() |
488 finally: | 460 finally: |
489 pullop.releasetransaction() | 461 pullop.releasetransaction() |
490 lock.release() | 462 lock.release() |
491 | 463 |
492 return result | 464 return result |
465 | |
466 def _pullchangeset(pullop): | |
467 """pull changeset from unbundle into the local repo""" | |
468 # We delay the open of the transaction as late as possible so we | |
469 # don't open transaction for nothing or you break future useful | |
470 # rollback call | |
471 pullop.gettransaction() | |
472 if pullop.heads is None and list(pullop.common) == [nullid]: | |
473 pullop.repo.ui.status(_("requesting all changes\n")) | |
474 elif pullop.heads is None and pullop.remote.capable('changegroupsubset'): | |
475 # issue1320, avoid a race if remote changed after discovery | |
476 pullop.heads = pullop.rheads | |
477 | |
478 if pullop.remote.capable('getbundle'): | |
479 # TODO: get bundlecaps from remote | |
480 cg = pullop.remote.getbundle('pull', common=pullop.common, | |
481 heads=pullop.heads or pullop.rheads) | |
482 elif pullop.heads is None: | |
483 cg = pullop.remote.changegroup(pullop.fetch, 'pull') | |
484 elif not pullop.remote.capable('changegroupsubset'): | |
485 raise util.Abort(_("partial pull cannot be done because " | |
486 "other repository doesn't support " | |
487 "changegroupsubset.")) | |
488 else: | |
489 cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') | |
490 return pullop.repo.addchangegroup(cg, 'pull', pullop.remote.url()) | |
493 | 491 |
494 def _pullphase(pullop): | 492 def _pullphase(pullop): |
495 # Get remote phases data from remote | 493 # Get remote phases data from remote |
496 remotephases = pullop.remote.listkeys('phases') | 494 remotephases = pullop.remote.listkeys('phases') |
497 publishing = bool(remotephases.get('publishing', False)) | 495 publishing = bool(remotephases.get('publishing', False)) |