Show More
@@ -492,9 +492,9 b' class bundletransactionmanager(object):' | |||||
492 | def release(self): |
|
492 | def release(self): | |
493 | raise NotImplementedError |
|
493 | raise NotImplementedError | |
494 |
|
494 | |||
495 |
def getremotechanges(ui, repo, |
|
495 | def getremotechanges(ui, repo, peer, onlyheads=None, bundlename=None, | |
496 | force=False): |
|
496 | force=False): | |
497 |
'''obtains a bundle of changes incoming from |
|
497 | '''obtains a bundle of changes incoming from peer | |
498 |
|
498 | |||
499 | "onlyheads" restricts the returned changes to those reachable from the |
|
499 | "onlyheads" restricts the returned changes to those reachable from the | |
500 | specified heads. |
|
500 | specified heads. | |
@@ -507,13 +507,13 b' def getremotechanges(ui, repo, other, on' | |||||
507 |
|
507 | |||
508 | "local" is a local repo from which to obtain the actual incoming |
|
508 | "local" is a local repo from which to obtain the actual incoming | |
509 | changesets; it is a bundlerepo for the obtained bundle when the |
|
509 | changesets; it is a bundlerepo for the obtained bundle when the | |
510 |
original " |
|
510 | original "peer" is remote. | |
511 | "csets" lists the incoming changeset node ids. |
|
511 | "csets" lists the incoming changeset node ids. | |
512 | "cleanupfn" must be called without arguments when you're done processing |
|
512 | "cleanupfn" must be called without arguments when you're done processing | |
513 |
the changes; it closes both the original " |
|
513 | the changes; it closes both the original "peer" and the one returned | |
514 | here. |
|
514 | here. | |
515 | ''' |
|
515 | ''' | |
516 |
tmp = discovery.findcommonincoming(repo, |
|
516 | tmp = discovery.findcommonincoming(repo, peer, heads=onlyheads, | |
517 | force=force) |
|
517 | force=force) | |
518 | common, incoming, rheads = tmp |
|
518 | common, incoming, rheads = tmp | |
519 | if not incoming: |
|
519 | if not incoming: | |
@@ -522,39 +522,39 b' def getremotechanges(ui, repo, other, on' | |||||
522 | os.unlink(bundlename) |
|
522 | os.unlink(bundlename) | |
523 | except OSError: |
|
523 | except OSError: | |
524 | pass |
|
524 | pass | |
525 |
return repo, [], |
|
525 | return repo, [], peer.close | |
526 |
|
526 | |||
527 | commonset = set(common) |
|
527 | commonset = set(common) | |
528 | rheads = [x for x in rheads if x not in commonset] |
|
528 | rheads = [x for x in rheads if x not in commonset] | |
529 |
|
529 | |||
530 | bundle = None |
|
530 | bundle = None | |
531 | bundlerepo = None |
|
531 | bundlerepo = None | |
532 |
localrepo = |
|
532 | localrepo = peer.local() | |
533 | if bundlename or not localrepo: |
|
533 | if bundlename or not localrepo: | |
534 |
# create a bundle (uncompressed if |
|
534 | # create a bundle (uncompressed if peer repo is not local) | |
535 |
|
535 | |||
536 | # developer config: devel.legacy.exchange |
|
536 | # developer config: devel.legacy.exchange | |
537 | legexc = ui.configlist('devel', 'legacy.exchange') |
|
537 | legexc = ui.configlist('devel', 'legacy.exchange') | |
538 | forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc |
|
538 | forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc | |
539 | canbundle2 = (not forcebundle1 |
|
539 | canbundle2 = (not forcebundle1 | |
540 |
and |
|
540 | and peer.capable('getbundle') | |
541 |
and |
|
541 | and peer.capable('bundle2')) | |
542 | if canbundle2: |
|
542 | if canbundle2: | |
543 | kwargs = {} |
|
543 | kwargs = {} | |
544 | kwargs[r'common'] = common |
|
544 | kwargs[r'common'] = common | |
545 | kwargs[r'heads'] = rheads |
|
545 | kwargs[r'heads'] = rheads | |
546 | kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client') |
|
546 | kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client') | |
547 | kwargs[r'cg'] = True |
|
547 | kwargs[r'cg'] = True | |
548 |
b2 = |
|
548 | b2 = peer.getbundle('incoming', **kwargs) | |
549 | fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), |
|
549 | fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), | |
550 | bundlename) |
|
550 | bundlename) | |
551 | else: |
|
551 | else: | |
552 |
if |
|
552 | if peer.capable('getbundle'): | |
553 |
cg = |
|
553 | cg = peer.getbundle('incoming', common=common, heads=rheads) | |
554 |
elif onlyheads is None and not |
|
554 | elif onlyheads is None and not peer.capable('changegroupsubset'): | |
555 | # compat with older servers when pulling all remote heads |
|
555 | # compat with older servers when pulling all remote heads | |
556 |
|
556 | |||
557 |
with |
|
557 | with peer.commandexecutor() as e: | |
558 | cg = e.callcommand('changegroup', { |
|
558 | cg = e.callcommand('changegroup', { | |
559 | 'nodes': incoming, |
|
559 | 'nodes': incoming, | |
560 | 'source': 'incoming', |
|
560 | 'source': 'incoming', | |
@@ -562,7 +562,7 b' def getremotechanges(ui, repo, other, on' | |||||
562 |
|
562 | |||
563 | rheads = None |
|
563 | rheads = None | |
564 | else: |
|
564 | else: | |
565 |
with |
|
565 | with peer.commandexecutor() as e: | |
566 | cg = e.callcommand('changegroupsubset', { |
|
566 | cg = e.callcommand('changegroupsubset', { | |
567 | 'bases': incoming, |
|
567 | 'bases': incoming, | |
568 | 'heads': rheads, |
|
568 | 'heads': rheads, | |
@@ -582,7 +582,7 b' def getremotechanges(ui, repo, other, on' | |||||
582 | # use the created uncompressed bundlerepo |
|
582 | # use the created uncompressed bundlerepo | |
583 | localrepo = bundlerepo = bundlerepository(repo.baseui, repo.root, |
|
583 | localrepo = bundlerepo = bundlerepository(repo.baseui, repo.root, | |
584 | fname) |
|
584 | fname) | |
585 |
# this repo contains local and |
|
585 | # this repo contains local and peer now, so filter out local again | |
586 | common = repo.heads() |
|
586 | common = repo.heads() | |
587 | if localrepo: |
|
587 | if localrepo: | |
588 | # Part of common may be remotely filtered |
|
588 | # Part of common may be remotely filtered | |
@@ -594,9 +594,9 b' def getremotechanges(ui, repo, other, on' | |||||
594 |
|
594 | |||
595 | if bundlerepo: |
|
595 | if bundlerepo: | |
596 | reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]] |
|
596 | reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]] | |
597 |
remotephases = |
|
597 | remotephases = peer.listkeys('phases') | |
598 |
|
598 | |||
599 |
pullop = exchange.pulloperation(bundlerepo, |
|
599 | pullop = exchange.pulloperation(bundlerepo, peer, heads=reponodes) | |
600 | pullop.trmanager = bundletransactionmanager() |
|
600 | pullop.trmanager = bundletransactionmanager() | |
601 | exchange._pullapplyphases(pullop, remotephases) |
|
601 | exchange._pullapplyphases(pullop, remotephases) | |
602 |
|
602 | |||
@@ -605,6 +605,6 b' def getremotechanges(ui, repo, other, on' | |||||
605 | bundlerepo.close() |
|
605 | bundlerepo.close() | |
606 | if bundle: |
|
606 | if bundle: | |
607 | os.unlink(bundle) |
|
607 | os.unlink(bundle) | |
608 |
|
|
608 | peer.close() | |
609 |
|
609 | |||
610 | return (localrepo, csets, cleanup) |
|
610 | return (localrepo, csets, cleanup) |
General Comments 0
You need to be logged in to leave comments.
Login now