##// END OF EJS Templates
exchange: drop support for lock-based unbundling (BC)...
Gregory Szorc -
r33667:fda0867c default
parent child Browse files
Show More
@@ -433,16 +433,13 b' def push(repo, remote, force=False, revs'
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:
@@ -468,21 +465,14 b' def push(repo, remote, force=False, revs'
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:
@@ -958,9 +948,12 b' def _pushchangeset(pushop):'
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
@@ -979,24 +972,18 b' def _pushchangeset(pushop):'
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"""
@@ -132,9 +132,6 b' class httppeer(wireproto.wirepeer):'
132 (' '.join(self.caps or ['none'])))
132 (' '.join(self.caps or ['none'])))
133 return self.caps
133 return self.caps
134
134
135 def lock(self):
136 raise error.Abort(_('operation not supported over http'))
137
138 def _callstream(self, cmd, _compressible=False, **args):
135 def _callstream(self, cmd, _compressible=False, **args):
139 if cmd == 'pushkey':
136 if cmd == 'pushkey':
140 args['data'] = ''
137 args['data'] = ''
@@ -237,9 +237,6 b' class localpeer(peer.peerrepository):'
237 except error.PushRaced as exc:
237 except error.PushRaced as exc:
238 raise error.ResponseError(_('push failed:'), str(exc))
238 raise error.ResponseError(_('push failed:'), str(exc))
239
239
240 def lock(self):
241 return self._repo.lock()
242
243 def pushkey(self, namespace, key, old, new):
240 def pushkey(self, namespace, key, old, new):
244 return self._repo.pushkey(namespace, key, old, new)
241 return self._repo.pushkey(namespace, key, old, new)
245
242
@@ -17,21 +17,6 b' from . import ('
17 wireproto,
17 wireproto,
18 )
18 )
19
19
20 class remotelock(object):
21 def __init__(self, repo):
22 self.repo = repo
23 def release(self):
24 self.repo.unlock()
25 self.repo = None
26 def __enter__(self):
27 return self
28 def __exit__(self, exc_type, exc_val, exc_tb):
29 if self.repo:
30 self.release()
31 def __del__(self):
32 if self.repo:
33 self.release()
34
35 def _serverquote(s):
20 def _serverquote(s):
36 if not s:
21 if not s:
37 return s
22 return s
@@ -337,33 +322,4 b' class sshpeer(wireproto.wirepeer):'
337 self.pipeo.flush()
322 self.pipeo.flush()
338 self.readerr()
323 self.readerr()
339
324
340 def lock(self):
341 self._call("lock")
342 return remotelock(self)
343
344 def unlock(self):
345 self._call("unlock")
346
347 def addchangegroup(self, cg, source, url, lock=None):
348 '''Send a changegroup to the remote server. Return an integer
349 similar to unbundle(). DEPRECATED, since it requires locking the
350 remote.'''
351 d = self._call("addchangegroup")
352 if d:
353 self._abort(error.RepoError(_("push refused: %s") % d))
354 for d in iter(lambda: cg.read(4096), ''):
355 self.pipeo.write(d)
356 self.readerr()
357
358 self.pipeo.flush()
359
360 self.readerr()
361 r = self._recv()
362 if not r:
363 return 1
364 try:
365 return int(r)
366 except ValueError:
367 self._abort(error.ResponseError(_("unexpected response:"), r))
368
369 instance = sshpeer
325 instance = sshpeer
General Comments 0
You need to be logged in to leave comments. Login now