Submitter | Jun Wu |
---|---|
Date | March 21, 2017, 12:04 a.m. |
Message ID | <c8693bc1191b3ac1af0a.1490054679@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/19484/ |
State | Accepted |
Headers | show |
Comments
On 3/21/17 12:04 AM, Jun Wu wrote: > # HG changeset patch > # User Jun Wu <quark@fb.com> > # Date 1490052852 25200 > # Mon Mar 20 16:34:12 2017 -0700 > # Node ID c8693bc1191b3ac1af0a67e97068777b13cfa672 > # Parent f710d54d1985975d7d37aa58e9d5740ebdcf5b7b > osutil: export a "getfstype" method > > This patch exports the "getfstype" method. So we can use it to enable > hardlinks for known safe filesystems. This series looks good to me. I had only a small nit on the first patch, which could potentially be fixed in-flight. > > The patch was tested manually via debugshell on a Linux system. > "mercurial.osutil.getfstype" works as expected. It's hard to mount > filesystem on user-space easily. I will add a test for real hardlink support > to indirectly test this patch, after turning on real hardlinks support for > certain whitelisted filesystems. > > diff --git a/mercurial/osutil.c b/mercurial/osutil.c > --- a/mercurial/osutil.c > +++ b/mercurial/osutil.c > @@ -1080,4 +1080,18 @@ const char *getfstype(const char *path) > return NULL; > } > + > +static PyObject *pygetfstype(PyObject *self, PyObject *args) > +{ > + const char *path = NULL; > + if (!PyArg_ParseTuple(args, "s", &path)) > + return NULL; > + > + const char *type = getfstype(path); > + if (type == NULL) > + Py_RETURN_NONE; > + > + PyObject *result = Py_BuildValue("s", type); > + return result; > +} > #endif /* def HAVE_STATFS */ > > @@ -1258,4 +1272,8 @@ static PyMethodDef methods[] = { > "set process title (best-effort)\n"}, > #endif > +#ifdef HAVE_STATFS > + {"getfstype", (PyCFunction)pygetfstype, METH_VARARGS, > + "get filesystem type (best-effort)\n"}, > +#endif > #endif /* ndef _WIN32 */ > #ifdef __APPLE__ >
On Mon, Mar 20, 2017 at 05:04:39PM -0700, Jun Wu wrote: > # HG changeset patch > # User Jun Wu <quark@fb.com> > # Date 1490052852 25200 > # Mon Mar 20 16:34:12 2017 -0700 > # Node ID c8693bc1191b3ac1af0a67e97068777b13cfa672 > # Parent f710d54d1985975d7d37aa58e9d5740ebdcf5b7b > # Available At https://bitbucket.org/quark-zju/hg-draft > # hg pull https://bitbucket.org/quark-zju/hg-draft -r c8693bc1191b > osutil: export a "getfstype" method Thank you for sticking with this - this looks like what I had hoped the first round could be. The statfs method is exactly what we needed. Queued the whole thing. > > This patch exports the "getfstype" method. So we can use it to enable > hardlinks for known safe filesystems. > > The patch was tested manually via debugshell on a Linux system. > "mercurial.osutil.getfstype" works as expected. It's hard to mount > filesystem on user-space easily. I will add a test for real hardlink support > to indirectly test this patch, after turning on real hardlinks support for > certain whitelisted filesystems. > > diff --git a/mercurial/osutil.c b/mercurial/osutil.c > --- a/mercurial/osutil.c > +++ b/mercurial/osutil.c > @@ -1080,4 +1080,18 @@ const char *getfstype(const char *path) > return NULL; > } > + > +static PyObject *pygetfstype(PyObject *self, PyObject *args) > +{ > + const char *path = NULL; > + if (!PyArg_ParseTuple(args, "s", &path)) > + return NULL; > + > + const char *type = getfstype(path); > + if (type == NULL) > + Py_RETURN_NONE; > + > + PyObject *result = Py_BuildValue("s", type); > + return result; > +} > #endif /* def HAVE_STATFS */ > > @@ -1258,4 +1272,8 @@ static PyMethodDef methods[] = { > "set process title (best-effort)\n"}, > #endif > +#ifdef HAVE_STATFS > + {"getfstype", (PyCFunction)pygetfstype, METH_VARARGS, > + "get filesystem type (best-effort)\n"}, > +#endif > #endif /* ndef _WIN32 */ > #ifdef __APPLE__ > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/osutil.c b/mercurial/osutil.c --- a/mercurial/osutil.c +++ b/mercurial/osutil.c @@ -1080,4 +1080,18 @@ const char *getfstype(const char *path) return NULL; } + +static PyObject *pygetfstype(PyObject *self, PyObject *args) +{ + const char *path = NULL; + if (!PyArg_ParseTuple(args, "s", &path)) + return NULL; + + const char *type = getfstype(path); + if (type == NULL) + Py_RETURN_NONE; + + PyObject *result = Py_BuildValue("s", type); + return result; +} #endif /* def HAVE_STATFS */ @@ -1258,4 +1272,8 @@ static PyMethodDef methods[] = { "set process title (best-effort)\n"}, #endif +#ifdef HAVE_STATFS + {"getfstype", (PyCFunction)pygetfstype, METH_VARARGS, + "get filesystem type (best-effort)\n"}, +#endif #endif /* ndef _WIN32 */ #ifdef __APPLE__