editing of pages with different capitalization

Edit pages with different capitalization

it's possible to acces pages indipendently of their capitalization. The heading is displayed as in the url/link.

If you try to edit the page after accessing it in a different notation than the original, you will edit an empty page and create a new one loosing the history of the original.


Hatta's page titles are case-sensitive, meaning that "Page" and "page" and "PAGE" are all three different page titles. This behavior might be currently affected by a non-standard filesystem ignoring case in file names, if you store your repository on FAT or NTFS filesystem. I don't yet have an idea on how to handle those, I will probably have to come up with some name-mangling workaround, but no solution seems clean at the moment.

With current version, as a workaround, if you need page names that differ only with letter case, please use a standard-compliant (POSIX) filesystem to store the repository.

Thank you for pointing out this problem. – Radomir Dopieralski


this happens also on apple standart-HFS… a clean solution may be a config-flag to use lowercase filenames.


I mean standard as in standards that are actually published, obeyed by more than a single implementor and not patented :) Your suggestion is a great idea, now I just wonder if I can make it somehow work with existing capitalized page titles without having to convert the repository. – Radomir Dopieralski

This patch is a quick-and-dirty way to do it:

--- a/hatta.py	Mon Mar 02 08:35:43 2009 +0100
+++ b/hatta.py	Mon Mar 02 08:37:40 2009 +0100
@@ -303,15 +303,16 @@
         return path

     def _file_path(self, title):
-        return os.path.join(self.path, werkzeug.url_quote(title, safe=''))
+        return os.path.join(self.path, werkzeug.url_quote(title.lower(),
+                                                          safe=''))

     def _title_to_file(self, title):
         return os.path.join(self.repo_prefix,
-                            werkzeug.url_quote(title, safe=''))
+                            werkzeug.url_quote(title.lower(), safe=''))

     def _file_to_title(self, filename):
         name = filename[len(self.repo_prefix):].strip('/')
-        return werkzeug.url_unquote(name)
+        return werkzeug.url_unquote(name.lower())

     def __contains__(self, title):
         return os.path.exists(self._file_path(title))

Why not use Mercurial's internal handling for case-folding? Already it has to go through some non-trivial hoops to store case-sensitive files.

For instance, on my Mac with a case-insensitive file system:

$ cat COPYING | wc
     340    2968   17992
$ hg cat COPYING | wc
     340    2968   17992
$ cat copying | wc
     340    2968   17992
$ hg cat copying | wc
copying: No such file in rev 95403de86d5f
       0       0       0

I'm not sure what the performance penalty would be of using internal Mercurial routines to fetch files instead of using the file system, but maybe this could be a config file preference. — julian

As far as I know (I'm not 100% sure, so I will have to check that) those mechanisms are planned and not yet implemented in Mercurial. Currently it just refuses to update to any revision that would result in a filename clash. It does the escaping for its internal files (manifests and such), but I already access them through Mercurial's internal mechanisms, so nothing to improve here. Citing from CaseFoldingPlan:

On the working directory side, the best we can do is detect collisions.

This really makes me upset, because if the bright people who created Mercurial can't solve this issue, I have little hope for solving it myself. It's not completely hopeless, because a wiki is less general than a source control system, and because there are users with ideas much better than mine. Be sure that I keep this issue in my mind, and I will definitely try to fix it when I see a way that doesn't involve destroying all computers with a certain operating system on them ;) – Radomir Dopieralski


Issues