##// END OF EJS Templates
wireproto: support disabling bundle1 only if repo is generaldelta...
Gregory Szorc -
r27633:37d7cf56 default
parent child Browse files
Show More
@@ -1345,14 +1345,26 Controls generic server settings.
1345 Whether to allow clients to push and pull using the legacy bundle1
1345 Whether to allow clients to push and pull using the legacy bundle1
1346 exchange format. (default: True)
1346 exchange format. (default: True)
1347
1347
1348 ``bundle1gd``
1349 Like ``bundle1` but only used if the repository is using the
1350 *generaldelta* storage format. (default: True)
1351
1348 ``bundle1.push``
1352 ``bundle1.push``
1349 Whether to allow clients to push using the legacy bundle1 exchange
1353 Whether to allow clients to push using the legacy bundle1 exchange
1350 format. (default: True)
1354 format. (default: True)
1351
1355
1356 ``bundle1gd.push``
1357 Like ``bundle1.push` but only used if the repository is using the
1358 *generaldelta* storage format. (default: True)
1359
1352 ``bundle1.pull``
1360 ``bundle1.pull``
1353 Whether to allow clients to pull using the legacy bundle1 exchange
1361 Whether to allow clients to pull using the legacy bundle1 exchange
1354 format. (default: True)
1362 format. (default: True)
1355
1363
1364 ``bundle1gd.pull``
1365 Like ``bundle1.pull` but only used if the repository is using the
1366 *generaldelta* storage format. (default: True)
1367
1356 Large repositories using the *generaldelta* storage format should
1368 Large repositories using the *generaldelta* storage format should
1357 consider setting this option because converting *generaldelta*
1369 consider setting this option because converting *generaldelta*
1358 repositories to the exchange format required by the bundle1 data
1370 repositories to the exchange format required by the bundle1 data
@@ -491,12 +491,33 def options(cmd, keys, others):
491 % (cmd, ",".join(others)))
491 % (cmd, ",".join(others)))
492 return opts
492 return opts
493
493
494 def bundle1allowed(ui, action):
494 def bundle1allowed(repo, action):
495 """Whether a bundle1 operation is allowed from the server."""
495 """Whether a bundle1 operation is allowed from the server.
496
497 Priority is:
498
499 1. server.bundle1gd.<action> (if generaldelta active)
500 2. server.bundle1.<action>
501 3. server.bundle1gd (if generaldelta active)
502 4. server.bundle1
503 """
504 ui = repo.ui
505 gd = 'generaldelta' in repo.requirements
506
507 if gd:
508 v = ui.configbool('server', 'bundle1gd.%s' % action, None)
509 if v is not None:
510 return v
511
496 v = ui.configbool('server', 'bundle1.%s' % action, None)
512 v = ui.configbool('server', 'bundle1.%s' % action, None)
497 if v is not None:
513 if v is not None:
498 return v
514 return v
499
515
516 if gd:
517 v = ui.configbool('server', 'bundle1gd', None)
518 if v is not None:
519 return v
520
500 return ui.configbool('server', 'bundle1', True)
521 return ui.configbool('server', 'bundle1', True)
501
522
502 # list of commands
523 # list of commands
@@ -665,7 +686,7 def getbundle(repo, proto, others):
665 raise KeyError('unknown getbundle option type %s'
686 raise KeyError('unknown getbundle option type %s'
666 % keytype)
687 % keytype)
667
688
668 if not bundle1allowed(repo.ui, 'pull'):
689 if not bundle1allowed(repo, 'pull'):
669 if not exchange.bundle2requested(opts.get('bundlecaps')):
690 if not exchange.bundle2requested(opts.get('bundlecaps')):
670 return ooberror(bundle2required)
691 return ooberror(bundle2required)
671
692
@@ -781,7 +802,7 def unbundle(repo, proto, heads):
781 fp.seek(0)
802 fp.seek(0)
782 gen = exchange.readbundle(repo.ui, fp, None)
803 gen = exchange.readbundle(repo.ui, fp, None)
783 if (isinstance(gen, changegroupmod.cg1unpacker)
804 if (isinstance(gen, changegroupmod.cg1unpacker)
784 and not bundle1allowed(repo.ui, 'push')):
805 and not bundle1allowed(repo, 'push')):
785 return ooberror(bundle2required)
806 return ooberror(bundle2required)
786
807
787 r = exchange.unbundle(repo, gen, their_heads, 'serve',
808 r = exchange.unbundle(repo, gen, their_heads, 'serve',
@@ -977,6 +977,51 Servers can disable bundle1 for clone/pu
977 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
977 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
978 [255]
978 [255]
979 $ killdaemons.py
979 $ killdaemons.py
980 $ cd ..
981
982 bundle1 can still pull non-generaldelta repos when generaldelta bundle1 disabled
983
984 $ hg --config format.usegeneraldelta=false init notgdserver
985 $ cd notgdserver
986 $ cat > .hg/hgrc << EOF
987 > [server]
988 > bundle1gd.pull = false
989 > EOF
990
991 $ touch foo
992 $ hg -q commit -A -m initial
993 $ hg serve -p $HGPORT -d --pid-file=hg.pid
994 $ cat hg.pid >> $DAEMON_PIDS
995
996 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT/ not-bundle2-1
997 requesting all changes
998 adding changesets
999 adding manifests
1000 adding file changes
1001 added 1 changesets with 1 changes to 1 files
1002 updating to branch default
1003 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1004
1005 $ killdaemons.py
1006 $ cd ../bundle2onlyserver
1007
1008 bundle1 pull can be disabled for generaldelta repos only
1009
1010 $ cat > .hg/hgrc << EOF
1011 > [server]
1012 > bundle1gd.pull = false
1013 > EOF
1014
1015 $ hg serve -p $HGPORT -d --pid-file=hg.pid
1016 $ cat hg.pid >> $DAEMON_PIDS
1017 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT/ not-bundle2
1018 requesting all changes
1019 abort: remote error:
1020 incompatible Mercurial client; bundle2 required
1021 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
1022 [255]
1023
1024 $ killdaemons.py
980
1025
981 Verify the global server.bundle1 option works
1026 Verify the global server.bundle1 option works
982
1027
@@ -994,6 +1039,42 Verify the global server.bundle1 option
994 [255]
1039 [255]
995 $ killdaemons.py
1040 $ killdaemons.py
996
1041
1042 $ cat > .hg/hgrc << EOF
1043 > [server]
1044 > bundle1gd = false
1045 > EOF
1046 $ hg serve -p $HGPORT -d --pid-file=hg.pid
1047 $ cat hg.pid >> $DAEMON_PIDS
1048
1049 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT/ not-bundle2
1050 requesting all changes
1051 abort: remote error:
1052 incompatible Mercurial client; bundle2 required
1053 (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
1054 [255]
1055
1056 $ killdaemons.py
1057
1058 $ cd ../notgdserver
1059 $ cat > .hg/hgrc << EOF
1060 > [server]
1061 > bundle1gd = false
1062 > EOF
1063 $ hg serve -p $HGPORT -d --pid-file=hg.pid
1064 $ cat hg.pid >> $DAEMON_PIDS
1065
1066 $ hg --config experimental.bundle2-exp=false clone http://localhost:$HGPORT/ not-bundle2-2
1067 requesting all changes
1068 adding changesets
1069 adding manifests
1070 adding file changes
1071 added 1 changesets with 1 changes to 1 files
1072 updating to branch default
1073 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1074
1075 $ killdaemons.py
1076 $ cd ../bundle2onlyserver
1077
997 Verify bundle1 pushes can be disabled
1078 Verify bundle1 pushes can be disabled
998
1079
999 $ cat > .hg/hgrc << EOF
1080 $ cat > .hg/hgrc << EOF
General Comments 0
You need to be logged in to leave comments. Login now