[paludis-commits] paludis.git (master) -- 5df950c by David Leverton

git at git.pioto.org git at git.pioto.org
Fri Aug 1 17:55:38 EDT 2008


Module:    paludis.git
Branch:    master
Commit:    5df950c88f03804d3939f2a5beb2bd31967f24af
URL:       http://git.pioto.org/?p=paludis.git;a=commit;h=5df950c88f03804d3939f2a5beb2bd31967f24af

Author:    David Leverton <levertond at googlemail.com>
Committer: David Leverton <levertond at googlemail.com>
Date:      Fri Aug  1 22:49:39 2008 +0100

----

Add Mercurial syncer.

----

 .gitignore                  |    5 ++
 NEWS                        |    2 +
 paludis/syncers/Makefile.am |   11 ++++-
 paludis/syncers/dohg.in     |  113 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+), 2 deletions(-)


diff --git a/.gitignore b/.gitignore
index 65a5533..f431cdf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -301,6 +301,11 @@ man-*
 /paludis/syncers/dogit+https
 /paludis/syncers/dogit+rsync
 /paludis/syncers/dogit+ssh
+/paludis/syncers/dohg+file
+/paludis/syncers/dohg+http
+/paludis/syncers/dohg+https
+/paludis/syncers/dohg+ssh
+/paludis/syncers/dohg+static-http
 /paludis/syncers/dorsync
 /paludis/syncers/dorsync+ssh
 /paludis/syncers/dosvn
diff --git a/NEWS b/NEWS
index 7d9e804..02b51ae 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ master:
       that the GNU versions are used.  (This is not necessary on typical Linux
       systems; check <command> --version if in doubt.)
 
+    * Paludis now supports syncing from Mercurial repositories.
+
 0.28.0:
     * Compilers without tr1 memory, type traits and functional support are no
       longer supported. This means you, gcc-3.
diff --git a/paludis/syncers/Makefile.am b/paludis/syncers/Makefile.am
index 4c23122..8a81a06 100644
--- a/paludis/syncers/Makefile.am
+++ b/paludis/syncers/Makefile.am
@@ -1,5 +1,5 @@
 MAINTAINERCLEANFILES = Makefile.in
-CLEANFILES = *~ .keep dobzr dobzr+aftp dobzr+file dobzr+ftp dobzr+http dobzr+https dobzr+sftp dobzr+ssh docvs+ext docvs+pserver docvs+ssh dodarcs+file dodarcs+http dodarcs+https dodarcs+ssh dofile dogit dogit+file dogit+http dogit+https dogit+rsync dogit+ssh dorsync dorsync+ssh dosvn dosvn+file dosvn+http dosvn+https dosvn+ssh dotar+file dotar+ftp dotar+http dotar+https
+CLEANFILES = *~ .keep dobzr dobzr+aftp dobzr+file dobzr+ftp dobzr+http dobzr+https dobzr+sftp dobzr+ssh docvs+ext docvs+pserver docvs+ssh dodarcs+file dodarcs+http dodarcs+https dodarcs+ssh dofile dogit dogit+file dogit+http dogit+https dogit+rsync dogit+ssh dohg+file dohg+http dohg+https dohg+ssh dohg+static-http dorsync dorsync+ssh dosvn dosvn+file dosvn+http dosvn+https dosvn+ssh dotar+file dotar+ftp dotar+http dotar+https
 SUBDIRS = .
 
 .keep :
@@ -30,6 +30,11 @@ libexecprog_SCRIPTS = \
 	dogit+https \
 	dogit+rsync \
 	dogit+ssh \
+	dohg+file \
+	dohg+http \
+	dohg+https \
+	dohg+ssh \
+	dohg+static-http \
 	dorsync \
 	dorsync+ssh \
 	dosvn \
@@ -53,7 +58,7 @@ installusersyncersdir = $(datadir)/paludis/syncers
 installusersyncers_DATA = .keep
 
 TESTS =
-EXTRA_DIST = $(libexecprog_SCRIPTS) dobzr.in docvs.in dodarcs.in dogit.in dorsync.in dosvn.in dotar.in
+EXTRA_DIST = $(libexecprog_SCRIPTS) dobzr.in docvs.in dodarcs.in dogit.in dohg.in dorsync.in dosvn.in dotar.in
 
 check_SCRIPTS =
 check_PROGRAMS = $(TESTS)
@@ -68,6 +73,8 @@ dodarcs+file dodarcs+http dodarcs+https dodarcs+ssh : dodarcs.in
 	cat $? > $@
 dogit dogit+file dogit+http dogit+https dogit+rsync dogit+ssh : dogit.in
 	cat $? > $@
+dohg+file dohg+http dohg+https dohg+ssh dohg+static-http : dohg.in
+	cat $? > $@
 dofile dorsync dorsync+ssh : dorsync.in
 	cat $? > $@
 dosvn dosvn+file dosvn+http dosvn+https dosvn+ssh : dosvn.in
diff --git a/paludis/syncers/dohg.in b/paludis/syncers/dohg.in
new file mode 100644
index 0000000..aad948c
--- /dev/null
+++ b/paludis/syncers/dohg.in
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+
+source "${PALUDIS_EBUILD_DIR}/echo_functions.bash"
+
+old_set=$-
+set -a
+for f in ${PALUDIS_BASHRC_FILES}; do
+    [[ -f "${f}" ]] && source "${f}"
+done
+[[ "${old_set}" == *a* ]] || set +a
+
+LOCAL=
+REMOTE=
+
+HG_OPTIONS=( )
+HG_CLONE_OPTIONS=( )
+HG_PULL_OPTIONS=( )
+HG_UPDATE_OPTIONS=( )
+
+while [[ $# -gt 0 ]]; do
+    case "${1}" in
+
+        --hg-option=*)
+            HG_OPTIONS[${#HG_OPTIONS[@]}]="${1#*=}"
+            ;;
+
+        --hg-clone-option=*)
+            HG_CLONE_OPTIONS[${#HG_CLONE_OPTIONS[@]}]="${1#*=}"
+            ;;
+
+        --hg-pull-option=*)
+            HG_PULL_OPTIONS[${#HG_PULL_OPTIONS[@]}]="${1#*=}"
+            ;;
+
+        --hg-update-option=*)
+            HG_UPDATE_OPTIONS[${#HG_UPDATE_OPTIONS[@]}]="${1#*=}"
+            ;;
+
+        --help)
+            PROTO="${0##*/do}"
+            if [[ "${PROTO}" == hg+file ]]; then
+                echo "    URL syntax: hg+file:///PATH[#BRANCH]"
+            elif [[ "${PROTO}" == hg+http || "${PROTO}" == hg+https ]]; then
+                echo "    URL syntax: ${PROTO}://[USERNAME@]SERVER/PATH[#BRANCH]"
+            elif [[ "${PROTO}" == hg+ssh ]]; then
+                echo "    URL syntax: hg+ssh://[USERNAME@]SERVER[:PORT]/PATH[#BRANCH]"
+            elif [[ "${PROTO}" == hg+static-http ]]; then
+                echo "    URL syntax: hg+static-http://SERVER[:PORT]/PATH[#BRANCH]"
+            else
+                ewarn "URL syntax for ${PROTO} is unknown.  This script will likely not work with the ${PROTO} protocol"
+            fi
+
+            echo "    Options:"
+            echo "        --hg-option=OPTION              Pass OPTION to hg as a global option"
+            echo "        --hg-clone-option=OPTION        Pass OPTION to hg clone"
+            echo "        --hg-pull-option=OPTION         Pass OPTION to hg pull"
+            echo "        --hg-update-option=OPTION       Pass OPTION to hg update"
+            exit 0
+            ;;
+
+        --*)
+            ewarn "${0}: unknown option '${1%%=*}'"
+            ;;
+
+        *)
+            if [[ -z "${LOCAL}" ]]; then
+                LOCAL="${1}"
+            elif [[ -z "${REMOTE}" ]]; then
+                REMOTE="${1}"
+            else
+                eerror "${0}: extra argument '${1}'"
+                exit 1
+            fi
+            ;;
+
+    esac
+    shift
+done
+
+if [[ -z "${LOCAL}" ]]; then
+    eerror "${0}: unspecified local repository directory"
+    exit 1
+elif [[ -z "${REMOTE}" ]]; then
+    eerror "${0}: unspecified remote repository URL"
+    exit 1
+fi
+
+REMOTE="${REMOTE#hg+}"
+
+if [[ -d "${LOCAL}" && ! -d "${LOCAL}/.hg" ]]; then
+    eerror "'${LOCAL}' exists but it is not a Mercurial repository"
+    exit 1
+fi
+
+if [[ -d "${LOCAL}" ]]; then
+    cd "${LOCAL}"
+    OLD_REMOTE="$(${HG_WRAPPER} hg "${HG_OPTIONS[@]}" paths default)"
+    if [[ "${OLD_REMOTE}" != "${REMOTE}" ]]; then
+        if ! sed -i -e '/^\[paths\]$/,/^\[/s,^default = .*,default = '"${REMOTE//,/\\,}," .hg/hgrc; then
+            eerror "${0}: could not switch from '${OLD_REMOTE}' to '${REMOTE}'"
+            exit 1
+        fi
+    fi
+    cd - >/dev/null
+fi
+
+if [[ -d "${LOCAL}/.hg" ]]; then
+    cd "${LOCAL}" && ${HG_WRAPPER} hg "${HG_OPTIONS[@]}" pull "${HG_PULL_OPTIONS[@]}" && \
+        ${HG_WRAPPER} hg "${HG_OPTIONS[@]}" update "${HG_UPDATE_OPTIONS[@]}"
+else
+    ${HG_WRAPPER} hg "${HG_OPTIONS[@]}" clone "${HG_CLONE_OPTIONS[@]}" "${REMOTE}" "${LOCAL}"
+fi
+
---


More information about the paludis-commits mailing list