summaryrefslogtreecommitdiff
path: root/merge-helpers
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-01-14 02:30:14 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-01-14 02:30:14 -0600
commit3f621085163cf2f3bb5bf6d0602b5f3fc6f7f4fd (patch)
treecf1ff615cf0999325ac87469a40227211fc81a49 /merge-helpers
parente6a5d7715e71d896ec389867f14829f3fb832429 (diff)
Distribute cvs-helpers to other directories.
Diffstat (limited to 'merge-helpers')
-rw-r--r--merge-helpers/Makefile6
-rw-r--r--merge-helpers/README23
-rwxr-xr-xmerge-helpers/commit171
-rwxr-xr-xmerge-helpers/commit-with-changelog-diff14
-rwxr-xr-xmerge-helpers/mkChangeLogList168
-rwxr-xr-xmerge-helpers/prepend21
6 files changed, 402 insertions, 1 deletions
diff --git a/merge-helpers/Makefile b/merge-helpers/Makefile
index 26fd792..7f35d6c 100644
--- a/merge-helpers/Makefile
+++ b/merge-helpers/Makefile
@@ -3,7 +3,11 @@
#
INSTALL_DIR=../bin
-SCRIPTS=check_submission
+SCRIPTS = check_submission
+SCRIPTS += commit-with-changelog-diff
+SCRIPTS += commit
+SCRIPTS += mkChangeLogList
+SCRIPTS += prepend
all: prep ${SCRIPTS} install
diff --git a/merge-helpers/README b/merge-helpers/README
new file mode 100644
index 0000000..f999ce9
--- /dev/null
+++ b/merge-helpers/README
@@ -0,0 +1,23 @@
+#
+# $Id$
+#
+
+This directory contains helpers for dealing with the RTEMS CVS Repository
+during maintenance activities.
+
+commit-with-changelog-diff
+ This utility is used when a patch is submitted with a diff that includes
+ the ChangeLog entry prepended to the ChangeLog. This diffs the ChangeLog
+ and extracts the added Log entry. Then it commits all files from the
+ current directory using that ChangeLog entry.
+cvscommit
+ This utility takes a message on the command line and uses mkChangeLogList
+ to properly format it. It then allows you the option to edit it and
+ commit files from the current directory using that Log entry.
+mkChangeLogList
+ This utility formats a ChangeLog entry using a message from the
+ command line. It uses the user information from /etc/passwd by
+ default but can be told to use another user's information or
+ an explicit name and email address.
+prepend
+ This is used to prepend a file to the ChangeLog.
diff --git a/merge-helpers/commit b/merge-helpers/commit
new file mode 100755
index 0000000..8d32ebc
--- /dev/null
+++ b/merge-helpers/commit
@@ -0,0 +1,171 @@
+#! /bin/sh
+#
+# Recurse from current directory assisting in generating ChangeLog entries
+# and committing files to the Source Code Repository.
+#
+# TODO:
+# + Currently supports CVS and git. Could add svn
+#
+
+progname=${0##*/}
+usage()
+{
+ echo "$progname [-dlq] [-e editor] [-u user] [-m message] [-M msgfile]"
+ echo "options:"
+ echo " -d .. debug, don't delete change files";
+ echo " -q .. quiet, don't display directories";
+ echo " -l .. local directory only";
+ echo " -m message .. text to use for modified files";
+ echo " -M msgfile .. file containing to use for modified files";
+ echo " -u user .. use user instead of LOGNAME";
+ echo " -U user .. use explicit user info -- not from passwd";
+ echo " -p PR .. PR info";
+ echo " -c CID .. Coverity Id number";
+ echo
+ exit 1
+}
+
+# Determine VCS in use
+if [ -d .git ] ; then
+ VCS=git
+elif [ -d CVS ] ; then
+ VCS=cvs
+else
+ echo "This does not look like a checkout from a VCS I understand."
+ exit 1
+fi
+
+editor="vim"
+changefile="changes-xxx"
+rem_changes="yes"
+quiet="no"
+user=$LOGNAME
+mkchoptions="-n"
+message=
+localdir="no"
+while getopts dlqe:M:m:u:U:p:c: OPT
+do
+ case "$OPT" in
+ d) rem_changes="yes" ;;
+ e) editor=$OPTARG ;;
+ l) localdir="yes" ;;
+ m) message=$OPTARG ;;
+ M) message=`cat $OPTARG` ;;
+ q) quiet="yes" ;;
+ u) user=$OPTARG ; mkchoptions=${mkchoptions}" -u ${user}" ;;
+ U) userArg="-U" userInfo=$OPTARG ;;
+ p) PrInfo=$OPTARG ; mkchoptions=${mkchoptions}" -p ${PrInfo}" ;;
+ c) CoverityInfo=$OPTARG ; mkchoptions=${mkchoptions}" -c ${CoverityInfo}" ;;
+ *) usage ;;
+ esac
+done
+
+export message
+let $((shiftcount = $OPTIND - 1))
+shift #shiftcount
+
+args=$*
+
+# find ChangeLogs and print them by depth
+get_subdirs()
+{
+ find . -name ChangeLog | while read f
+ do
+ case $1 in
+ */*/*/*/*/*/*/*/*/*) d=9 ;;
+ */*/*/*/*/*/*/*/*) d=8 ;;
+ */*/*/*/*/*/*/*) d=7 ;;
+ */*/*/*/*/*/*) d=6 ;;
+ */*/*/*/*/*) d=5 ;;
+ */*/*/*/*) d=4 ;;
+ */*/*/*) d=3 ;;
+ */*/*) d=2 ;;
+ */*) d=1 ;;
+ *) d=0 ;;
+ esac
+ echo ${d} ${f}
+ done | sort -n -r | cut -d' ' -f2- | while read f
+ do
+ dirname $f
+ done
+}
+if [ ${localdir} = "yes" ] ; then
+ subdirs="."
+else
+ subdirs=`get_subdirs`
+fi
+
+# Make sure we have user information
+if test "X${userInfo}" = "X" ; then
+ user_name=`grep ^${user} /etc/passwd | cut -d':' -f5 | cut -d',' -f1`
+ if test "X${user_name}" = "X" ; then
+ echo "User information not set"
+ usage
+ fi
+fi
+
+commit()
+{
+ if [ $? -ne 0 ] ; then
+ return
+ fi
+
+ prepend ${changefile}
+
+ # Specify VCS support directory
+ case ${VCS} in
+ cvs)
+ ${CVS} up ChangeLog
+ cvs commit -F ${changefile}
+ ;;
+ git)
+ echo "git commit -F ${changefile}"
+ git commit -a -F ${changefile}
+ ;;
+ *) echo "${VCS} to be implemented" ; exit 1 ;;
+ esac
+}
+
+# Specify VCS support directory
+case ${VCS} in
+ cvs) VCSDIR=CVS ;;
+ git) VCSDIR=.git ;;
+ *)
+ echo "${VCS} to be implemented"
+ exit 1
+ ;;
+esac
+
+for ddir in ${subdirs} ; do
+ test "${ddir}" = "${VCSDIR}" && continue
+ test "${ddir}" = "autom4te.cache" && continue
+ test "${ddir}" = "install" && continue
+ if [ -d "${ddir}" ]; then
+ if [ ! -d "${ddir}/${VCSDIR}" ] ; then
+ echo "WARNING - ${ddir} is not in .git"
+ continue
+ fi
+ test -f "${ddir}/ChangeLog" || continue
+ cd "$ddir" >/dev/null
+ mkChangeLogList ${mkchoptions} ${userArg} "${userInfo}" \
+ -m "${message}" >${changefile}
+ test $? -ne 0 && continue
+ while test -s ${changefile} ; do
+ fullpath=`pwd`
+ test "$quiet" = "no" && echo "** directory: $fullpath **"
+ cat ${changefile}
+ response="n"
+ read -p "Commit changes? [y/n/e(edit)]: " response
+ case ${response} in
+ y) commit; break ;;
+ n) break ;;
+ e) ${editor} ${changefile} ;;
+ *) echo "*** enter y,n, or e ***" ;;
+ esac
+ done
+ test $rem_changes = "yes" && rm -rf $changefile
+ cd - >/dev/null
+ fi
+done
+
+
diff --git a/merge-helpers/commit-with-changelog-diff b/merge-helpers/commit-with-changelog-diff
new file mode 100755
index 0000000..f1bf5e5
--- /dev/null
+++ b/merge-helpers/commit-with-changelog-diff
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+if [ ! -r ChangeLog ] ; then
+ echo "ERROR: No ChangeLog in current directory."
+ exit 1
+fi
+
+cvs diff -u ChangeLog| grep ^+ | \
+ sed -e '/^+++/d' -e 's/^+ //' -e 's/^+//' >ch
+cat ch
+
+cvs commit -F ch
+rm -f ch
+exit 0
diff --git a/merge-helpers/mkChangeLogList b/merge-helpers/mkChangeLogList
new file mode 100755
index 0000000..5d9fe9c
--- /dev/null
+++ b/merge-helpers/mkChangeLogList
@@ -0,0 +1,168 @@
+#! /bin/sh
+#
+# Use git from the current directory and put the file names
+# in suitable format for use in a ChangeLog.
+#
+# TODO: Initial conversion from cvs
+#
+# $Id: mkChangeLogList,v 1.6 2011/01/04 19:53:53 joel Exp $
+#
+
+mklog_()
+{
+ cat >XXX
+ if test `cat XXX | wc -l` -ne 0 ; then
+ (cat XXX | cut -d':' -f2 | \
+ sed -e '$!s/$/,/' -e '$s/$/:/' ; \
+ test $? -ne 0 || echo "$*" )| \
+ xargs -s80 | sed -e '1s/^/ \* /' -e '2,$s/^/ /'
+ fi
+ rm -f XXX
+}
+
+progname=${0##*/}
+usage()
+{
+ echo "$progname [-ln] [-u user] [-U user_information] [-m message] [-M msgfile]"
+ exit 1
+}
+
+print_name="no"
+user=$LOGNAME
+git_local_arg=""
+basedir=.
+while getopts d:lnM:m:p:c:u:U: OPT
+do
+ case "$OPT" in
+ d) basedir=$OPTARG ;;
+ l) git_local_arg="-l" ;;
+ n) print_name="yes" ;;
+ p) prnum=$OPTARG ;;
+ c) coverity_num=$OPTARG ;;
+ m) message=$OPTARG ;;
+ M) message=`cat $OPTARG` ;;
+ u) user=$OPTARG ; print_name="yes" ;;
+ U) user_name=$OPTARG ; print_name="yes" ;;
+ *) usage ;;
+ esac
+done
+
+let $((shiftcount = $OPTIND - 1))
+shift #shiftcount
+
+args=$*
+
+dirarg="${basedir}"
+
+# Determine VCS in use
+if [ -d .git ] ; then
+ VCS=git
+elif [ -d CVS ] ; then
+ VCS=cvs
+else
+ echo "This does not look like a checkout from a VCS I understand."
+ exit 1
+fi
+
+if [ ! -r ChangeLog ] ; then
+ ( echo "There is no ChangeLog in this directory." ;
+ echo "Where are you putting the entry?" )>/dev/stderr
+ exit 1
+fi
+
+case ${VCS} in
+ cvs)
+ # done parsing arguments, now work
+ if [ "X${CVSROOT}" = "X" ] ; then
+ CVS=cvs
+ else
+ CVS="cvs -d ${CVSROOT}"
+ fi
+ CVS="${CVS}"
+
+ files_modded=`${CVS} diff ${dirarg} 2>&1 | grep ^Index | wc -l`
+ files_added=`${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no " | wc -l`
+ files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
+ ;;
+ git)
+ files_modded=`git status ${dirarg} 2>&1 | grep "modified: " | wc -l`
+ files_added=`git status ${dirarg} 2>&1 | grep "new file: " | wc -l`
+ files_deleted=0
+ #files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
+ ;;
+ *)
+ echo "${VCS} to be implemented"
+ exit 1
+ ;;
+esac
+
+files_changed=`expr ${files_modded} + ${files_added} + ${files_deleted}`
+if test ${files_changed} -eq 0 ; then
+ exit 0
+fi
+
+if test ${print_name} = "yes" ; then
+ if test "X${user_name}" = "X" ; then
+ if test "X${user}" = "X" ; then
+ echo "User not specified (LOGNAME not set or no -u option)"
+ usage
+ fi
+
+ user_name=`grep ^${user} /etc/passwd | cut -d':' -f5 | cut -d',' -f1`
+ if test "X${user_name}" = "X" ; then
+ echo "User information not set"
+ usage
+ fi
+ fi
+
+ date=`date +%Y-%m-%d`
+ echo "${date} ${user_name}"
+ echo
+fi
+
+if test "X${prnum}" != "X" ; then
+ echo " PR ${prnum}"
+fi
+if test "X${coverity_num}" != "X" ; then
+ echo " Coverity Id ${coverity_num}"
+fi
+
+case ${VCS} in
+ cvs)
+ # Generate list of modified files
+ ${CVS} diff ${dirarg} 2>/dev/null | grep ^Index | mklog_ ${message}
+
+ # Generate list of deleted files
+ test ${files_added} -gt 1 && plural=s
+ ${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no comparison" | \
+ sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
+
+ # Generate list of removed files
+ ${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
+ sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
+ mklog_ Removed.
+ ;;
+ git)
+ # Generate list of modified files
+ git status 2>&1 | grep "modified: " | mklog_ ${message}
+
+ # Generate list of deleted files
+ test ${files_added} -gt 1 && plural=s
+ git status 2>&1 | grep "new file: " | \
+ sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
+
+ # Generate list of removed files
+ #${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
+ # sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
+ # mklog_ Removed.
+ ;;
+ *)
+ echo "${VCS} to be implemented"
+ exit 1
+ ;;
+esac
+
+echo
+
+# rm -f XXX
+exit 0
diff --git a/merge-helpers/prepend b/merge-helpers/prepend
new file mode 100755
index 0000000..454a5fa
--- /dev/null
+++ b/merge-helpers/prepend
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+if [ ! -r ChangeLog ] ; then
+ echo ChangeLog does not exist
+ exit 1
+fi
+
+if [ $# -ne 1 ] ; then
+ echo no file to prepend to ChangeLog specified
+ exit 1
+fi
+
+if [ ! -r $1 ] ; then
+ echo $1 does not exist so can not be prepended to ChangeLog
+ exit 1
+fi
+
+mv ChangeLog XXX
+cat $1 XXX > ChangeLog
+rm -f XXX
+exit 0