@@ -1272,6 +1272,26 @@
return lbuf;
}
+/* The high level status command for hglib API. */
+hg_linestream_buffer *hg_status(hg_handle *handle, int (*callback)
+ (const char *msg, size_t len), char *argument[])
+{
+ hg_linestream_buffer *sbuf = malloc(sizeof(hg_csetstream_buffer));
+ sbuf->handle = handle;
+
+ sbuf->command = cmdbuilder("status", argument, NULL);
+
+ if(hg_rawcommand(handle, sbuf->command) < 0){
+ return NULL;
+ }
+
+ sbuf->callback = callback;
+ sbuf->buffer = NULL;
+ sbuf->buf_size = 0;
+
+ return sbuf;
+}
+
/* 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)
@@ -1487,3 +1507,18 @@
return return_value;
}
+/* The lbuf next step. */
+int hg_fetch_status_entry(hg_linestream_buffer *lbuf, hg_st_entry *sentry)
+{
+ char *buff = NULL;
+ int return_value = hg_fetch_line_entry(lbuf, &buff);
+
+ if(return_value <= 0)
+ return return_value;
+
+ sentry->code = buff[0];
+ sentry->file = buff + 2;
+
+ return return_value;
+}
+
@@ -296,6 +296,40 @@
}hg_rev_entry;
/**
+ * \struct hg_st_entry
+ * \brief This structure will contain status information about a file.
+ *
+ * \var hg_st_entry::code
+ * The code field will stock the code for curent file.
+ *
+ * The codes used to show the status of files are:
+ *
+ * M = modified
+ * A = added
+ * R = removed
+ * C = clean
+ * ! = missing (deleted by non-hg command, but still tracked)
+ * ? = not tracked
+ * I = ignored
+ * = origin of the previous file listed as A (added)
+ *
+ * \var hg_st_entry::file
+ * The file field will stock the curent file.
+ *
+ * \typedef hg_st_entry
+ * \brief This structure will contain status information about a file.
+ *
+ * \param code
+ * The code field will stock the code for curent file.
+ * \param file
+ * The file field will stock the curent file.
+ * */
+typedef struct hg_st_entry{
+ char code;
+ char *file;
+}hg_st_entry;
+
+/**
* \brief Reading the header from cmdsrv.
*
* The function will read the header from the command server and will save it to
@@ -1942,6 +1976,70 @@
(const char *msg, size_t len), char *argument[]);
/**
+ * \brief hg_status command for hglib API.
+ *
+ * Show status of files in the repository. If names are given, only files that
+ * match are shown. Files that are clean or ignored or the source of a copy/move
+ * operation, are not listed unless -c/--clean, -i/--ignored, -C/--copies or
+ * -A/--all are given. Unless options described with "show only ..." are given,
+ * the options -mardu are used.
+ *
+ * The codes used to show the status of files are:
+ *
+ * M = modified
+ * A = added
+ * R = removed
+ * C = clean
+ * ! = missing (deleted by non-hg command, but still tracked)
+ * ? = not tracked
+ * I = ignored
+ * = origin of the previous file listed as A (added)
+ *
+ * Options/Argument list option:
+ *
+ * -A, --all show status of all files
+ * -m, --modified show only modified files
+ * -a, --added show only added files
+ * -r, --removed show only removed files
+ * -d, --deleted show only deleted (but tracked) files
+ * -c, --clean show only files without changes
+ * -u, --unknown show only unknown (not tracked) files
+ * -i, --ignored show only ignored files
+ * -n, --no-status hide status prefix
+ * -C, --copies show source of copied files
+ * -0, --print0 end filenames with NUL, for use with xargs
+ * --rev show difference from revision
+ * --change list the changed files of a revision
+ * -I, --include include names matching the given patterns
+ * -X, --exclude exclude names matching the given patterns
+ * -S, --subrepos recurse into subrepositories
+ *
+ * aliases: st
+ *
+ * To get status information use the returned hg_linestream_buffer structure
+ * with hg_fetch_line_entry() or hg_fetch_status_entry().
+ *
+ * - Using the return value in hg_fetch_line_entry() function you will get
+ * unparse data, one line at once.
+ * - Using the return value in hg_fetch_status_entry() function you will get
+ * the data parse in hg_rev_entry structure.
+ *
+ * \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_status(hg_handle *handle, int(*callback)
+ (const char *msg, size_t len), char *argument[]);
+
+/**
* \brief The yield mechanism that will get the next entry.
*
* This function is used inside of hg_fetch_cset_entry() and hg_fetch_line_entry()
@@ -2116,4 +2214,24 @@
* */
int hg_fetch_phase_entry(hg_linestream_buffer *lbuf, hg_rev_entry *pentry);
+/**
+ * \brief The iterator step. Getting the next line.
+ *
+ * Some commands could perform huge amount of data, to pass this data to users
+ * in a parse way mode I provide this function. This function will return a line
+ * in a single call.
+ *
+ * \param lbuf The buffer structure to store line data.
+ * \param sentry Address where a line will be placed in a parse way.
+ * \retval 1 Succesful operation, pass the first find line to lentry pointer.
+ * \retval 0 To indicate the end of command, everything works well.
+ * \retval -1 to indicate an error, with errno set appropriately.
+ *
+ * errno can be:
+ * - EINVAL - Invalid argument (handle it's set to a null pointer)
+ * - read(2) command errors
+ * - read_header error
+ * */
+int hg_fetch_status_entry(hg_linestream_buffer *lbuf, hg_st_entry *sentry);
+
#endif