changeset 30691:7adb60660496

chg: decouple hgclient from setuppager procutil should not depend on hgclient. This patch makes the pager handling part independent from hgclient.
author Jun Wu <quark@fb.com>
date Mon, 02 Jan 2017 14:10:32 +0000
parents e9ec42634ec8
children 23ddd43ba866
files contrib/chg/chg.c contrib/chg/procutil.c
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Mon Jan 02 14:04:35 2017 +0000
+++ b/contrib/chg/chg.c	Mon Jan 02 14:10:32 2017 +0000
@@ -430,7 +430,10 @@
 	}
 
 	setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
-	pagerpid = setuppager(hgc, argv + 1, argc - 1);
+	const char *pagercmd = hgc_getpager(hgc, argv + 1, argc - 1);
+	pagerpid = setuppager(pagercmd);
+	if (pagerpid)
+		hgc_attachio(hgc);  /* reattach to pager */
 	int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);
 	restoresignalhandler();
 	hgc_close(hgc);
--- a/contrib/chg/procutil.c	Mon Jan 02 14:04:35 2017 +0000
+++ b/contrib/chg/procutil.c	Mon Jan 02 14:10:32 2017 +0000
@@ -157,10 +157,8 @@
 
 /* This implementation is based on hgext/pager.py (post 369741ef7253)
  * Return 0 if pager is not started, or pid of the pager */
-static pid_t setuppager(hgclient_t *hgc, const char *const args[],
-		       size_t argsize)
+static pid_t setuppager(const char *pagercmd)
 {
-	const char *pagercmd = hgc_getpager(hgc, args, argsize);
 	if (!pagercmd)
 		return 0;
 
@@ -179,7 +177,6 @@
 				goto error;
 		}
 		close(pipefds[1]);
-		hgc_attachio(hgc);  /* reattach to pager */
 		return pid;
 	} else {
 		dup2(pipefds[0], fileno(stdin));