mercurial/exchange.py
changeset 26587 56b2bcea2529
parent 26566 58880acd2369
child 26623 5a95fe44121d
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    28         fname = vfs.join(fname)
    28         fname = vfs.join(fname)
    29 
    29 
    30     magic, version = header[0:2], header[2:4]
    30     magic, version = header[0:2], header[2:4]
    31 
    31 
    32     if magic != 'HG':
    32     if magic != 'HG':
    33         raise util.Abort(_('%s: not a Mercurial bundle') % fname)
    33         raise error.Abort(_('%s: not a Mercurial bundle') % fname)
    34     if version == '10':
    34     if version == '10':
    35         if alg is None:
    35         if alg is None:
    36             alg = changegroup.readexactly(fh, 2)
    36             alg = changegroup.readexactly(fh, 2)
    37         return changegroup.cg1unpacker(fh, alg)
    37         return changegroup.cg1unpacker(fh, alg)
    38     elif version.startswith('2'):
    38     elif version.startswith('2'):
    39         return bundle2.getunbundler(ui, fh, magicstring=magic + version)
    39         return bundle2.getunbundler(ui, fh, magicstring=magic + version)
    40     else:
    40     else:
    41         raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
    41         raise error.Abort(_('%s: unknown bundle version %s') % (fname, version))
    42 
    42 
    43 def buildobsmarkerspart(bundler, markers):
    43 def buildobsmarkerspart(bundler, markers):
    44     """add an obsmarker part to the bundler with <markers>
    44     """add an obsmarker part to the bundler with <markers>
    45 
    45 
    46     No part is created if markers is empty.
    46     No part is created if markers is empty.
   191                    - pushop.remote.local().supported)
   191                    - pushop.remote.local().supported)
   192         if missing:
   192         if missing:
   193             msg = _("required features are not"
   193             msg = _("required features are not"
   194                     " supported in the destination:"
   194                     " supported in the destination:"
   195                     " %s") % (', '.join(sorted(missing)))
   195                     " %s") % (', '.join(sorted(missing)))
   196             raise util.Abort(msg)
   196             raise error.Abort(msg)
   197 
   197 
   198     # there are two ways to push to remote repo:
   198     # there are two ways to push to remote repo:
   199     #
   199     #
   200     # addchangegroup assumes local user can lock remote
   200     # addchangegroup assumes local user can lock remote
   201     # repo (local filesystem, old ssh servers).
   201     # repo (local filesystem, old ssh servers).
   202     #
   202     #
   203     # unbundle assumes local user cannot lock remote repo (new ssh
   203     # unbundle assumes local user cannot lock remote repo (new ssh
   204     # servers, http servers).
   204     # servers, http servers).
   205 
   205 
   206     if not pushop.remote.canpush():
   206     if not pushop.remote.canpush():
   207         raise util.Abort(_("destination does not support push"))
   207         raise error.Abort(_("destination does not support push"))
   208     # get local lock as we might write phase data
   208     # get local lock as we might write phase data
   209     localwlock = locallock = None
   209     localwlock = locallock = None
   210     try:
   210     try:
   211         # bundle2 push may receive a reply bundle touching bookmarks or other
   211         # bundle2 push may receive a reply bundle touching bookmarks or other
   212         # things requiring the wlock. Take it now to ensure proper ordering.
   212         # things requiring the wlock. Take it now to ensure proper ordering.
   433             # least one of the missinghead will be obsolete or
   433             # least one of the missinghead will be obsolete or
   434             # unstable. So checking heads only is ok
   434             # unstable. So checking heads only is ok
   435             for node in outgoing.missingheads:
   435             for node in outgoing.missingheads:
   436                 ctx = unfi[node]
   436                 ctx = unfi[node]
   437                 if ctx.obsolete():
   437                 if ctx.obsolete():
   438                     raise util.Abort(mso % ctx)
   438                     raise error.Abort(mso % ctx)
   439                 elif ctx.troubled():
   439                 elif ctx.troubled():
   440                     raise util.Abort(mst[ctx.troubles()[0]] % ctx)
   440                     raise error.Abort(mst[ctx.troubles()[0]] % ctx)
   441 
   441 
   442         # internal config: bookmarks.pushing
   442         # internal config: bookmarks.pushing
   443         newbm = pushop.ui.configlist('bookmarks', 'pushing')
   443         newbm = pushop.ui.configlist('bookmarks', 'pushing')
   444         discovery.checkheads(unfi, pushop.remote, outgoing,
   444         discovery.checkheads(unfi, pushop.remote, outgoing,
   445                              pushop.remoteheads,
   445                              pushop.remoteheads,
   656     stream = util.chunkbuffer(bundler.getchunks())
   656     stream = util.chunkbuffer(bundler.getchunks())
   657     try:
   657     try:
   658         try:
   658         try:
   659             reply = pushop.remote.unbundle(stream, ['force'], 'push')
   659             reply = pushop.remote.unbundle(stream, ['force'], 'push')
   660         except error.BundleValueError as exc:
   660         except error.BundleValueError as exc:
   661             raise util.Abort('missing support for %s' % exc)
   661             raise error.Abort('missing support for %s' % exc)
   662         try:
   662         try:
   663             trgetter = None
   663             trgetter = None
   664             if pushback:
   664             if pushback:
   665                 trgetter = pushop.trmanager.transaction
   665                 trgetter = pushop.trmanager.transaction
   666             op = bundle2.processbundle(pushop.repo, reply, trgetter)
   666             op = bundle2.processbundle(pushop.repo, reply, trgetter)
   667         except error.BundleValueError as exc:
   667         except error.BundleValueError as exc:
   668             raise util.Abort('missing support for %s' % exc)
   668             raise error.Abort('missing support for %s' % exc)
   669     except error.PushkeyFailed as exc:
   669     except error.PushkeyFailed as exc:
   670         partid = int(exc.partid)
   670         partid = int(exc.partid)
   671         if partid not in pushop.pkfailcb:
   671         if partid not in pushop.pkfailcb:
   672             raise
   672             raise
   673         pushop.pkfailcb[partid](pushop, exc)
   673         pushop.pkfailcb[partid](pushop, exc)
   965         missing = set(pullop.remote.requirements) - pullop.repo.supported
   965         missing = set(pullop.remote.requirements) - pullop.repo.supported
   966         if missing:
   966         if missing:
   967             msg = _("required features are not"
   967             msg = _("required features are not"
   968                     " supported in the destination:"
   968                     " supported in the destination:"
   969                     " %s") % (', '.join(sorted(missing)))
   969                     " %s") % (', '.join(sorted(missing)))
   970             raise util.Abort(msg)
   970             raise error.Abort(msg)
   971 
   971 
   972     lock = pullop.repo.lock()
   972     lock = pullop.repo.lock()
   973     try:
   973     try:
   974         pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
   974         pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
   975         streamclone.maybeperformlegacystreamclone(pullop)
   975         streamclone.maybeperformlegacystreamclone(pullop)
  1106     _pullbundle2extraprepare(pullop, kwargs)
  1106     _pullbundle2extraprepare(pullop, kwargs)
  1107     bundle = pullop.remote.getbundle('pull', **kwargs)
  1107     bundle = pullop.remote.getbundle('pull', **kwargs)
  1108     try:
  1108     try:
  1109         op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
  1109         op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
  1110     except error.BundleValueError as exc:
  1110     except error.BundleValueError as exc:
  1111         raise util.Abort('missing support for %s' % exc)
  1111         raise error.Abort('missing support for %s' % exc)
  1112 
  1112 
  1113     if pullop.fetch:
  1113     if pullop.fetch:
  1114         results = [cg['return'] for cg in op.records['changegroup']]
  1114         results = [cg['return'] for cg in op.records['changegroup']]
  1115         pullop.cgresult = changegroup.combineresults(results)
  1115         pullop.cgresult = changegroup.combineresults(results)
  1116 
  1116 
  1156         cg = pullop.remote.getbundle('pull', common=pullop.common,
  1156         cg = pullop.remote.getbundle('pull', common=pullop.common,
  1157                                      heads=pullop.heads or pullop.rheads)
  1157                                      heads=pullop.heads or pullop.rheads)
  1158     elif pullop.heads is None:
  1158     elif pullop.heads is None:
  1159         cg = pullop.remote.changegroup(pullop.fetch, 'pull')
  1159         cg = pullop.remote.changegroup(pullop.fetch, 'pull')
  1160     elif not pullop.remote.capable('changegroupsubset'):
  1160     elif not pullop.remote.capable('changegroupsubset'):
  1161         raise util.Abort(_("partial pull cannot be done because "
  1161         raise error.Abort(_("partial pull cannot be done because "
  1162                            "other repository doesn't support "
  1162                            "other repository doesn't support "
  1163                            "changegroupsubset."))
  1163                            "changegroupsubset."))
  1164     else:
  1164     else:
  1165         cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
  1165         cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
  1166     pullop.cgresult = changegroup.addchangegroup(pullop.repo, cg, 'pull',
  1166     pullop.cgresult = changegroup.addchangegroup(pullop.repo, cg, 'pull',