[Fwd: Re: Using win32_symlinks outside bazaar]

Alexander Belchenko bialix at ukr.net
Fri Oct 26 16:35:25 BST 2007


I don't know what to answer to this guy on his question:

"I was not aware of Bazaar and its use by the Ubuntu team and have only
become aware of mercurial through the MoinMoin people using it; we have
been using subversion.
I am curious, is there a paper somewhere which explains why one might
wish to use Bazaar rather than either Mercurial or subversion?"


Someone help me with this: "Is there a paper somewhere which  explains 
why one might wish to use Bazaar rather than either Mercurial or 
subversion?"

Alexander


-------- Исходное сообщение --------
Тема: 	Re: Using win32_symlinks outside bazaar
Дата: 	Fri, 26 Oct 2007 15:21:03 +0000 (GMT)
От: 	picogoogolplex-utility at yahoo.co.uk
Кому: 	Alexander Belchenko <bialix at ukr.net>



Alexander,

I have done what you said and successfully made it work. It was the use
of bzrlib.osutils.file_kind in the __init__.py to determine the mode
that made me think that there was a dependency on this code.

Xapian uses the presence of a symbolic link as a locking mechanism and
therefore rewriting these to look for a fake symlink was easy.

The speed implications are not paramount as I develop on windows, where
performance is not critical, but deploy on linux where the problem does
not present itself.

I was not aware of Bazaar and its use by the Ubuntu team and have only
become aware of mercurial through the MoinMoin people using it; we have
been using subversion.
I am curious, is there a paper somewhere which explains why one might
wish to use Bazaar rather than either Mercurial or subversion?

Thanks very much for your time, regards,

Tim

----- Original Message ----
From: Alexander Belchenko <bialix at ukr.net>
To: picogoogolplex-utility at yahoo.co.uk
Sent: Friday, 26 October, 2007 9:18:12 AM
Subject: Re: Using win32_symlinks outside bazaar

picogoogolplex-utility at yahoo.co.uk пишет:
  > Is it possible to point me to the bazaar source files I will need to
be able to reuse your win32_symlinks code (e.g. bzrlib.osutils)?
  >
  > I use the MoinMoin wiki and the developers in v1.6 have just
introduced Xapian text indexing.
  >
  > However, whereas MoinMoin and Xapian are cross platform, it seems
that the Xapian python bindings require symlink, readlink and remove and
therefore limit this method of indexing to posix systems.
  >
  > I thought that I could reuse your code to get my MoinMoin pages indexed.
  >
  > Hope you can help, regards,
  >
  > Tim

Hi Tim,

I have no idea what is Xapian and how it works,
but I could try to help you.

First at all: my module *does not* provide any real symlinks
support for windows platform. You need to understand this.
If Xapian require *real* symlinks and expects that underlying
OS will follow symlinks to files or directories --
you will failed every time. My code create *fake* symlinks,
that could be used from within python code,
but actually these symlinks are regular files on disks.

2) win32_symlinks already lives outside bazaar,
it's just plugin. You can download my code from Launchpad:
https://launchpad.net/bzr-win32symlinks

When you get my code you'll see win32_symlinks.py module
that do all actual job. The code could looks strange
and overcomplicated, but only because I tried to reach
one important point: I want to create fake symlinks
that will be compatible with Cygwin. So if you create
symlink with my code, and then run Cygwin -- you should see
in Cygwin *real* cygwin-style symlink. And yeah -- then
Cygwin will treat them as symlinks and follow them
as on regular unix platforms.

3) because it's *fake* symlinks that actually are files
on disk, you could do it in really simple way: just write
link target to file to create symlink and read from disk
for readlink. That's basically all. But you have no way
to say from python code is any particular file is symlink
or not. In my code I used cygwin approach to differentiate
them (by setting SYSTEM file attribute).

4) To differentiate between regular files and symlinks
*from within bzrlib* I do special check for *all* files
as described in my code. And this check slow down
things. Keep this in mind.

5) If you still interested to use my code, you basically
should do following:

    a) as early as possible import stadard python os module
       and monkeypatch it to inject 2 functions (symlink and
       readlink) from my win32_symlinks.py module. This step
       will allow any python program to use this functions
       without typical NameError traceback (because these
       functions is simply absent in windows version of Python).
       You should monkeypatching os module before any
       main modules of Xapian or MoinMoin will be loaded,
       otherwise they will not see your injection.
    b) you should decide how the best to cheat Xapian and
       teach it to differentiate between regular files and
       fake symlinks. In bzrlib I override methods in
       bzrlib.osutils module (file_kind, isfile, islink).
       In stadard os.path module there is function islink,
       so in simplest case you need only replace this
       function with your custom equivalent (you can look
       in my code __init__.py function islink as example).
       But if Xapian use os.stat info to obtain info
       about symlinks, you'll need to monkeypatch
       os.stat/os.lstat functions as well.

I hope this information is enough to start for you.
And if you need real support for symlinks from OS,
you should consider to using Cygwin on Windows.
Then you don't need my fake symlinks at all, because
Cygwin already emulate it inside.

Alexander




More information about the bazaar mailing list