[PATCH 5 of 5] chg: forward umask from client to server
Jun Wu
quark at fb.com
Mon Feb 15 09:42:53 EST 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1455546926 0
# Mon Feb 15 14:35:26 2016 +0000
# Node ID 0dbc77c19a3790c0746838c84f7325475cce0f65
# Parent 35ad63ce921c694c506304e36486063c1cc7f9c5
chg: forward umask from client to server
This is necessary to make chg test pass on test-inherit-mode.t.
diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -33,6 +33,7 @@
CAP_CHDIR = 0x0200,
CAP_GETPAGER = 0x0400,
CAP_SETENV = 0x0800,
+ CAP_UMASK = 0x1000,
};
typedef struct {
@@ -47,6 +48,7 @@
{"chdir", CAP_CHDIR},
{"getpager", CAP_GETPAGER},
{"setenv", CAP_SETENV},
+ {"umask", CAP_UMASK},
{NULL, 0}, /* terminator */
};
@@ -385,6 +387,17 @@
writeblockrequest(hgc, "chdir");
}
+static void forwardumask(hgclient_t *hgc)
+{
+ mode_t mask = umask(0);
+ int n = snprintf(hgc->ctx.data, hgc->ctx.maxdatasize, "%d", mask);
+ if (n >= (int)hgc->ctx.maxdatasize || n <= 0)
+ abortmsg("unexpected umask length (%d)", n);
+ hgc->ctx.datasize = (size_t)n;
+ writeblockrequest(hgc, "umask");
+ umask(mask);
+}
+
/*!
* Open connection to per-user cmdserver
*
@@ -433,6 +446,8 @@
attachio(hgc);
if (hgc->capflags & CAP_CHDIR)
chdirtocwd(hgc);
+ if (hgc->capflags & CAP_UMASK)
+ forwardumask(hgc);
return hgc;
}
More information about the Mercurial-devel
mailing list