Show More
@@ -3288,6 +3288,9 b' class compressionengine(object):' | |||||
3288 |
|
3288 | |||
3289 | If bundle compression is supported, the class must also implement |
|
3289 | If bundle compression is supported, the class must also implement | |
3290 | ``compressstream`` and `decompressorreader``. |
|
3290 | ``compressstream`` and `decompressorreader``. | |
|
3291 | ||||
|
3292 | The docstring of this method is used in the help system to tell users | |||
|
3293 | about this engine. | |||
3291 | """ |
|
3294 | """ | |
3292 | return None |
|
3295 | return None | |
3293 |
|
3296 | |||
@@ -3372,6 +3375,12 b' class _zlibengine(compressionengine):' | |||||
3372 | return 'zlib' |
|
3375 | return 'zlib' | |
3373 |
|
3376 | |||
3374 | def bundletype(self): |
|
3377 | def bundletype(self): | |
|
3378 | """zlib compression using the DEFLATE algorithm. | |||
|
3379 | ||||
|
3380 | All Mercurial clients should support this format. The compression | |||
|
3381 | algorithm strikes a reasonable balance between compression ratio | |||
|
3382 | and size. | |||
|
3383 | """ | |||
3375 | return 'gzip', 'GZ' |
|
3384 | return 'gzip', 'GZ' | |
3376 |
|
3385 | |||
3377 | def wireprotosupport(self): |
|
3386 | def wireprotosupport(self): | |
@@ -3453,6 +3462,17 b' class _bz2engine(compressionengine):' | |||||
3453 | return 'bz2' |
|
3462 | return 'bz2' | |
3454 |
|
3463 | |||
3455 | def bundletype(self): |
|
3464 | def bundletype(self): | |
|
3465 | """An algorithm that produces smaller bundles than ``gzip``. | |||
|
3466 | ||||
|
3467 | All Mercurial clients should support this format. | |||
|
3468 | ||||
|
3469 | This engine will likely produce smaller bundles than ``gzip`` but | |||
|
3470 | will be significantly slower, both during compression and | |||
|
3471 | decompression. | |||
|
3472 | ||||
|
3473 | If available, the ``zstd`` engine can yield similar or better | |||
|
3474 | compression at much higher speeds. | |||
|
3475 | """ | |||
3456 | return 'bzip2', 'BZ' |
|
3476 | return 'bzip2', 'BZ' | |
3457 |
|
3477 | |||
3458 | # We declare a protocol name but don't advertise by default because |
|
3478 | # We declare a protocol name but don't advertise by default because | |
@@ -3506,6 +3526,10 b' class _noopengine(compressionengine):' | |||||
3506 | return 'none' |
|
3526 | return 'none' | |
3507 |
|
3527 | |||
3508 | def bundletype(self): |
|
3528 | def bundletype(self): | |
|
3529 | """No compression is performed. | |||
|
3530 | ||||
|
3531 | Use this compression engine to explicitly disable compression. | |||
|
3532 | """ | |||
3509 | return 'none', 'UN' |
|
3533 | return 'none', 'UN' | |
3510 |
|
3534 | |||
3511 | # Clients always support uncompressed payloads. Servers don't because |
|
3535 | # Clients always support uncompressed payloads. Servers don't because | |
@@ -3552,6 +3576,17 b' class _zstdengine(compressionengine):' | |||||
3552 | return bool(self._module) |
|
3576 | return bool(self._module) | |
3553 |
|
3577 | |||
3554 | def bundletype(self): |
|
3578 | def bundletype(self): | |
|
3579 | """A modern compression algorithm that is fast and highly flexible. | |||
|
3580 | ||||
|
3581 | Only supported by Mercurial 4.1 and newer clients. | |||
|
3582 | ||||
|
3583 | With the default settings, zstd compression is both faster and yields | |||
|
3584 | better compression than ``gzip``. It also frequently yields better | |||
|
3585 | compression than ``bzip2`` while operating at much higher speeds. | |||
|
3586 | ||||
|
3587 | If this engine is available and backwards compatibility is not a | |||
|
3588 | concern, it is likely the best available engine. | |||
|
3589 | """ | |||
3555 | return 'zstd', 'ZS' |
|
3590 | return 'zstd', 'ZS' | |
3556 |
|
3591 | |||
3557 | def wireprotosupport(self): |
|
3592 | def wireprotosupport(self): | |
@@ -3650,5 +3685,35 b' class _zstdengine(compressionengine):' | |||||
3650 |
|
3685 | |||
3651 | compengines.register(_zstdengine()) |
|
3686 | compengines.register(_zstdengine()) | |
3652 |
|
3687 | |||
|
3688 | def bundlecompressiontopics(): | |||
|
3689 | """Obtains a list of available bundle compressions for use in help.""" | |||
|
3690 | # help.makeitemsdocs() expects a dict of names to items with a .__doc__. | |||
|
3691 | items = {} | |||
|
3692 | ||||
|
3693 | # We need to format the docstring. So use a dummy object/type to hold it | |||
|
3694 | # rather than mutating the original. | |||
|
3695 | class docobject(object): | |||
|
3696 | pass | |||
|
3697 | ||||
|
3698 | for name in compengines: | |||
|
3699 | engine = compengines[name] | |||
|
3700 | ||||
|
3701 | if not engine.available(): | |||
|
3702 | continue | |||
|
3703 | ||||
|
3704 | bt = engine.bundletype() | |||
|
3705 | if not bt or not bt[0]: | |||
|
3706 | continue | |||
|
3707 | ||||
|
3708 | doc = pycompat.sysstr('``%s``\n %s' % ( | |||
|
3709 | bt[0], engine.bundletype.__doc__)) | |||
|
3710 | ||||
|
3711 | value = docobject() | |||
|
3712 | value.__doc__ = doc | |||
|
3713 | ||||
|
3714 | items[bt[0]] = value | |||
|
3715 | ||||
|
3716 | return items | |||
|
3717 | ||||
3653 | # convenient shortcut |
|
3718 | # convenient shortcut | |
3654 | dst = debugstacktrace |
|
3719 | dst = debugstacktrace |
General Comments 0
You need to be logged in to leave comments.
Login now