[PATCH 0 of 3] purge and case sensitive/insensitive file systems

Gilles Moris gilles.moris at free.fr
Thu Apr 10 07:10:24 UTC 2008


Hello,

I came across a specific behavior of the purge extension that does not allow
to purge without --force when some tracked files are added, removed, modified
or deleted.
The comments in the code are explaining that this is only due to case mangling
file systems:

def _check_fs(ui, repo):
    """Abort if there is the chance of having problems with name-mangling fs

    In a name mangling filesystem (e.g. a case insensitive one)
    dirstate.walk() can yield filenames different from the ones
    stored in the dirstate. This already confuses the status and
    add commands, but with purge this may cause data loss.

    To prevent this, this function will abort if there are uncommitted
    changes.
    """

Is there still possible problems with the nowdays implementation of mercurial ?
Possibly yes, as I seen some messages on this topic recently.

1. Curiously, the code makes us use the --force whatever the file system type.
I am proposing to avoid the use of the --force on case sensitive file systems.
Further down the _check_fs() function:

-    modified, added, removed, deleted = repo.status()[:4]
-    if modified or added or removed or deleted:
-        if not util.checkfolding(repo.path) and not ui.quiet:
-            ui.warn(_("Purging on name mangling filesystems is not "
-                      "fully supported.\n"))
-        raise util.Abort(_("outstanding uncommitted changes"))
+    if not util.checkfolding(repo.path):
+        modified, added, removed, deleted = repo.status()[:4]
+        if modified or added or removed or deleted:
+            if not ui.quiet:
+                ui.warn(_("Purging on name mangling filesystems is not "
+                          "fully supported.\n"))
+            raise util.Abort(_("outstanding uncommitted changes"))

2. You will also notice the util.checkfolding() function is counter-intuitive:
it is returning True if the file systems is actually case sensitive. We can:
2.a. Rename it to something like case_sensitive_fs(), though it breaks the API
     (PATCH 2)
2.b. Possibly keep the same name but invert the returned boolean value, which is
     something I don't like because it will silently break extensions/patches
     using it.
2.c. Do nothing. This is pointless or not desirable.

3. I clarified the help of purge about ignored files (already submitted).
   (PATCH 3)

Regards.
Gilles.


11 files changed, 126 insertions(+), 44 deletions(-)
hgext/purge.py                     |   19 +++++++++--------
mercurial/commands.py              |    2 -
mercurial/merge.py                 |    2 -
mercurial/util.py                  |    2 -
tests/hghave                       |   20 ++++++++++++++++++
tests/test-purge                   |   23 --------------------
tests/test-purge-casefolding       |   40 ++++++++++++++++++++++++++++++++++++
tests/test-purge-casefolding.out   |    9 ++++++++
tests/test-purge-casesensitive     |   38 ++++++++++++++++++++++++++++++++++
tests/test-purge-casesensitive.out |    6 +++++
tests/test-purge.out               |    9 --------


More information about the Mercurial-devel mailing list