Patchwork [6,of,6,RFC,hglib] parse_changeset: it's more like pointing to the correct position

login
register
mail settings
Submitter Iulian Stana
Date Sept. 5, 2013, 2:13 p.m.
Message ID <971a1958260d28af4ba8.1378390406@doppler>
Download mbox | patch
Permalink /patch/2338/
State Deferred, archived
Headers show

Comments

Iulian Stana - Sept. 5, 2013, 2:13 p.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1378389525 -10800
#      Thu Sep 05 16:58:45 2013 +0300
# Node ID 971a1958260d28af4ba8dc5a5fed740baa79ae68
# Parent  45ab6314f20f386125e15e369cd1b719e3e7ebf2
parse_changeset: it's more like pointing to the correct position

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -106,6 +106,53 @@ 
 	return exitcode;
 }
 
+/**
+ * \brief 'Parse a changeset'. It's more like pointing to the correct position.
+ *
+ * The changeset could be found on buff pointer. To not duplicate the data I 
+ * choose to point every hg_cset_entry field to the right position.
+ * \param cset The pointer where changeset could be found.
+ * \param ce   The hg_cset_entry structure where the changeset will be parse.
+ * \retval 0 if successful.
+ * */
+int parse_changeset(char *cset, hg_cset_entry *ce)
+{
+	char *position = cset;
+	/* set pointer for revision position */
+	ce->rev = cset;
+	position = strstr(position, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for node position */
+	ce->node = position + 1;
+	position = strstr(position + 1, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for tag position */
+	ce->tags = position + 1;
+	position = strstr(position + 1, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for branch position */
+	ce->branch = position + 1;
+	position = strstr(position + 1, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for author position */
+	ce->author = position + 1;
+	position = strstr(position + 1, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for data position */
+	ce->date = position + 1;
+	position = strstr(position + 1, "\n");
+	cset[position - cset] = '\0';
+
+	/* set pointer for description position */
+	ce->desc = position + 1;
+	/* */
+	return 0;
+}
 
 /* The cbuf next step. Getting the next changeset. */
 int hg_fetch_cset_entry(hg_csetstream_buffer *cbuf, hg_cset_entry *centry)