[PATCH 1 of 3] purge: enable to purge with outstanding changes on case sensitive filesystems

Gilles Moris gilles.moris at free.fr
Thu Apr 10 02:10:25 CDT 2008


8 files changed, 120 insertions(+), 38 deletions(-)
hgext/purge.py                     |   13 ++++++-----
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 --------


# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1207810210 -7200
# Node ID 1bd769993474e4b9131e228658f9d113adbedc97
# Parent  03d728621d90d35493794045cc08c25f15580c9c
purge: enable to purge with outstanding changes on case sensitive filesystems

Because of the partial support of case folding filesystems, purge without
--force was even forbidden on case sensitive filesystems.
Tests for purge have been splitted with specific tests for case sensitive and
case folding file systems.

diff --git a/hgext/purge.py b/hgext/purge.py
--- a/hgext/purge.py
+++ b/hgext/purge.py
@@ -92,12 +92,13 @@
 
     # We can't use (files, match) to do a partial walk here - we wouldn't
     # notice a modified README file if the user ran "hg purge readme"
-    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"))
 
 
 def purge(ui, repo, *dirs, **opts):
diff --git a/tests/hghave b/tests/hghave
--- a/tests/hghave
+++ b/tests/hghave
@@ -118,6 +118,25 @@
     except ImportError:
         return False
 
+def has_casesensitive_fs():
+    d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
+    p1 = os.path.join(d, 'testcase')
+    p2 = os.path.join(d, 'TESTCASE')
+    f = open(p1, 'w')
+    f.close()
+    try:
+        s1 = os.stat(p1)
+        s2 = os.stat(p2)
+        if s2 == s1:
+            ret = False
+        else:
+            ret = True
+    except:
+        ret = True
+    os.unlink(p1)
+    os.rmdir(d)
+    return ret
+
 checks = {
     "baz": (has_baz, "GNU Arch baz client"),
     "cvs": (has_cvs, "cvs client"),
@@ -136,6 +155,7 @@
     "tla": (has_tla, "GNU Arch tla client"),
     "unix-permissions": (has_unix_permissions, "unix-style permissions"),
     "pygments": (has_pygments, "Pygments source highlighting library"),
+    "casesensitive-fs": (has_casesensitive_fs, "case sensitive file system"),
 }
 
 def list_features():
diff --git a/tests/test-purge b/tests/test-purge
--- a/tests/test-purge
+++ b/tests/test-purge
@@ -78,29 +78,6 @@
 hg purge -v --all
 ls
 
-echo % abort with missing files until we support name mangling filesystems
-touch untracked_file
-rm r1
-# hide error messages to avoid changing the output when the text changes
-hg purge -p 2> /dev/null
-if [ $? -ne 0 ]; then
-    echo "refused to run"
-fi
-if [ -f untracked_file ]; then
-    echo "untracked_file still around"
-fi
-hg purge -p --force
-hg purge -v 2> /dev/null
-if [ $? -ne 0 ]; then
-    echo "refused to run"
-fi
-if [ -f untracked_file ]; then
-    echo "untracked_file still around"
-fi
-hg purge -v --force
-hg revert --all --quiet
-ls
-
 echo '% tracked file in ignored directory (issue621)'
 echo directory >> .hgignore
 hg ci -m 'ignore directory'
diff --git a/tests/test-purge-casefolding b/tests/test-purge-casefolding
new file mode 100755
--- /dev/null
+++ b/tests/test-purge-casefolding
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" no-casesensitive-fs || exit 80
+
+cat <<EOF >> $HGRCPATH
+[extensions]
+hgext.purge=
+EOF
+
+echo % init
+hg init t
+cd t
+
+echo % setup
+echo r1 > r1
+hg ci -qAmr1 -d'0 0'
+
+echo % abort with missing files until we support name mangling filesystems
+touch untracked_file
+rm r1
+# hide error messages to avoid changing the output when the text changes
+hg purge -p 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "refused to run"
+fi
+if [ -f untracked_file ]; then
+    echo "untracked_file still around"
+fi
+hg purge -p --force
+hg purge -v 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "refused to run"
+fi
+if [ -f untracked_file ]; then
+    echo "untracked_file still around"
+fi
+hg purge -v --force
+ls
+
+
diff --git a/tests/test-purge-casefolding.out b/tests/test-purge-casefolding.out
new file mode 100644
--- /dev/null
+++ b/tests/test-purge-casefolding.out
@@ -0,0 +1,9 @@
+% init
+% setup
+% abort with missing files until we support name mangling filesystems
+refused to run
+untracked_file still around
+untracked_file
+refused to run
+untracked_file still around
+Removing file untracked_file
diff --git a/tests/test-purge-casesensitive b/tests/test-purge-casesensitive
new file mode 100755
--- /dev/null
+++ b/tests/test-purge-casesensitive
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" casesensitive-fs || exit 80
+
+cat <<EOF >> $HGRCPATH
+[extensions]
+hgext.purge=
+EOF
+
+echo % init
+hg init t
+cd t
+
+echo % setup
+echo r1 > r1
+hg ci -qAmr1 -d'0 0'
+
+echo % do not abort with missing files on case sensitive filesystems
+touch untracked_file
+rm r1
+# hide error messages to avoid changing the output when the text changes
+hg purge -p 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "refused to run"
+fi
+if [ -f untracked_file ]; then
+    echo "untracked_file still around"
+fi
+hg purge -v 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "refused to run"
+fi
+if [ -f untracked_file ]; then
+    echo "untracked_file still around"
+fi
+ls
+
+
diff --git a/tests/test-purge-casesensitive.out b/tests/test-purge-casesensitive.out
new file mode 100644
--- /dev/null
+++ b/tests/test-purge-casesensitive.out
@@ -0,0 +1,6 @@
+% init
+% setup
+% do not abort with missing files on case sensitive filesystems
+untracked_file
+untracked_file still around
+Removing file untracked_file
diff --git a/tests/test-purge.out b/tests/test-purge.out
--- a/tests/test-purge.out
+++ b/tests/test-purge.out
@@ -50,15 +50,6 @@
 Removing file ignored
 directory
 r1
-% abort with missing files until we support name mangling filesystems
-refused to run
-untracked_file still around
-untracked_file
-refused to run
-untracked_file still around
-Removing file untracked_file
-directory
-r1
 % tracked file in ignored directory (issue621)
 untracked_file
 Removing file untracked_file


More information about the Mercurial-devel mailing list