How to install the tortoisehg in Ubuntu20.04

I do not have a working package or snap. But using these instructions, it is rather easy to get tortoisehg working from source.

  1. Check that python --version returns a Python 3 interpreter. If not, you have to change the symlink /usr/bin/python to /usr/bin/python3.

    OK:

    $ python --version
    Python 3.8.2
    

    Not OK:

    $ python --version
    Python 2.7.18rc1
    

    Change the symlink:

    $ sudo rm /usr/bin/python
    $ sudo ln -s /usr/bin/python3 /usr/bin/python
    
  2. pip3 is needed to fulfill all the build dependencies.

    sudo apt install python3-pip build-essential
    
  3. Clone tortoisehg repository.

    hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
    
  4. Change into thg directory.

    cd thg
    
  5. Install PyQt5.

    pip3 install pyqt5
    
  6. Install mercurial.

    pip3 install mercurial
    
  7. Install Qscintilla.

    pip3 install qscintilla
    sudo apt install pyqt5.qsci-dev
    
  8. Lets build tortoisehg for inplace usage.

    make local
    
  9. Start tortoisehg.

    ./thg
    

I got tortoisehg working on three different Ubuntu 20.04 installations using this recipe.


When I tried to do the flow suggested by Gunter something went wrong and I got an error:

No module named 'PyQt5.Qsci'

None of the installation options proposed previously here worked.

I managed to eliminate it by running

sudo apt-get install python3-pyqt5.qsci 

Apart from confirming that the steps described by Gunther work well, I want to add that you also need to install iniparse to ensure TortoiseHg work properly. It needs iniparse to parse and update the Mercurial configuration.

Either

sudo apt-get install python3-iniparse

or

pip3 install iniparse

Also, if you want to make TortoiseHg available as desktop application from menu or so, you can first copy thg into /usr/bin or /usr/local/bin. You must also copy the Python module tortoisehg inside the directory where you built TortoiseHg to one of the paths in PYTHONPATH (PYTHONPATH is the path where Python searches for module files). Otherwise, TortoiseHg won't start with the following error.

$ thg
No module named 'tortoisehg'
abort: couldn't find tortoisehg libraries in [/usr/bin:/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/home/xxx/.local/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.8/dist-packages]

You can do:

sudo cp -R tortoisehg /usr/local/lib/python3.8/dist-packages

Then add a file ~/.local/share/applications/thg.desktop (for current user) or /usr/share/applications/thg.desktop (for system-wide usage).

[Desktop Entry]
Name=TortoiseHg
Exec=/usr/bin/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development

Update to set the Exec to the correct path of thg.

Also see: https://bitbucket.org/tortoisehg/thg/wiki/developers/Linux