Using Mercurial on DOS

These are my notes on how to get the Mercurial version control system running on DOS (at least for local use). I have not done extensive testing, so this is more of a proof of concept.


  1. Install PythonD (a port of Python 2.4.2 to DOS). It requires a 386 or later processor, long filename support (provided by DOSLFN, for example), and a packet driver (for networking, without which it will not run). If you don't have a network card or you want to use it offline, use NULLPKT (run it as NULLPKT 0x60).
  2. Download Mercurial 3.4.2. This is the last version compatible with Python 2.4.x. Extract the downloaded file. It will create a directory called mercurial-3.4.2.
  3. Copy or move all files from mercurial-3.4.2\mercurial\pure to its parent directory. Warning: their names must stay lowercase. Note that has a long filename as well.
  4. In mercurial-3.4.2\hg, replace line 18 with: libdir = '../lib/python2.4/site-packages/'
  5. In mercurial-3.4.2\mercurial\
    1. Comment out (or remove) lines 962 and 963.
    2. Replace line 485 with: code = os.system(cmd.replace("/", "\\"))
    3. Replace line 683 with: rc = os.system(cmd.replace("/", "\\"))
    4. Comment out lines 677 and 678 and add (or replace them with): if sys.platform == 'ms-dos5':
  6. In mercurial-3.4.2\mercurial\, replace line 18 with: import scmdos as scmplatform
  7. Create mercurial-3.4.2\mercurial\ with the contents:
    def systemrcpath():
        return []

    userrcpath = systemrcpath
  8. Copy or move the directories to %PYTHONHOME%\lib\python2.4\site-packages\, where %PYTHONHOME% is the directory where you installed PythonD (it contains the directories bin, lib, etc.). You will need a program that can copy long filenames. One such program is Necromancer's DOS Navigator. XCOPY (1.4) in FreeDOS and XCOPY in Windows 98 cannot(?).
  9. Copy the file mercurial-3.4.2\hg to %PYTHONHOME%\bin\.
  10. If you did all this right, running %PYTHONHOME%\bin\python\python24 %PYTHONHOME%\bin\hg will print Mercurial's usage instructions. You will probably want to make a batch file or alias to make it easier to run.
  11. Create your Mercurial configuration file and put it in whatever location. It should at least contain your name to use in commit messages: [ui]
    username = Your Name <>
  12. Set the environment variable EDITOR to the full path and name of your preferred text editor (which must support long filenames) and HGRCPATH to the full path and name of your Mercurial configuration file. You will probably want to do that a batch file too.

Known problems

First published on .
Last updated on .

Table of contents

Contact me