ArticleslgStudy

computer science

Mercurial

Mercurial is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Mercurial rather than just read about it. In short: Mercurial is a distributed revision control tool for software developers. It is supported on Microsoft Windows, Linux, and other Unix-like systems, such as FreeBSD and macOS.

Mercurial — main illustration
Mercurial — illustration

Key takeaways

  • Mercurial belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Mercurial to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Mercurial from memory before moving on to harder problems.

Reference excerpt

Mercurial is a distributed revision control tool for software developers. It is supported on Microsoft Windows, Linux, and other Unix-like systems, such as FreeBSD and macOS. Mercurial's major design goals include high performance and scalability, decentralization, fully distributed collaborative development, robust handling of both plain text and binary files, and advanced branching and merging capabilities, while remaining conceptually simple. It includes an integrated web-interface. Mercurial has also taken steps to ease the transition for users of other version control systems, particularly Subversion. Mercurial is primarily a command-line driven program, but graphical user interface extensions are available, e.g. TortoiseHg, and several IDEs offer support for version control with Mercurial. All of Mercurial's operations are invoked as arguments to its driver program hg (a reference to Hg – the chemical symbol of the element mercury). Olivia Mackall originated Mercurial and served as its lead developer until late 2016. Mercurial is released as free software under the GPL-2.0-or-later license. It is mainly implemented using the Python programming language, but includes a binary diff implementation written in C.

History Mackall first announced Mercurial on 19 April 2005. The impetus for this was the announcement earlier that month by Bitmover that they were withdrawing the free version of BitKeeper because of the development of SourcePuller. BitKeeper had been used for the version control requirements of the Linux kernel project. Mackall decided to write a distributed version control system as a replacement for use with the Linux kernel. This project started a few days after the now well-known Git project was initiated by Linus Torvalds with similar aims. The Linux kernel project decided to use Git rather than Mercurial, but Mercurial is now used by many other projects (see below). In an answer on the Mercurial mailing list, Olivia Mackall explained how the name "Mercurial" was chosen:

Shortly before the first release, I read an article about the ongoing Bitkeeper debacle that described Larry McVoy as mercurial (in the sense of 'fickle'). Given the multiple meanings, the convenient abbreviation, and the good fit with my pre-existing naming scheme (see my email address), it clicked instantly. Mercurial is thus named in Larry's honor. I do not know if the same is true of Git. High-profile projects such as the OpenJDK have used Mercurial in the past, though the OpenJDK no longer does as of Java 16.

Design Mercurial uses SHA-1 hashes to identify revisions. For repository access via a network, Mercurial uses an HTTP-based protocol that seeks to reduce round-trip requests, new connections, and data transferred. Mercurial can also work over SSH where the protocol is very similar to the HTTP-based protocol. By default it uses a 3-way merge before calling external merge tools.

Usage Figure 1 shows some of the most important operations in Mercurial and their relations to Mercurial's concepts.

Adoption Although Mercurial was not selected to manage the Linux kernel sources, it was adopted by several organizations for a time. Many projects used Mercurial for a time, but most had moved to Git by 2020. From 2016 until 2020, Facebook was using the Rust programming language to write Mononoke, a Mercurial server specifically designed to support large multi-project repositories. The source repository was archived in 2020, likely indicating the end of this project In 2013, Facebook adopted Mercurial and began work on scaling it to handle their large, unified code repository. There are no reports after 2014, suggesting this project may have been terminated. Google was able to use Mercurial as a front-end to their cloud-based 'Piper' monorepo back-end in 2016. Little recent information is available which suggests Mercurial support may now only be via Git compatibility. Bitbucket announced that its web-based version control services would end support for Mercurial in June 2020 (then extended to July 2020), explaining that "less than 1% of new projects use it, and developer surveys indicated that 90% of developers use Git". Xen used Mercurial for many years, but moved to Git in 2013. Mozilla used Mercurial for many years, but started moving to end support for Mercurial in favor of Git in 2023.

Mercurial servers and repository management Heptapod, a GitLab fork for Mercurial by Octobus Kallithea, a GPLv3 fork of RhodeCode Phabricator by Phacility RhodeCode by RhodeCode Inc.

Source code hosting

The following websites provide free source code hosting for Mercurial repositories:

Bitbucket by Atlassian (gone as of July 2020) Codebase FastHg GNU Savannah by FSF Heptapod hglab OSDN (seems dysfunctional as of December 2024) Perforce Puszcza (a sister site to GNU Savannah, hosted in Ukraine) SourceForge SourceHut TuxFamily Mercurial website mentions some other forges.

Open source projects using Mercurial Some projects using the Mercurial distributed RCS:

Open source projects formerly using Mercurial Mozilla 2007-2023 Xen ?-2013 OpenJDK

See also

Comparison of version-control software Distributed version control List of version-control software

Notes

References

External links

Official website

Illustrations

Mercurial illustration
Mercurial: Figure 1: Some important operations of Mercurial and their relations.
Figure 1: Some important operations of Mercurial and their relations.

Worked examples

Example 1 — a first encounter with Mercurial

Start with the simplest possible case. Write down what Mercurial claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Mercurial before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Mercurial ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Mercurial

In research
Mercurial appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Mercurial in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Mercurial is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2005 software, Cross-platform free software, Distributed version control systems, so understanding it makes those chapters shorter.
In everyday life
Look for Mercurial outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Mercurial” →

How to study Mercurial in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Mercurial means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Mercurial out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Mercurial in simple terms?

Mercurial is a distributed revision control tool for software developers. It is supported on Microsoft Windows, Linux, and other Unix-like systems, such as FreeBSD and macOS.

Why does Mercurial matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Mercurial?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Mercurial.

Tags

  • 2005 software
  • Cross-platform free software
  • Distributed version control systems
  • Free software programmed in C
  • Free software programmed in Python
  • Free version control software
  • Software using the GNU General Public License
  • Version control systems

Keep exploring