Replace SC_VCS=git-svn with SC_WANT_CHANGELOG.

Now ChangeLog creation is controlled directly by a dedicated variable.
It is disabled by default, and enabled implicitly with cvs, svn and
git-svn. It can be enabled explicitly via `-c' too.

SC_VCS no longer will contain git-svn -- it will be simply git. That
simplifies a lot of checks in the code.
This commit is contained in:
Michał Górny 2010-11-01 23:13:55 +01:00
parent de3ab6ece9
commit 09661479e0
2 changed files with 16 additions and 15 deletions

View File

@ -35,9 +35,9 @@ repository (due to limitations of non-distributed VCSes).
.IP "\fB-c\fP, \fB--changelog\fP" .IP "\fB-c\fP, \fB--changelog\fP"
Ignored (provided for backwards compatibility). ChangeLog entries are Force creating a ChangeLog even if DVCS is used. Otherwise, ChangeLog
now created as needed. Use \fB--trivial\fP to suppress creation of entries will be created if needed. Use \fB--trivial\fP to suppress
ChangeLog entries. creation of ChangeLog entries.
Because of the nature of DVCSes, a ChangeLog will not be created for a Because of the nature of DVCSes, a ChangeLog will not be created for a
new ebuild in a GIT or Mercurial repository. However, if the ebuild new ebuild in a GIT or Mercurial repository. However, if the ebuild

View File

@ -52,6 +52,8 @@ local_supported || eval 'local() {
# See if we're in a repo, and what VCS are we using. # See if we're in a repo, and what VCS are we using.
find_repo() { find_repo() {
: ${SC_WANT_CHANGELOG=}
if svn info >/dev/null 2>&1; then if svn info >/dev/null 2>&1; then
SC_VCS=svn SC_VCS=svn
elif hg tip >/dev/null 2>&1; then elif hg tip >/dev/null 2>&1; then
@ -65,10 +67,9 @@ find_repo() {
if [ ${ret} -ne 127 ] && [ ${ret} -ne 128 ]; then if [ ${ret} -ne 127 ] && [ ${ret} -ne 128 ]; then
if echo "${remotes}" | grep git-svn >/dev/null 2>&1; then if echo "${remotes}" | grep git-svn >/dev/null 2>&1; then
SC_VCS=git-svn SC_WANT_CHANGELOG=1
else
SC_VCS=git
fi fi
SC_VCS=git-svn
else else
die 'Unable to find any familiar repository type (are you inside the repo?).' die 'Unable to find any familiar repository type (are you inside the repo?).'
fi fi
@ -82,7 +83,7 @@ find_repo() {
is_whole_dir_removed() { is_whole_dir_removed() {
if [ ${SC_VCS} = svn ]; then if [ ${SC_VCS} = svn ]; then
[ "$(svn status --depth=empty -- "${1}" | wc -l)" = 1 ] [ "$(svn status --depth=empty -- "${1}" | wc -l)" = 1 ]
elif [ ${SC_VCS%-svn} = git ]; then elif [ ${SC_VCS} = git ]; then
[ -z "$(git ls-files -c -- "${1}")" ] [ -z "$(git ls-files -c -- "${1}")" ]
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
[ -z "$(hg status -madc "${1}")" ] [ -z "$(hg status -madc "${1}")" ]
@ -96,7 +97,7 @@ is_package_removal() {
local fields list local fields list
[ -d profiles ] && fields=1-2 || fields=1 [ -d profiles ] && fields=1-2 || fields=1
if [ ${SC_VCS%-svn} = git ]; then if [ ${SC_VCS} = git ]; then
list=$(git diff-index --relative --name-only --diff-filter=D HEAD) list=$(git diff-index --relative --name-only --diff-filter=D HEAD)
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
list=$(hg status -nr .) list=$(hg status -nr .)
@ -189,7 +190,7 @@ find_ebuilds() {
check_for_changes() { check_for_changes() {
local output local output
if [ ${SC_VCS%-svn} = git ]; then if [ ${SC_VCS} = git ]; then
output=$(git diff-index --name-only --relative HEAD -- "${@}") output=$(git diff-index --name-only --relative HEAD -- "${@}")
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
output=$(hg status -- ${1-.} "${@}") output=$(hg status -- ${1-.} "${@}")
@ -207,7 +208,7 @@ check_for_changes() {
# Discard any changes to a particular set of files. # Discard any changes to a particular set of files.
vcs_reset() { vcs_reset() {
if [ ${SC_VCS%-svn} = git ]; then if [ ${SC_VCS} = git ]; then
git checkout HEAD -- "${@}" 2>/dev/null || req rm -f -- "${@}" git checkout HEAD -- "${@}" 2>/dev/null || req rm -f -- "${@}"
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
[ -n "$(hg status -au "${@}")" ] && req rm -f -- "${@}" [ -n "$(hg status -au "${@}")" ] && req rm -f -- "${@}"
@ -225,7 +226,7 @@ vcs_reset() {
# Request VCS to provide a verbose status report. # Request VCS to provide a verbose status report.
vcs_status() { vcs_status() {
if [ ${SC_VCS%-svn} = git ]; then if [ ${SC_VCS} = git ]; then
git status -s -- ${1-.} "${@}" git status -s -- ${1-.} "${@}"
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
hg status -- ${1-.} "${@}" hg status -- ${1-.} "${@}"
@ -238,7 +239,7 @@ vcs_status() {
# Add particular files to the repository. # Add particular files to the repository.
vcs_add() { vcs_add() {
${SC_VCS%-svn} add -- "${@}" ${SC_VCS} add -- "${@}"
} }
# Commit the specified objects using the commit message provided # Commit the specified objects using the commit message provided
@ -248,7 +249,7 @@ vcs_commit() {
msg=${1} msg=${1}
shift shift
if [ ${SC_VCS%-svn} = git ]; then if [ ${SC_VCS} = git ]; then
exec git commit -m "${msg}" ${1+-o} -- "${@}" exec git commit -m "${msg}" ${1+-o} -- "${@}"
elif [ ${SC_VCS} = hg ]; then elif [ ${SC_VCS} = hg ]; then
exec hg commit -m "${msg}" -- ${1-.} "${@}" exec hg commit -m "${msg}" -- ${1-.} "${@}"
@ -332,7 +333,7 @@ main() {
;; ;;
-c|--changelog) -c|--changelog)
# Now changelog entries are implicit -- backwards compat. SC_WANT_CHANGELOG=1
;; ;;
-C|--nocolor) -C|--nocolor)
monochrome=1 monochrome=1
@ -408,7 +409,7 @@ main() {
# With DVCS repos, we do not do ChangeLogs by default... # With DVCS repos, we do not do ChangeLogs by default...
# ...at least unless they're already there. # ...at least unless they're already there.
if [ ${SC_VCS#git-} = svn ] || [ ${SC_VCS} = cvs ] || [ -f ChangeLog ]; then if [ -n "${SC_WANT_CHANGELOG}" ] || [ -f ChangeLog ]; then
sayv 'Cleaning up the ChangeLog...' sayv 'Cleaning up the ChangeLog...'
vcs_reset ChangeLog vcs_reset ChangeLog