mercurial (hg) support
This commit is contained in:
parent
3dd1343ec8
commit
fc387c377b
118
forgebuild.sh
118
forgebuild.sh
|
@ -73,12 +73,18 @@ clone () {
|
||||||
dvcs="$1"
|
dvcs="$1"
|
||||||
src="$2"
|
src="$2"
|
||||||
dest="$3"
|
dest="$3"
|
||||||
if [[ "$dvcs" = "git" ]]; then
|
case "$dvcs" in
|
||||||
git clone --recursive "$2" "$3"
|
"git")
|
||||||
else
|
git clone --recursive "$2" "$3"
|
||||||
echo "UNIMPLEMENTED"
|
;;
|
||||||
exit 1
|
"mercurial"|"hg")
|
||||||
fi
|
hg clone "$2" "$3"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "UNIMPLEMENTED"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks for updates, if any download them
|
# Checks for updates, if any download them
|
||||||
|
@ -88,8 +94,6 @@ clone () {
|
||||||
# - anything else when there was an error
|
# - anything else when there was an error
|
||||||
updates() {
|
updates() {
|
||||||
dvcs="$1"
|
dvcs="$1"
|
||||||
# TODO: non-master primary branch
|
|
||||||
[ -z "$2" ] && p_branch="master" || p_branch="$2"
|
|
||||||
case "$dvcs" in
|
case "$dvcs" in
|
||||||
"git")
|
"git")
|
||||||
# Refresh remote before comparing with local
|
# Refresh remote before comparing with local
|
||||||
|
@ -97,12 +101,11 @@ updates() {
|
||||||
error pull_failed
|
error pull_failed
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
p_branch="$(branch git)"
|
||||||
git diff --quiet remotes/origin/$p_branch
|
git diff --quiet remotes/origin/$p_branch
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
info pull
|
info pull
|
||||||
# Do not invoke an editor when merging submodule updates (--no-edit)
|
if ! git pull origin $p_branch --quiet; then
|
||||||
#if ! git pull --quiet; then
|
|
||||||
if ! git pull origin $p_branch; then
|
|
||||||
error pull_failed
|
error pull_failed
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
|
@ -110,6 +113,18 @@ updates() {
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
"mercurial"|"hg")
|
||||||
|
if hg incoming; then
|
||||||
|
info pull
|
||||||
|
if ! hg pull; then
|
||||||
|
error pull_failed
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "UNIMPLEMENTED"
|
echo "UNIMPLEMENTED"
|
||||||
return 4
|
return 4
|
||||||
|
@ -117,6 +132,26 @@ updates() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Checkout a specific branch/commit
|
||||||
|
# returns 0 on success, 1 if the checkout failed
|
||||||
|
# 2 if the backend is unknown
|
||||||
|
checkout () {
|
||||||
|
dvcs="$1"
|
||||||
|
target="$2"
|
||||||
|
case "$dvcs" in
|
||||||
|
"git")
|
||||||
|
git checkout $target
|
||||||
|
;;
|
||||||
|
"mercurial"|"hg")
|
||||||
|
hg update $target
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "UNIMPLEMENTED"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Checks for submodule updates
|
# Checks for submodule updates
|
||||||
# Returns 0 for no updates, 1 for updates performed
|
# Returns 0 for no updates, 1 for updates performed
|
||||||
# and anything else when there was an error
|
# and anything else when there was an error
|
||||||
|
@ -129,7 +164,6 @@ subupdates() {
|
||||||
DIR="$(pwd)"
|
DIR="$(pwd)"
|
||||||
for submodule in $(git config --file .gitmodules --get-regexp path | awk '{ print $2 }'); do
|
for submodule in $(git config --file .gitmodules --get-regexp path | awk '{ print $2 }'); do
|
||||||
cd $submodule
|
cd $submodule
|
||||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
||||||
updates git
|
updates git
|
||||||
res=$?
|
res=$?
|
||||||
cd $DIR
|
cd $DIR
|
||||||
|
@ -147,6 +181,24 @@ subupdates() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print the current branch for specified DVCS
|
||||||
|
# Return 0 when ok, 1 on error, 2 on unknown DVCS
|
||||||
|
branch () {
|
||||||
|
dvcs="$1"
|
||||||
|
case "$dvcs" in
|
||||||
|
"git")
|
||||||
|
git rev-parse --abbrev-ref HEAD || exit 1
|
||||||
|
;;
|
||||||
|
"mercurial"|"hg")
|
||||||
|
hg identify -b || exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "UNIMPLEMENTED"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Logging is done with the LOG="debug|info|error" environment variable
|
# Logging is done with the LOG="debug|info|error" environment variable
|
||||||
if [ ! -z $LOG ] && [ "$LOG" != "" ]; then
|
if [ ! -z $LOG ] && [ "$LOG" != "" ]; then
|
||||||
case $LOG in
|
case $LOG in
|
||||||
|
@ -274,35 +326,36 @@ for p_name in ${PROJECTS[*]}; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# checkout a specific branch/commit
|
# So we have a source, check the associated DVCS
|
||||||
if [ -f $BASEDIR/$p_name.checkout ]; then
|
[ -f $BASEDIR/$p_name.dvcs ] && dvcs="$(cat $BASEDIR/$p_name.dvcs)" || dvcs="git"
|
||||||
p_branch="$(cat $BASEDIR/$p_name.checkout)"
|
|
||||||
export i18n_branch="$p_branch"
|
|
||||||
info to_branch
|
|
||||||
else
|
|
||||||
# TODO: support non-master primary branch
|
|
||||||
p_branch="master"
|
|
||||||
export i18n_branch="$p_branch"
|
|
||||||
debug default_branch
|
|
||||||
fi
|
|
||||||
p_dir="$BASEDIR/.$p_name"
|
p_dir="$BASEDIR/.$p_name"
|
||||||
if [ ! -d $p_dir ]; then
|
if [ ! -d $p_dir ]; then
|
||||||
source="$(cat $BASEDIR/$p_name.source)"
|
source="$(cat $BASEDIR/$p_name.source)"
|
||||||
export i18n_source="$source"
|
export i18n_source="$source"
|
||||||
info clone
|
info clone
|
||||||
# Don't forget the git submodules!
|
if ! clone "$dvcs" "$source" "$p_dir"; then
|
||||||
if ! git clone --recursive "$source" "$p_dir"; then
|
|
||||||
error clone_failed
|
error clone_failed
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd $p_dir
|
cd $p_dir
|
||||||
if [[ "$p_branch" != "master" ]]; then
|
|
||||||
debug checkout
|
# checkout a specific branch/commit
|
||||||
if ! git checkout "$p_branch"; then
|
if [ -f $BASEDIR/$p_name.checkout ]; then
|
||||||
|
p_branch="$(cat $BASEDIR/$p_name.checkout)"
|
||||||
|
export i18n_branch="$p_branch"
|
||||||
|
info to_branch
|
||||||
|
debug checkout
|
||||||
|
if ! checkout $dvcs "$p_branch"; then
|
||||||
error checkout_failed
|
error checkout_failed
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
else
|
||||||
|
p_branch="$(branch $dvcs)"
|
||||||
|
export i18n_branch="$p_branch"
|
||||||
|
debug default_branch
|
||||||
|
fi
|
||||||
|
|
||||||
run $p_name
|
run $p_name
|
||||||
# Skip to the next task!
|
# Skip to the next task!
|
||||||
continue
|
continue
|
||||||
|
@ -310,7 +363,8 @@ for p_name in ${PROJECTS[*]}; do
|
||||||
debug already_cloned
|
debug already_cloned
|
||||||
cd "$p_dir"
|
cd "$p_dir"
|
||||||
|
|
||||||
updates git "$p_branch"
|
# Omit "" on p_branch so if it's empty it's not registered as argument (and the default is used)
|
||||||
|
updates $dvcs $p_branch
|
||||||
res="$?"
|
res="$?"
|
||||||
case "$res" in
|
case "$res" in
|
||||||
"0")
|
"0")
|
||||||
|
@ -323,10 +377,10 @@ for p_name in ${PROJECTS[*]}; do
|
||||||
debug no_update
|
debug no_update
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
subupdates git > /dev/stderr
|
subupdates $dvcs
|
||||||
subres=$?
|
subres=$?
|
||||||
[ $subres -eq 0 ] && debug no_update && continue
|
[ $subres -eq 0 ] && debug no_update && continue
|
||||||
[ ! $subres -eq 1 ] && echo "$subres" && continue # subupdates errored
|
[ ! $subres -eq 1 ] && continue # subupdates errored
|
||||||
run $p_name
|
run $p_name
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue