What's new in Mercurial (HG) 4.1?

What's new in Mercurial (HG) 4.1?

Mercurial (HG) 4.1 was released last week. A new version of Mercurial is released according to their time-based release plan that includes four major releases in a year. The aim of this blog post is to describe what's new in Mercurial 4.1 and even more importantly what's interesting in Mercurial 4.1. Deveo provides free Mercurial repository hosting for private repositories up until 1 GB of total storage. In addition, you can also host SVN and Git repositories. We are always looking forward to new releases of each version control system we support.

From zlib to zstd

Zstandard or zstd is a lossless compression algorithm that provides both great compression ratio in addition to speed for compression needs. Zstandard 1.0 was released 31st of August 2016. According to the release blog post the compression speed is roughly five times faster than zlib while decompression speed is roughly two times faster respectively and more importantly, Zstandard maintains the same level of compression ratio; 3.14 vs. 3.11 to zlib and zstd respectively.

Mercurial 4.1 introduces some notable changes in order to push zstd usage forward. There is a new extensible "compression engines" API, that allows the usage and implementation of new compression engines as extensions.

The new compression formats are currently fully supported in bundles and the wire protocol. Bundles are usable if you have a poor network connection that is preventing hg clone from completing. A bundle is downloaded as a package, and thus the download can be continued, if the connection is lost.

The wire protocol, on the other hand, is the set of commands that Mercurial uses to discover changesets to push and pull and actually exchange changesets with remote hosts. In addition to the bundles and the wire protocol, there's also experimental support to use different compression engines in revlogs.

Benefits of zstd in Mercurial 4.1

Prior to Mercurial 4.1 all HTTP payloads for commands were utilizing zlib. As zstd is distributed alongside Mercurial 4.1 and forward, HTTP payloads for many commands are set to use zstd by default. Using these commands can bring 40% server-side CPU usage savings for operations, such as serving bundles.

A new statistical profiler has been added and made the default profiler for --profile. This profiler gives more accurate results than Python's built-in cProfile (the previous default) because the profiler overhead is much smaller. The output from --profile now displays the code hot path by default. This allows Mercurial developers to more accurately identify performance problems.

Experimental debugupgraderepo command

If Mercurial introduces a new repository level feature or
changes its behavior of an existing feature, users cannot trust that doing a simple hg clone would upgrade the repository to use the optimal settings. hg debugupgraderepo is a command that performs an in-place upgrade of a repository to use new, optimal features. Since this command is still a work in progress, I would not advise to use it with production data.

Improvements in Mercurial 4.1

The performance of reading individual revlog entries has been greatly improved, especially with large repositories. In addition, the low-level content diffing algorithm is now around two times faster. Operations that write data to the repository, such as commits can be noticeably faster as a result.

Conclusion

If you are interested in reading the full release notes, check out the official release notes for Mercurial 4.1 and a summary of changes in Mercurial 4.1. If you want to host Mercurial repositories for free, see how Deveo can help you in hosting Mercurial in the cloud or on your own servers.

Seamless software development.

Code management and collaboration platform with Git, Subversion, and Mercurial.

Sign up for free
comments powered by Disqus