# HG changeset patch # User Jun Wu # Date 1484002743 -28800 # Node ID a45c0f42271f2984b2e132e3e7e6d855c33ff94a # Parent 2957409449ac4e4c4c0fb51d4272aa83ff42a8ed chg: handle pager request client-side This patch implements the simple S-channel pager handling at chg client-side. Note: It does not deal with environ and cwd currently for simplicity, which will be fixed later. diff -r 2957409449ac -r a45c0f42271f contrib/chg/Makefile --- a/contrib/chg/Makefile Tue Jan 10 06:58:51 2017 +0800 +++ b/contrib/chg/Makefile Tue Jan 10 06:59:03 2017 +0800 @@ -25,7 +25,7 @@ $(CC) $(LDFLAGS) -o $@ $(OBJS) chg.o: hgclient.h procutil.h util.h -hgclient.o: hgclient.h util.h +hgclient.o: hgclient.h procutil.h util.h procutil.o: procutil.h util.h util.o: util.h diff -r 2957409449ac -r a45c0f42271f contrib/chg/hgclient.c --- a/contrib/chg/hgclient.c Tue Jan 10 06:58:51 2017 +0800 +++ b/contrib/chg/hgclient.c Tue Jan 10 06:59:03 2017 +0800 @@ -23,6 +23,7 @@ #include #include "hgclient.h" +#include "procutil.h" #include "util.h" enum { @@ -71,6 +72,8 @@ static const size_t defaultdatasize = 4096; +static void attachio(hgclient_t *hgc); + static void initcontext(context_t *ctx) { ctx->ch = '\0'; @@ -248,6 +251,13 @@ memcpy(ctx->data, &r_n, sizeof(r_n)); ctx->datasize = sizeof(r_n); writeblock(hgc); + } else if (strcmp(args[0], "pager") == 0) { + setuppager(args[1]); + if (hgc->capflags & CAP_ATTACHIO) + attachio(hgc); + /* unblock the server */ + static const char emptycmd[] = "\n"; + sendall(hgc->sockfd, emptycmd, sizeof(emptycmd) - 1); } else { abortmsg("unknown type in system request: %s", args[0]); }