[PATCH] posix: add configuration option to ignore execution mode changes (issue3301)

A. S. Budden abudden at gmail.com
Fri Mar 2 06:20:04 CST 2012


# HG changeset patch
# User A. S. Budden <abudden at gmail.com>
# Date 1330690534 0
# Node ID 105fae68f78292cebd41e118bc68b24c171fa553
# Parent  85db991780b7b86913c3e29a5fe7ef25ab5ee93c
posix: add configuration option to ignore execution mode changes (issue3301)

Using a posix version of Mercurial on a filesystem (such as FAT)
without support for the executable bit can result in Mercurial
erroneously reporting/committing executable bit changes.

This patch adds an 'ignoreexec' option to the 'ui' field in hgrc
to allow a user to make the posix version act like the Windows
version and ignore execution mode changes.  This is roughly
equivalent to Git's core.filemode option.

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -1017,7 +1017,9 @@
         self.opener = scmutil.opener(self.wc)
         self.wopener = scmutil.opener(self.wc)
         self.childmap = mapfile(ui, self.join('hg-childmap'))
-        self.is_exec = util.checkexec(self.wc) and util.isexec or None
+        self.is_exec = util.checkexec(self.wc) \
+                and not ui.config('ui', 'ignoreexec', False) \
+                and util.isexec or None
 
         if created:
             hook = os.path.join(created, 'hooks', 'pre-revprop-change')
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -143,7 +143,10 @@
 
     @propertycache
     def _checkexec(self):
-        return util.checkexec(self._root)
+        if self._ui.config('ui', 'ignoreexec', False):
+            return False
+        else:
+            return util.checkexec(self._root)
 
     @propertycache
     def _checkcase(self):
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1097,6 +1097,10 @@
     ``ignore.other = ~/.hgignore2``. For details of the ignore file
     format, see the ``hgignore(5)`` man page.
 
+``ignoreexec``
+    Ignore changes to the execution mode on files being committed.  True
+	or False.  Default is False.
+
 ``interactive``
     Allow to prompt the user. True or False. Default is True.
 
diff --git a/tests/test-execute-bit.t b/tests/test-execute-bit.t
--- a/tests/test-execute-bit.t
+++ b/tests/test-execute-bit.t
@@ -26,3 +26,18 @@
   $ test -x a && echo executable -- bad || echo not executable -- good
   not executable -- good
 
+test ignoreexec option
+
+  $ hg up tip
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo b > b
+  $ hg ci -Am'not executable'
+  adding b
+
+  $ chmod +x b
+  $ hg st
+  M b
+  $ echo '[ui]' >> .hg/hgrc
+  $ echo 'ignoreexec = True' >> .hg/hgrc
+  $ hg st
+


More information about the Mercurial-devel mailing list