From ab9468dd8f83a12d3b0a23db7486ca5822f32b99 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Wed, 31 Jul 2013 11:13:32 -0400 Subject: [PATCH] Ajout script pour afficher les subrepositories avec git-remote-hg --- scripts/Makefile.am | 2 +- scripts/vs-hgsub | 88 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100755 scripts/vs-hgsub diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 8d297bb..8ee8ea5 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -18,7 +18,7 @@ dist_bin_SCRIPTS = \ setdate \ strip-debug-symbols \ tildes-clean \ - vb vd vl vs \ + vb vd vl vs vs-hgsub \ hg-format-patch hg-update-subrepos \ git-hg-sub-import git-hg-sub-update \ flac2ogg flac2mp3 \ diff --git a/scripts/vs-hgsub b/scripts/vs-hgsub new file mode 100755 index 0000000..3182ec2 --- /dev/null +++ b/scripts/vs-hgsub @@ -0,0 +1,88 @@ +#!/bin/bash + +print_usage() +{ + echo "$(basename $0) -- gives status of version control subrepositories." + echo "Usage: $(basename $0) [OPTIONS...]" + echo "Options:" + echo " -h display this help and exit" + echo " -m display only subrepositories with local modifications" +} + +while getopts "hm" flag ;do + case ${flag} in + h) + print_usage + exit 0 + ;; + m) + DISPLAY_LOCAL_MODS_ONLY=1 + ;; + ?) + echo "${PROG_NAME}: Invalid option: ${OPTARG}." + echo "Try \`${PROG_NAME} --help' for more information." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. + +if [ ! -f .hgsub ]; then + echo "No Mercurial subrepositories found" + exit 1 +fi + +# Read lines from .hgsub +while read sub; do + # Remove CR (DOS) + sub="${sub//$'\r'/}" + + if [ "${sub}" != "" ]; then + # Get subrepository URL + src="${sub//*= /}" + + # Replace using subpaths extension content + src=${src/${sp_src}/${sp_dst}} + + # Get subrepository local alias or label + dest="${sub// =*}" + + # Get project ID (example: S0289) + id=$(echo ${sub} | sed "s/.*\(S[0-9][0-9][0-9][0-9]\).*/\1/") + + # Get revision of subrepository (remove CR from .hgsubstate) + rev=$(cat .hgsubstate | tr -d '\r' | grep "${id}" | sed "s/ .*//") + + if [ -n "${debug}" ]; then + echo "repo: ${src}" + echo " id: ${id}" + echo " rev: ${rev}" + echo " src: ${src}" + echo " dest: ${dest}" + fi + + pushd "${dest}" 1> /dev/null + + if vs | grep -q "nothing to commit"; then + LOCAL_MODS=0 + else + LOCAL_MODS=1 + fi + + if [ "x${DISPLAY_LOCAL_MODS_ONLY}" != "x1" ]; then + # Force to display all subrepositories if -m is not specified + LOCAL_MODS=1 + fi + + if [ "x${LOCAL_MODS}" = "x1" ]; then + echo "============================" + echo "subrepo: ${dest}" + vs + fi + + popd 1> /dev/null + fi +done < .hgsub -- 2.20.1