Mercurial 1.8.3 on Jython 2.5.2

Adrian Buehlmann adrian at cadifra.com
Thu May 12 08:00:41 UTC 2011


On 2011-05-12 09:29, Sébastien Deleuze wrote:
> OK, understood, I tried to import java module, wich has nothing to do
> with posix ou windows modules.
> 
> I also tried with import windows, but if I do I got error sine it uses ctypes:
> 
>     _kernel32 = ctypes.windll.kernel32
>   File "C:\jython2.5.2\Lib\site-packages\mercurial\demandimport.py", line 76, in
>  __getattribute__
>     return getattr(self._module, attr)
> AttributeError: 'module' object has no attribute 'windll'
> 
>>From what I understand, the only way to make it work is to write a
> pure equivalent of posix.py or win32.py.
> Do you think it is technicaly possible ?

No. Unless you find a way to access the plain win32 API functions

  CreateHardLink
  CreateFile
  GetFileInformationByHandle

> A major issue may be that java runtime don't care about file
> permissions (at least in java6/7, it may be the case in java 8), but
> for read only capabilities it may be not an issue for me.

The really problematic thing for a Python program is finding out how
many hardlinks a file has on Windows.

For example CPython's

  os.lstat(pathname).st_nlink

is always zero on Windows, even if pathname points to a file with hardlinks.

Mercurial on Windows (at least the CPython based installers available)
create hardlinked clones when cloning locally on a NTFS volume.

  http://mercurial.selenic.com/wiki/HardlinkedClones

Committing or pushing to such a hardlinked repo needs a Mercurial which
is capable of detecting (and breaking up) hardlinks, or repository
corruption will ensue (detectable by 'hg verify', but you won't notice
it until you actually *do* run 'hg verify').

The CPython based Mercurial uses an ingenious combination of C code (see
osutil.c, posixfile on line 405, solves [1]) and a ctypes based low
level module win32.py (functions oslink, nlinks) to create and detect
hardlinks inside .hg/store.

You would need to carefully replicate all that in Jython.

[1] http://mercurial.selenic.com/wiki/UnlinkingFilesOnWindows



More information about the Mercurial mailing list