From 76c56cbd8a9a50bca495494fc2c5766478d01010 Mon Sep 17 00:00:00 2001 From: belliash Date: Mon, 16 Jan 2012 19:18:46 +0100 Subject: [PATCH] add missing mercurial support --- config/ezsync.conf | 4 ++-- libraries/repositories | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/config/ezsync.conf b/config/ezsync.conf index 61b01d0..9ef587a 100644 --- a/config/ezsync.conf +++ b/config/ezsync.conf @@ -16,7 +16,7 @@ MODULES_POSTCOMMIT="" # These options specify the build Portage tree, which all the changes are made to, as well # as a mainline Portage tree, which the major updates come from. Ordered parameters are: # portage name = name of Portage tree (eg. gentoo-portage) -# sync protocol = protocol being used by repository (git, rsync, svn) +# sync protocol = protocol being used by repository (git, hg, rsync, svn) # remote address = the remote repository address to clone from and send commits to # optional branch = in a non-bare repository, this is the branch that will be fetched # NOTE: Not every protocol can be used for building Portage tree! @@ -26,7 +26,7 @@ PORTAGE_MAINLINE=( "mainline-portage" "rsync" "rsync://rsync.mydomain.org/mainli # These defines the overlays that might be used later in a synchronization process. # Ordered parameters are: # overlay name = the overlay name (eg. regen2-overlay) -# protocol used = protocol being used by repository (git, rsync, svn) +# protocol used = protocol being used by repository (git, hg, rsync, svn) # remote address = the remote repository address to clone from and send commits to # optional branch = in a non-bare repository, this is the branch that will be fetched # files to copy = comma separated list of packages to merge, or ALL to merge every diff --git a/libraries/repositories b/libraries/repositories index 14d979b..8db7f14 100644 --- a/libraries/repositories +++ b/libraries/repositories @@ -39,6 +39,30 @@ function pullGit() { return 0 } +#------------------------------------------------------------------------------- +# Downloads or updates specified HG repository +# Parameters: %dest_directory% %address% [%branch%] +#------------------------------------------------------------------------------- +function pullMercurial() { + local DIRECTORY="${1}" + local ADDRESS="${2}" + local BRANCH="${3:-default}" + if [ -d ${DIRECTORY} ]; then + cd ${DIRECTORY} + run "hg recover" + run "hg revert -aC" || return 1 + run "hg purge" || return 1 + run "hg pull" || return 1 + else + run "hg clone ${ADDRESS} ${DIRECTORY}" || return 1 + if [ ${BRANCH} != "default" ]; then + run "hg branch ${BRANCH}" || return 1 + fi + echo -e "\n[extensions]\nhgext.purge=" >> ${DIRECTORY}/.hg/hgrc + fi + return 0 +} + #------------------------------------------------------------------------------- # Synchronizes specified repository regardless its protocol # Parameters: %dest_directory% %protocol% %address% [%branch%] @@ -49,6 +73,9 @@ function pullRepository() { [Gg][Ii][Tt]) pullGit "${1}" "${3}" "${4}" && return 0 ;; + [Hh][Gg]) + pullMercurial "${1}" "${3}" "${4}" && return 0 + ;; [Rr][Ss][Yy][Nn][Cc]) pullRsync "${1}" "${3}" && return 0 ;;