Patchwork [STABLE] largefiles: avoid exec-bit examination on the platform being unaware of it

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 24, 2014, 2:21 p.m.
Message ID <d47e371f9abe39460340.1416838890@juju>
Download mbox | patch
Permalink /patch/6837/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Nov. 24, 2014, 2:21 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1416838654 -32400
#      Mon Nov 24 23:17:34 2014 +0900
# Branch stable
# Node ID d47e371f9abe39460340b77738b672001841b054
# Parent  cc0ff93d0c0c29526465a1d07b9eddf5b2da51dd
largefiles: avoid exec-bit examination on the platform being unaware of it

Changeset 24600c9d7f4e introduced the examination of exec bit of
largefiles in "hg status --rev REV" case, but it doesn't avoid it on
the platform being unaware of exec-bit (e.g. on NTFS of Windows).

To avoid leak of internal implementation of "dirstate" class, this
patch uses "util.checkexec" instead of "dirstate._checkexec", even
though the former costs (a little) more than the latter when the
latter is already cached. This kind of information may have to be
cached at VFS layer in the future.
Matt Mackall - Nov. 24, 2014, 8:07 p.m.
On Mon, 2014-11-24 at 23:21 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1416838654 -32400
> #      Mon Nov 24 23:17:34 2014 +0900
> # Branch stable
> # Node ID d47e371f9abe39460340b77738b672001841b054
> # Parent  cc0ff93d0c0c29526465a1d07b9eddf5b2da51dd
> largefiles: avoid exec-bit examination on the platform being unaware of it
> 
> Changeset 24600c9d7f4e introduced the examination of exec bit of
> largefiles in "hg status --rev REV" case, but it doesn't avoid it on
> the platform being unaware of exec-bit (e.g. on NTFS of Windows).
> 
> To avoid leak of internal implementation of "dirstate" class, this
> patch uses "util.checkexec" instead of "dirstate._checkexec", even
> though the former costs (a little) more than the latter when the
> latter is already cached. This kind of information may have to be
> cached at VFS layer in the future.

I think it's ok to use dirstate._checkexec here. The underscore is
advisory: think of it as like C++'s "friend" rather than "private".
Katsunori FUJIWARA - Nov. 25, 2014, 5:21 a.m.
At Mon, 24 Nov 2014 14:07:21 -0600,
Matt Mackall wrote:
> 
> On Mon, 2014-11-24 at 23:21 +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1416838654 -32400
> > #      Mon Nov 24 23:17:34 2014 +0900
> > # Branch stable
> > # Node ID d47e371f9abe39460340b77738b672001841b054
> > # Parent  cc0ff93d0c0c29526465a1d07b9eddf5b2da51dd
> > largefiles: avoid exec-bit examination on the platform being unaware of it
> > 
> > Changeset 24600c9d7f4e introduced the examination of exec bit of
> > largefiles in "hg status --rev REV" case, but it doesn't avoid it on
> > the platform being unaware of exec-bit (e.g. on NTFS of Windows).
> > 
> > To avoid leak of internal implementation of "dirstate" class, this
> > patch uses "util.checkexec" instead of "dirstate._checkexec", even
> > though the former costs (a little) more than the latter when the
> > latter is already cached. This kind of information may have to be
> > cached at VFS layer in the future.
> 
> I think it's ok to use dirstate._checkexec here. The underscore is
> advisory: think of it as like C++'s "friend" rather than "private".

OK. I'll post V2 using "dirstate._checkexec".


> -- 
> Mathematics is the supreme nostalgia of our time.
> 
> 
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -170,6 +170,7 @@  def reposetup(ui, repo):
                     else:
                         tocheck = unsure + modified + added + clean
                         modified, added, clean = [], [], []
+                        checkexec = util.checkexec(self.root)
 
                         for lfile in tocheck:
                             standin = lfutil.standin(lfile)
@@ -177,7 +178,8 @@  def reposetup(ui, repo):
                                 abslfile = self.wjoin(lfile)
                                 if ((ctx1[standin].data().strip() !=
                                      lfutil.hashfile(abslfile)) or
-                                    (('x' in ctx1.flags(standin)) !=
+                                    (checkexec and
+                                     ('x' in ctx1.flags(standin)) !=
                                      bool(lfutil.getexecutable(abslfile)))):
                                     modified.append(lfile)
                                 elif listclean:
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -577,6 +577,31 @@  the working context)
   $ hg status -A --rev '.^1' large2
   M large2
 
+#else
+
+Test that "hg status" against revisions other than parent ignores exec
+bit correctly on the platform being unaware of it.
+
+  $ hg update -q -C 4
+
+  $ cat > exec-bit.patch <<EOF
+  > # HG changeset patch
+  > # User test
+  > # Date 0 0
+  > #      Thu Jan 01 00:00:00 1970 +0000
+  > # Node ID be1b433a65b12b27b5519d92213e14f7e1769b90
+  > # Parent  07d6153b5c04313efb75deec9ba577de7faeb727
+  > chmod +x large2
+  > 
+  > diff --git a/.hglf/large2 b/.hglf/large2
+  > old mode 100644
+  > new mode 100755
+  > EOF
+  $ hg import --exact --bypass exec-bit.patch
+  applying exec-bit.patch
+  $ hg status -A --rev tip large2
+  C large2
+
 #endif
 
   $ cd ..