[PATCH 5 of 5 V2] chg: forward umask from client to server

Jun Wu quark at fb.com
Tue Feb 16 14:50:26 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 85f8838dcd9afd49b1a3ded8fb8193b8126a3a04
# Parent  0e71344230a9d312b22fcb4a08c8da7399cd07b2
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_SETUMASK = 0x1000,
 };
 
 typedef struct {
@@ -47,6 +48,7 @@
 	{"chdir", CAP_CHDIR},
 	{"getpager", CAP_GETPAGER},
 	{"setenv", CAP_SETENV},
+	{"setumask", CAP_SETUMASK},
 	{NULL, 0},  /* terminator */
 };
 
@@ -385,6 +387,17 @@
 	writeblockrequest(hgc, "chdir");
 }
 
+static void forwardumask(hgclient_t *hgc)
+{
+	mode_t mask = umask(0);
+	umask(mask);
+
+	const char command[] = "setumask\n";
+	sendall(hgc->sockfd, command, sizeof(command) - 1);
+	uint32_t data = htonl(mask);
+	sendall(hgc->sockfd, &data, sizeof(data));
+}
+
 /*!
  * Open connection to per-user cmdserver
  *
@@ -433,6 +446,8 @@
 		attachio(hgc);
 	if (hgc->capflags & CAP_CHDIR)
 		chdirtocwd(hgc);
+	if (hgc->capflags & CAP_SETUMASK)
+		forwardumask(hgc);
 
 	return hgc;
 }


More information about the Mercurial-devel mailing list