Comments
Patch
@@ -650,6 +650,26 @@
return exitcode;
}
+/* The high level cat command for hglib API. */
+hg_linestream_buffer *hg_cat(hg_handle *handle, int (*callback)
+ (const char *msg, size_t len), char *argument[])
+{
+ hg_linestream_buffer *cbuf = malloc(sizeof(hg_csetstream_buffer));
+ cbuf->handle = handle;
+
+ cbuf->command = cmdbuilder("cat", argument, NULL);
+
+ if(hg_rawcommand(handle, cbuf->command) < 0){
+ return NULL;
+ }
+
+ cbuf->callback = callback;
+ cbuf->buffer = NULL;
+ cbuf->buf_size = 0;
+
+ return cbuf;
+}
+
/* The yield next step. Getting the next entry. */
int hg_fetch_entry(hg_stream_buffer *stream, int (*detect_byte)(char *buff,
int buf_size, int data_on_pipe), int func_type)
@@ -757,7 +757,48 @@
* */
int hg_bundle(hg_handle *handle, int (*callback)(const char *msg, size_t len),
char *argument[]);
-
+
+/**
+ * \brief hg_cat command for hglib API.
+ *
+ * Print the specified files as they were at the given revision. If no revision
+ * is given, the parent of the working directory is used.
+ *
+ * Output may be to a file, in which case the name of the file is given using a
+ * format string. The formatting rules are the same as for the export command,
+ * with the following additions:
+ *
+ * %s: basename of file being printed
+ * %d: dirname of file being printed, or '.' if in repository root
+ * %p: root-relative path name of file being printed
+ *
+ * Options/Argument list option:
+ *
+ * -o, --output print output to file with formatted name
+ * -r, --rev print the given revision
+ * --decode apply any matching decode filter
+ * -I, --include include names matching the given patterns
+ * -X, --exclude exclude names matching the given patterns
+ *
+ * To get cat information use the returned hg_linestream_buffer structure with
+ * hg_fetch_line_entry() function.
+ *
+ * If you use -o option, you still need to call hg_fetch_line_entry() function.
+ *
+ * \param handle The handle of the connection, wherewith I want to communicate
+ * \param callback A function that will handle error data.
+ * A NULL pointer will ignore error data.
+ * \param argument The option list. Will contain all option that you wish.
+ * \retval hg_linestream_buffer A pointer to hg_linestream_buffer structure if
+ * successful
+ * \retval NULL to indicate an error, with errno set appropriately.
+ *
+ * errno can be:
+ * - hg_rawcommand errors
+ * */
+hg_linestream_buffer *hg_cat(hg_handle *handle, int (*callback)
+ (const char *msg, size_t len), char *argument[]);
+
/**
* \brief The yield mechanism that will get the next entry.
*