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.
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).
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.
Copy or move all files from mercurial-3.4.2\mercurial\pure to its parent directory. Warning: their names must stay lowercase. Note that diffhelpers.py has a long filename as well.
In mercurial-3.4.2\hg, replace line 18 with: libdir = '../lib/python2.4/site-packages/'
Comment out (or remove) lines 962 and 963.
Replace line 485 with: code = os.system(cmd.replace("/", "\\"))
Replace line 683 with: rc = os.system(cmd.replace("/", "\\"))
Comment out lines 677 and 678 and add (or replace them with): if sys.platform == 'ms-dos5':
In mercurial-3.4.2\mercurial\scmutil.py, replace line 18 with: import scmdos as scmplatform
Create mercurial-3.4.2\mercurial\scmdos.py with the contents:
userrcpath = systemrcpath
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(?).
Copy the file mercurial-3.4.2\hg to %PYTHONHOME%\bin\.
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.
Create your Mercurial configuration file and put it in whatever location. It should at least contain your name to use in commit messages:
username = Your Name <your.email@address>
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.
Mercurial will take a few seconds to start, even on a very fast computer (for DOS standards) and even on a RAM disk. It seems that PythonD is just very slow.
If running hg log gives you the error ValueError: invalid literal for int(): ., try deleting .hg\store\phaseroots. I don't know why this happens or why this solves it.
If you terminated Mercurial with Ctrl+C and you get the message waiting for lock on working directory when running it the next time, delete the file .hg\wlock.
PythonD supports networking, but not SSL.
If you use a batch file to start Mercurial, you will be unable to redirect or pipe its output, which makes certain commands (such as hg log) hard to use. You can use an alias if your command interpreter supports it or pipe Mercurial's output to TEE inside the batch file as a workaround.