Patchwork [2,of,2] chg: upgrade client to use "setumask2" command

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 5, 2018, 1:30 p.m.
Message ID <4cb84ca878258306a364.1538746237@mimosa>
Download mbox | patch
Permalink /patch/35490/
State New
Headers show

Comments

Yuya Nishihara - Oct. 5, 2018, 1:30 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1538744917 -32400
#      Fri Oct 05 22:08:37 2018 +0900
# Node ID 4cb84ca878258306a364c6b1502081e469dabd64
# Parent  fea3ce7f43989d7fd50a04cf2f8ff402031cdbd8
chg: upgrade client to use "setumask2" command

No compatibility code is added to the client side, since it's unlikely for
new client to communicate with the old server.
Augie Fackler - Oct. 10, 2018, 8:25 a.m.
On Fri, Oct 05, 2018 at 10:30:37PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1538744917 -32400
> #      Fri Oct 05 22:08:37 2018 +0900
> # Node ID 4cb84ca878258306a364c6b1502081e469dabd64
> # Parent  fea3ce7f43989d7fd50a04cf2f8ff402031cdbd8
> chg: upgrade client to use "setumask2" command

queued, thanks

Patch

diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -32,7 +32,7 @@  enum { CAP_GETENCODING = 0x0001,
        CAP_ATTACHIO = 0x0100,
        CAP_CHDIR = 0x0200,
        CAP_SETENV = 0x0800,
-       CAP_SETUMASK = 0x1000,
+       CAP_SETUMASK2 = 0x1000,
        CAP_VALIDATE = 0x2000,
        CAP_SETPROCNAME = 0x4000,
 };
@@ -48,7 +48,7 @@  static const cappair_t captable[] = {
     {"attachio", CAP_ATTACHIO},
     {"chdir", CAP_CHDIR},
     {"setenv", CAP_SETENV},
-    {"setumask", CAP_SETUMASK},
+    {"setumask2", CAP_SETUMASK2},
     {"validate", CAP_VALIDATE},
     {"setprocname", CAP_SETPROCNAME},
     {NULL, 0}, /* terminator */
@@ -425,10 +425,11 @@  static void forwardumask(hgclient_t *hgc
 	mode_t mask = umask(0);
 	umask(mask);
 
-	static const char command[] = "setumask\n";
-	sendall(hgc->sockfd, command, sizeof(command) - 1);
 	uint32_t data = htonl(mask);
-	sendall(hgc->sockfd, &data, sizeof(data));
+	enlargecontext(&hgc->ctx, sizeof(data));
+	memcpy(hgc->ctx.data, &data, sizeof(data));
+	hgc->ctx.datasize = sizeof(data);
+	writeblockrequest(hgc, "setumask2");
 }
 
 /*!
@@ -508,7 +509,7 @@  hgclient_t *hgc_open(const char *socknam
 		attachio(hgc);
 	if (hgc->capflags & CAP_CHDIR)
 		chdirtocwd(hgc);
-	if (hgc->capflags & CAP_SETUMASK)
+	if (hgc->capflags & CAP_SETUMASK2)
 		forwardumask(hgc);
 
 	return hgc;