##// END OF EJS Templates
wireproto: config options to disable bundle1...
Gregory Szorc -
r27246:b288fb27 default
parent child Browse files
Show More
@@ -1319,6 +1319,23 b' Controls generic server settings.'
1319 1319 Instruct HTTP clients not to send request headers longer than this
1320 1320 many bytes. (default: 1024)
1321 1321
1322 ``bundle1``
1323 Whether to allow clients to push and pull using the legacy bundle1
1324 exchange format. (default: True)
1325
1326 ``bundle1.push``
1327 Whether to allow clients to push using the legacy bundle1 exchange
1328 format. (default: True)
1329
1330 ``bundle1.pull``
1331 Whether to allow clients to pull using the legacy bundle1 exchange
1332 format. (default: True)
1333
1334 Large repositories using the *generaldelta* storage format should
1335 consider setting this option because converting *generaldelta*
1336 repositories to the exchange format required by the bundle1 data
1337 format can consume a lot of CPU.
1338
1322 1339 ``smtp``
1323 1340 --------
1324 1341
@@ -30,6 +30,10 b' from . import ('
30 30 util,
31 31 )
32 32
33 bundle2required = _(
34 'incompatible Mercurial client; bundle2 required\n'
35 '(see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n')
36
33 37 class abstractserverproto(object):
34 38 """abstract class that summarizes the protocol API
35 39
@@ -487,6 +491,14 b' def options(cmd, keys, others):'
487 491 % (cmd, ",".join(others)))
488 492 return opts
489 493
494 def bundle1allowed(ui, action):
495 """Whether a bundle1 operation is allowed from the server."""
496 v = ui.configbool('server', 'bundle1.%s' % action, None)
497 if v is not None:
498 return v
499
500 return ui.configbool('server', 'bundle1', True)
501
490 502 # list of commands
491 503 commands = {}
492 504
@@ -652,6 +664,11 b' def getbundle(repo, proto, others):'
652 664 elif keytype != 'plain':
653 665 raise KeyError('unknown getbundle option type %s'
654 666 % keytype)
667
668 if not bundle1allowed(repo.ui, 'pull'):
669 if not exchange.bundle2requested(opts.get('bundlecaps')):
670 return ooberror(bundle2required)
671
655 672 cg = exchange.getbundle(repo, 'serve', **opts)
656 673 return streamres(proto.groupchunks(cg))
657 674
@@ -763,6 +780,10 b' def unbundle(repo, proto, heads):'
763 780 proto.getfile(fp)
764 781 fp.seek(0)
765 782 gen = exchange.readbundle(repo.ui, fp, None)
783 if (isinstance(gen, changegroupmod.cg1unpacker)
784 and not bundle1allowed(repo.ui, 'push')):
785 return ooberror(bundle2required)
786
766 787 r = exchange.unbundle(repo, gen, their_heads, 'serve',
767 788 proto._client())
768 789 if util.safehasattr(r, 'addpart'):
@@ -951,3 +951,86 b' Test lazily acquiring the lock during un'
951 951 remote: adding manifests
952 952 remote: adding file changes
953 953 remote: added 1 changesets with 1 changes to 1 files
954
955 $ cd ..
956
957 Servers can disable bundle1 for clone/pull operations
958
959 $ killdaemons.py
960 $ hg init bundle2onlyserver
961 $ cd bundle2onlyserver
962 $ cat > .hg/hgrc << EOF
963 > [server]
964 > bundle1.pull = false
965 > EOF
966
967 $ touch foo
968 $ hg -q commit -A -m initial
969
970 $ hg serve -p $HGPORT -d --pid-file=hg.pid
971 $ cat hg.pid >> $DAEMON_PIDS
972
973 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT/ not-bundle2
974 requesting all changes
975 abort: remote error:
976 incompatible Mercurial client; bundle2 required
977 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
978 [255]
979 $ killdaemons.py
980
981 Verify the global server.bundle1 option works
982
983 $ cat > .hg/hgrc << EOF
984 > [server]
985 > bundle1 = false
986 > EOF
987 $ hg serve -p $HGPORT -d --pid-file=hg.pid
988 $ cat hg.pid >> $DAEMON_PIDS
989 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT not-bundle2
990 requesting all changes
991 abort: remote error:
992 incompatible Mercurial client; bundle2 required
993 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
994 [255]
995 $ killdaemons.py
996
997 Verify bundle1 pushes can be disabled
998
999 $ cat > .hg/hgrc << EOF
1000 > [server]
1001 > bundle1.push = false
1002 > [web]
1003 > allow_push = *
1004 > push_ssl = false
1005 > EOF
1006
1007 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E error.log
1008 $ cat hg.pid >> $DAEMON_PIDS
1009 $ cd ..
1010
1011 $ hg clone http://localhost:$HGPORT bundle2-only
1012 requesting all changes
1013 adding changesets
1014 adding manifests
1015 adding file changes
1016 added 1 changesets with 1 changes to 1 files
1017 updating to branch default
1018 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1019 $ cd bundle2-only
1020 $ echo commit > foo
1021 $ hg commit -m commit
1022 $ hg --config experimental.bundle2-exp=false push
1023 pushing to http://localhost:$HGPORT/
1024 searching for changes
1025 abort: remote error:
1026 incompatible Mercurial client; bundle2 required
1027 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
1028 [255]
1029
1030 $ hg push
1031 pushing to http://localhost:$HGPORT/
1032 searching for changes
1033 remote: adding changesets
1034 remote: adding manifests
1035 remote: adding file changes
1036 remote: added 1 changesets with 1 changes to 1 files
General Comments 0
You need to be logged in to leave comments. Login now