[PATCH 10 of 55 RFC c-hglib:level1] hg_archive: creating a high level function for mercurial archive command

Iulian Stana julian.stana at gmail.com
Fri Sep 13 19:35:22 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379110688 -10800
#      Sat Sep 14 01:18:08 2013 +0300
# Node ID a74f54214315594dc69836005089d45e211e1fc5
# Parent  f21b87f4e6a36ca368f469e5e5c6673aafa98f66
hg_archive: creating a high level function for mercurial archive command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -496,6 +496,23 @@
 	return lbuf;
 }
 
+/* The high level archive command for hglib API. */
+int hg_archive(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("archive", argument, NULL);
+
+	if(hg_rawcommand(handle, command) < 0){
+		return -1;
+	}
+	free(command);
+
+	exitcode = hg_runcommand(handle, callback, NULL);
+
+	return exitcode;
+}
+
 /* 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)
diff --git a/client.h b/client.h
--- a/client.h
+++ b/client.h
@@ -474,6 +474,50 @@
 			(const char *msg, size_t len), char *argument[]);
 
 /**
+ * \brief hg_archive command for hglib API.
+ * 
+ * Create an unversioned archive of a repository revision.
+ *
+ * The exact name of the destination archive or directory is given using a
+ * format string; see export for details.
+ *
+ * Each member added to an archive file has a directory prefix prepended. Use
+ * prefix to specify a format string for the prefix. The default is the
+ * basename of the archive, with suffixes removed.
+ *
+ * Valid types are:
+ *
+ *	files:	a directory full of files (default)
+ *	tar:	tar archive, uncompressed
+ *	tbz2:	tar archive, compressed using bzip2
+ *	tgz:	tar archive, compressed using gzip
+ *	uzip:	zip archive, uncompressed
+ *	zip:	zip archive, compressed using deflate
+ *
+ * Options/Argument list option:
+ *
+ *	--no-decode	do not pass files through decoders
+ *	-p, --prefix	directory prefix for files in archive
+ *	-r, --rev		revision to distribute
+ *	-t, --type		type of distribution to create
+ *	-S, --subrepos	recurse into subrepositories
+ *	-I, --include	include names matching the given patterns
+ *	-X, --exclude	exclude names matching the given patterns
+ *
+ *
+ * \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 exitcode  To indicate the end of archive_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_archive(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()


More information about the Mercurial-devel mailing list