equal
deleted
inserted
replaced
489 if others: |
489 if others: |
490 sys.stderr.write("warning: %s ignored unexpected arguments %s\n" |
490 sys.stderr.write("warning: %s ignored unexpected arguments %s\n" |
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 |
|
515 |
|
516 if gd: |
|
517 v = ui.configbool('server', 'bundle1gd', None) |
|
518 if v is not None: |
|
519 return v |
499 |
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 |
503 commands = {} |
524 commands = {} |
663 opts[k] = bool(v) |
684 opts[k] = bool(v) |
664 elif keytype != 'plain': |
685 elif keytype != 'plain': |
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 |
672 cg = exchange.getbundle(repo, 'serve', **opts) |
693 cg = exchange.getbundle(repo, 'serve', **opts) |
673 return streamres(proto.groupchunks(cg)) |
694 return streamres(proto.groupchunks(cg)) |
779 try: |
800 try: |
780 proto.getfile(fp) |
801 proto.getfile(fp) |
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', |
788 proto._client()) |
809 proto._client()) |
789 if util.safehasattr(r, 'addpart'): |
810 if util.safehasattr(r, 'addpart'): |