There are multiple advantages:
- Very useful TortoiseHG Workbench (+MQ queues) interface, it's a superpower dashboard for your working copies
- Clean mercurial CLI
TODO: Write me
TODO: Write me
Mercurial is builtin sometimes behave differently than the hg distributed through python/pip even if versions are the same. And sometime you need to replace builtin mercurial with your own version.
For windows you have two options to run TortoiseHg:
- build your own installer and install it
- Run
thg
from source code under python
Both ways are extremely complex due to the next reasons:
- Currently mercurial and TortoiseHG are sitting on python 2.7 version and there are no binaries for PyQT and other dependencies.
- Shell extensions require a big amount of windows specific tools and installation actions.
- You need Windows 7 SDK and other very old build tools.
For UI TortoiseHG uses mercurial package as python library from its C:\Program Files\TortoiseHG\lib\library.zip
For commands TortoiseHG executes hg.exe
in a separated process, with the next search sequence:
C:\Program Files\TortoiseHG\hg.exe
- System
hg.exe
(According to %PATH% variable)
When TortoiseHg runs hg.exe
it does some extra wrapping which in turn requires that hg.exe
should have access to thg python package. If this requirements is not satisfied, the next errors rise:
*** failed to import extension tortoisehg.util.hgcommands: No module named tortoisehg.util.hgcommands
*** failed to import extension tortoisehg.util.partialcommit: No module named tortoisehg.util.partialcommit
*** failed to import extension tortoisehg.util.pipeui: No module named tortoisehg.util.pipeui
*** failed to import extension tortoisehg.util.win32ill: No module named tortoisehg.util.win32ill
*** failed to import extension tortoisehg.util.hgdispatch: No module named tortoisehg.util.hgdispatch
- Install Python 2.7
- Create a python virtual environment for a custom mercurial
- Instal mercurial and plugins into the virtual environment
- Add
hg.exe
from the virtual environment to the %PATH% and renameC:\Program Files\TortoiseHG\hg.exe
tohg4.8.2.exe
- Copy
tortoisehg
python package fromthg
sources to the virtual environmentLibs\site-packages
- Download latest python 2.7 (for example from https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi)
- Install it to the
C:\Python27-x64
- Prefer to NOT add this python to the PATH
- Create
C:\Python27-x64\setup-vars.cmd
set PATH=c:\python27-x64;c:\python27-x64\scripts;%PATH%
- upgrade pip from elevated priveleges (Administrator command prompt)
C:\Python27-x64\setup-vars.cmd
pip install -U pip
- Activate
C:\Python27-x64
C:\Python27-x64\setup-vars.cmd
- Install
virtualenv
package
pip install virtualenv
- Create an virtual environment virtualenv C:\opt\mercurial
- Activate virtual environment
c:\opt\mercurial\scripts\activate
- Install mercurial
pip install mercurial
hg --version
- Install common mercurial plugins
pip install hg-git ipaddress mercurial-keyring
- Move all
*.exe
files excepthg.exe
fromC:\opt\mercurial\scripts
to `C:\opt\mercurial\scripts\hide' (this step is required to avoid conflicts of the virtual environment and other python environments - Add
C:\opt\mercurial\scripts\hg.exe
to the PATH variable
setx PATH C:\opt\mercurial\scripts;%PATH%
- Rename
C:\Program Files\TortoiseHG\hg.exe
tohg4.9.0.exe
- Check
hg --version
from the fresh command prompt
- Download
thg
sources from the repository https://bitbucket.org/tortoisehg/thg/src
hg clone https://bitbucket.org/tortoisehg/thg/src -r 4.9.0 c:\opt\thg-src
- Copy tortoisehg package from sources to the virtual environment
Copy folder
C:\opt\thg-src\tortoisehg
toC:\opt\hg\Lib\site-packages