I will give an example of installing on Linux the latest version of Mercurial, downloaded from the official site.
If the system already has Mercurial, then delete, for example, in Ubuntu this can be done like this:
hg hg version which hg sudo apt-get remove mercurial --purge sudo apt-get autoremove sudo apt-get remove mercurial-common --purge
Now install the necessary components:
sudo apt install python-dev python-docutils gcc
Download from the official Mercurial website and install:
wget https://www.mercurial-scm.org/repo/hg/archive/stable.tar.gz tar xzvf stable.tar.gz cd Mercurial-stable sudo make install which hg