Mercurial > hg
comparison mercurial/exchange.py @ 33701:fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Locking over the wire protocol and the "addchangegroup" wire
protocol command has been deprecated since e8c4f3d3df8c, which was
first part of Mercurial 0.9.1.
Support for handling these commands from sshserver was dropped in
9f6e0e7ef828 in 2015, effectively locking out pre 0.9.1 clients
from new servers.
However, client-side code for calling lock and addchangegroup is
still present in exchange.py and the various peer classes to
facilitate pushing to pre 0.9.1 servers.
The lock-based pushing mechanism is extremely brittle. 0.9.1 was
released in July 2006 and I highly doubt anyone is still running
such an ancient version of Mercurial on a server. I'm about to
refactor the peer API and I don't think it is worth keeping
support for this ancient protocol feature. So, this commit removes
client support for the lock-based pushing mechanism. This means
modern clients will no longer be able to push to pre 0.9.1 servers.
Differential Revision: https://phab.mercurial-scm.org/D264
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Aug 2017 17:44:56 -0700 |
parents | db3dc11356ed |
children | 033484935391 |
comparison
equal
deleted
inserted
replaced
33700:970967e0a917 | 33701:fda0867cfe03 |
---|---|
431 msg = _("required features are not" | 431 msg = _("required features are not" |
432 " supported in the destination:" | 432 " supported in the destination:" |
433 " %s") % (', '.join(sorted(missing))) | 433 " %s") % (', '.join(sorted(missing))) |
434 raise error.Abort(msg) | 434 raise error.Abort(msg) |
435 | 435 |
436 # there are two ways to push to remote repo: | |
437 # | |
438 # addchangegroup assumes local user can lock remote | |
439 # repo (local filesystem, old ssh servers). | |
440 # | |
441 # unbundle assumes local user cannot lock remote repo (new ssh | |
442 # servers, http servers). | |
443 | |
444 if not pushop.remote.canpush(): | 436 if not pushop.remote.canpush(): |
445 raise error.Abort(_("destination does not support push")) | 437 raise error.Abort(_("destination does not support push")) |
438 | |
439 if not pushop.remote.capable('unbundle'): | |
440 raise error.Abort(_('cannot push: destination does not support the ' | |
441 'unbundle wire protocol command')) | |
442 | |
446 # get local lock as we might write phase data | 443 # get local lock as we might write phase data |
447 localwlock = locallock = None | 444 localwlock = locallock = None |
448 try: | 445 try: |
449 # bundle2 push may receive a reply bundle touching bookmarks or other | 446 # bundle2 push may receive a reply bundle touching bookmarks or other |
450 # things requiring the wlock. Take it now to ensure proper ordering. | 447 # things requiring the wlock. Take it now to ensure proper ordering. |
466 if pushop.locallocked: | 463 if pushop.locallocked: |
467 pushop.trmanager = transactionmanager(pushop.repo, | 464 pushop.trmanager = transactionmanager(pushop.repo, |
468 'push-response', | 465 'push-response', |
469 pushop.remote.url()) | 466 pushop.remote.url()) |
470 pushop.repo.checkpush(pushop) | 467 pushop.repo.checkpush(pushop) |
471 lock = None | 468 _pushdiscovery(pushop) |
472 unbundle = pushop.remote.capable('unbundle') | 469 if not _forcebundle1(pushop): |
473 if not unbundle: | 470 _pushbundle2(pushop) |
474 lock = pushop.remote.lock() | 471 _pushchangeset(pushop) |
475 try: | 472 _pushsyncphase(pushop) |
476 _pushdiscovery(pushop) | 473 _pushobsolete(pushop) |
477 if not _forcebundle1(pushop): | 474 _pushbookmark(pushop) |
478 _pushbundle2(pushop) | 475 |
479 _pushchangeset(pushop) | |
480 _pushsyncphase(pushop) | |
481 _pushobsolete(pushop) | |
482 _pushbookmark(pushop) | |
483 finally: | |
484 if lock is not None: | |
485 lock.release() | |
486 if pushop.trmanager: | 476 if pushop.trmanager: |
487 pushop.trmanager.close() | 477 pushop.trmanager.close() |
488 finally: | 478 finally: |
489 if pushop.trmanager: | 479 if pushop.trmanager: |
490 pushop.trmanager.release() | 480 pushop.trmanager.release() |
956 if 'changesets' in pushop.stepsdone: | 946 if 'changesets' in pushop.stepsdone: |
957 return | 947 return |
958 pushop.stepsdone.add('changesets') | 948 pushop.stepsdone.add('changesets') |
959 if not _pushcheckoutgoing(pushop): | 949 if not _pushcheckoutgoing(pushop): |
960 return | 950 return |
951 | |
952 # Should have verified this in push(). | |
953 assert pushop.remote.capable('unbundle') | |
954 | |
961 pushop.repo.prepushoutgoinghooks(pushop) | 955 pushop.repo.prepushoutgoinghooks(pushop) |
962 outgoing = pushop.outgoing | 956 outgoing = pushop.outgoing |
963 unbundle = pushop.remote.capable('unbundle') | |
964 # TODO: get bundlecaps from remote | 957 # TODO: get bundlecaps from remote |
965 bundlecaps = None | 958 bundlecaps = None |
966 # create a changegroup from local | 959 # create a changegroup from local |
967 if pushop.revs is None and not (outgoing.excluded | 960 if pushop.revs is None and not (outgoing.excluded |
968 or pushop.repo.changelog.filteredrevs): | 961 or pushop.repo.changelog.filteredrevs): |
977 else: | 970 else: |
978 cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing, | 971 cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing, |
979 bundlecaps=bundlecaps) | 972 bundlecaps=bundlecaps) |
980 | 973 |
981 # apply changegroup to remote | 974 # apply changegroup to remote |
982 if unbundle: | 975 # local repo finds heads on server, finds out what |
983 # local repo finds heads on server, finds out what | 976 # revs it must push. once revs transferred, if server |
984 # revs it must push. once revs transferred, if server | 977 # finds it has different heads (someone else won |
985 # finds it has different heads (someone else won | 978 # commit/push race), server aborts. |
986 # commit/push race), server aborts. | 979 if pushop.force: |
987 if pushop.force: | 980 remoteheads = ['force'] |
988 remoteheads = ['force'] | |
989 else: | |
990 remoteheads = pushop.remoteheads | |
991 # ssh: return remote's addchangegroup() | |
992 # http: return remote's addchangegroup() or 0 for error | |
993 pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, | |
994 pushop.repo.url()) | |
995 else: | 981 else: |
996 # we return an integer indicating remote head count | 982 remoteheads = pushop.remoteheads |
997 # change | 983 # ssh: return remote's addchangegroup() |
998 pushop.cgresult = pushop.remote.addchangegroup(cg, 'push', | 984 # http: return remote's addchangegroup() or 0 for error |
999 pushop.repo.url()) | 985 pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, |
986 pushop.repo.url()) | |
1000 | 987 |
1001 def _pushsyncphase(pushop): | 988 def _pushsyncphase(pushop): |
1002 """synchronise phase information locally and remotely""" | 989 """synchronise phase information locally and remotely""" |
1003 cheads = pushop.commonheads | 990 cheads = pushop.commonheads |
1004 # even when we don't push, exchanging phase data is useful | 991 # even when we don't push, exchanging phase data is useful |