Patchwork [c-hglib] hg_exitcode: the exitcode for the current command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 18, 2013, 11:25 p.m.
Message ID <416d889424e9d5653260.1379546727@doppler>
Download mbox | patch
Permalink /patch/2533/
State Accepted
Headers show

Comments

Iulian Stana - Sept. 18, 2013, 11:25 p.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1379454205 -10800
#      Wed Sep 18 00:43:25 2013 +0300
# Node ID 416d889424e9d56532608a3ab803bdd2e5a633b4
# Parent  8bdb422f21775a3826a59eeefd17e3f6da6a0308
hg_exitcode: the exitcode for the current command

The server tell use that he finished his action when the 'r' channel is send.
This function will get the exitcode from the server.
Matt Mackall - Sept. 18, 2013, 11:30 p.m.
On Thu, 2013-09-19 at 02:25 +0300, Iulian Stana wrote:
> # HG changeset patch
> # User Iulian Stana <julian.stana@gmail.com>
> # Date 1379454205 -10800
> #      Wed Sep 18 00:43:25 2013 +0300
> # Node ID 416d889424e9d56532608a3ab803bdd2e5a633b4
> # Parent  8bdb422f21775a3826a59eeefd17e3f6da6a0308
> hg_exitcode: the exitcode for the current command

Queued, thanks.

Patch

diff --git a/hglib/client.c b/hglib/client.c
--- a/hglib/client.c
+++ b/hglib/client.c
@@ -295,3 +295,23 @@ 
 	return length;
 }
 
+/*
+ * The exitcode for the current command.
+ * */
+int hg_exitcode(hg_handle *handle)
+{
+	int exitcode;
+
+	if (handle == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (read(handle->p_read, &exitcode, sizeof(int)) < 0) {
+		return -1;
+	}
+	handle->protect = 0;
+	return swap_uint32(exitcode);
+}
+
+