Internals question - localrepo.sjoin/rjoin

Paul Moore p.f.moore at gmail.com
Mon Apr 14 11:58:13 CDT 2008


I'm looking at how Mercurial handles OS and internal file names
(background - I'm trying to get a handle on where there are case
insensitivity issues). To that end, I'm treating filenames as one of
two types - OS (using os.sep to separate path components, potentially
case insensitive) and internal (using / always, and in effect case
insensitive).

Now, in localrepo.py there are a number of local repository helper
functions. Things like localrepo.join(f) which does an os.path.join of
self.path and f. This clearly takes an OS path and returns an OS path.

But sjoin and pjoin are harder.

rjoin takes an os.path.join of self.root and pconvert(f) - but
util.pconvert converts os.sep to forward slashes! This is
inconsistent.

sjoin is a little more subtle. It does os.path.join on spath and an
encoded copy of f. But encodefn (which is util.encodefilename) takes a
path and converts any "difficult" characters to encoded versions. The
set of "difficult" characters includes \, and does NOT include /. So
it seems to me that encodefn is expecting to receive an "internal"
filename, and return an "internal" filename. This is again
inconsistent.

Can anyone clarify for me? I'd be interested to hear comments on 2 levels:

1. Is my analysis of paths as "OS" or "internal" sensible (and if not,
how should I look at this)?
2. What are rjoin and sjoin *meant* to do, in terms of the path
structure they should return (if I ignore path separator issues, the
answer is pretty obvious, so don't worry about that).

Thanks,
Paul.


More information about the Mercurial-devel mailing list