Comments
Patch
@@ -314,12 +314,85 @@
return handle->out_data;
}
+/**
+ * \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;
+}
+
/* Will return a zero-length string. */
char *hg_abort(const char *msg, size_t size)
{
return "";
}
+int trash_data(hg_handle *handle, int(*callback)(const char *msg, size_t len))
+{
+ char buff[4096];
+ int nb;
+ int exitcode;
+ hg_header *head = hg_read_header(handle);
+ while(head->channel != r){
+ head = hg_read_header(handle);
+ /* trash output data. */
+ if(head->channel == o){
+ hg_rawread(handle, buff, 4096);
+ }
+ /* handle error data. */
+ else if(head->channel == e){
+ if(nb = hg_rawread(handle, buff, 4096), nb > 0)
+ if(callback)
+ callback(buff, strlen(buff));
+ }
+ }
+ if(head->channel == r){
+ exitcode = hg_exitcode(handle);
+ }
+ return exitcode;
+}
+
/* Read and add to some pointers the received data from cmdserver. */
int hg_runcommand(hg_handle *handle, int (*callback)(const char *msg, size_t len),
char *(*prompt)(const char *msg, size_t len))
@@ -163,6 +163,53 @@
}hg_annotate_entry;
/**
+ * \struct hg_cset_entry
+ * \brief This structure will contain informations about a changeset.
+ *
+ * \var hg_cset_entry::author
+ * The author field will stock the author of the cset.
+ * \var hg_cset_entry::branch
+ * The branch field will stock the cset branch.
+ * \var hg_cset_entry::date
+ * The date field will stock the data when cset was created.
+ * \var hg_cset_entry::desc
+ * The desc field will stock the cset message.
+ * \var hg_cset_entry::node
+ * The node field will stock the node hash.
+ * \var hg_cset_entry::rev
+ * The rev field will stock the revision number.
+ * \var hg_cset_entry::tags
+ * The tags field will stock the tag of the cset.
+ *
+ * \typedef hg_cset_entry
+ * \brief This structure will contain informations about a changeset.
+ *
+ * \param author
+ * The author field will stock the author of the cset.
+ * \param branch
+ * The branch field will stock the cset branch.
+ * \param date
+ * The date field will stock the data when cset was created.
+ * \param desc
+ * The desc field will stock the cset message.
+ * \param node
+ * The node field will stock the node hash.
+ * \param rev
+ * The rev field will stock the revision number.
+ * \param tags
+ * The tags field will stock the tag of the cset.
+ * */
+typedef struct hg_cset_entry{
+ char *author;
+ char *branch;
+ char *date;
+ char *desc;
+ char *node;
+ char *rev;
+ char *tags;
+}hg_cset_entry;
+
+/**
* \brief Reading the header from cmdsrv.
*
* The function will read the header from the command server and will save it to