From patchwork Thu Sep 5 14:13:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 6, RFC, hglib] parse_changeset: it's more like pointing to the correct position From: Iulian Stana X-Patchwork-Id: 2338 Message-Id: <971a1958260d28af4ba8.1378390406@doppler> To: mercurial-devel@selenic.com Date: Thu, 05 Sep 2013 17:13:26 +0300 # HG changeset patch # User Iulian Stana # 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 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)