summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmael Luceno2011-06-01 00:11:50 -0300
committerIsmael Luceno2011-06-01 00:11:50 -0300
commit46bbcbf55036ddddabeb7bc0cf7e2114dbd0eb66 (patch)
tree4cadaf38886f2967ab44b0b23c56d3adaf20fe48
parent0f8003cceee353ec821fb0b6366dca6d29728d8a (diff)
hg_download.function: hg download handler
Mostly copied from pymsnt.
-rw-r--r--ChangeLog1
-rwxr-xr-xFUNCTIONS1
-rwxr-xr-xhg_download.function44
3 files changed, 46 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 606935a57f..32ff7f593b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2011-05-31 Ismael Luceno <ismael@sourcemage.org>
* python-pypi/w3lib: new spell, Library of web-relatedfunctions
* python-pypi/scrapy: new spell, A high-level Python Screen Scraping framework
+ * hg_download.function: hg download handler (mostly copied from pymsnt)
2011-05-31 Treeve Jelbert <treeve@sourcemage.org>
* python-pypi/geraldo: new spell, python reporting engine
diff --git a/FUNCTIONS b/FUNCTIONS
index 6e26adc618..00cab135ff 100755
--- a/FUNCTIONS
+++ b/FUNCTIONS
@@ -720,3 +720,4 @@ fi
. $GRIMOIRE/glselect.function
. $GRIMOIRE/bzr_download.function
+. $GRIMOIRE/hg_download.function
diff --git a/hg_download.function b/hg_download.function
new file mode 100755
index 0000000000..7732c94f1f
--- /dev/null
+++ b/hg_download.function
@@ -0,0 +1,44 @@
+#---------------------------------------------------------------------
+## Handler for downloading from mercurial URLs
+#---------------------------------------------------------------------
+function hg_checkout() {
+ unset URL HG_ROOT HG_MODULE HG_TAG
+ url_hg_crack $1
+ message "${MESSAGE_COLOR}Starting Mercurial checkout of" \
+ "${FILE_COLOR}$2${MESSAGE_COLOR}...${DEFAULT_COLOR}" &&
+ if [[ -f $SOURCE_CACHE/$2 ]]
+ then
+ message "${MESSAGE_COLOR}Previous source found unpacking...${DEFAULT_COLOR}" &&
+ tar -jxf $SOURCE_CACHE/$2 &&
+ cd ${HG_MODULE} &&
+ message "${MESSAGE_COLOR}Running Mercurial update...${DEFAULT_COLOR}" &&
+ hg pull -u -r ${HG_TAG}
+ cd ..
+ message "${MESSAGE_COLOR}Done...${DEFAULT_COLOR}"
+ else
+ message "${MESSAGE_COLOR}Running initial Mercurial clone...${DEFAULT_COLOR}" &&
+ hg clone -r${HG_TAG} "http://${HG_ROOT}" ${HG_MODULE}
+ message "${MESSAGE_COLOR}Done...${DEFAULT_COLOR}"
+ fi &&
+ message "${MESSAGE_COLOR}Generating tarball...${DEFAULT_COLOR}" &&
+ tar -jcf $2 ${HG_MODULE} &&
+ mv $2 ${SOURCE_CACHE}/$2 &&
+ message "${MESSAGE_COLOR}Mercurial checkout complete...${DEFAULT_COLOR}"
+}
+
+function hg_download() {
+ hg_checkout "${SOURCE_URL}" "${SOURCE}"
+ if [ -n "${SOURCE2_URL}" ]
+ then
+ hg_checkout "${SOURCE2_URL}" "${SOURCE2}"
+ fi
+}
+
+function url_hg_crack() {
+ URL=$(url_strip_prefix "$1" hg_http)
+ HG_ROOT=$(echo $URL | sed "s#\(^[^/]*[^:]*\):.*#\1#")
+ local HG_MODULE_TAG=$(echo $URL | sed "s#^[^/]*[^:]*\(.*\)#\1#")
+ HG_MODULE=$(echo $HG_MODULE_TAG | cut -d : -f2)
+ local HG_TAGNAME=$(echo $HG_MODULE_TAG | cut -d : -f3)
+ HG_TAG=${HG_TAGNAME:-tip}
+}