From fd43e21740dfed8d6eb0e5471a879689b6b2e786 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 17 Mar 2018 02:33:04 -0700 Subject: [PATCH] tg-info: omit annihilated dependencies from list When showing the "Depends:" list for a branch omit any dependencies that have been annihilated. This matches the behavior of other TopGit commands and annihilated branches are supposed to just "get out of your way". However, if `--verbose` is given at least twice, then do include them (just like `tg summary --verbose --verbose --list` does) with an annotation that they've been annihilated. A side-effect of this change is that `tg info` now handles oddly formatted `.topdeps` files a bit more gracefully. Signed-off-by: Kyle J. McKay --- README | 2 ++ tg-info.sh | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README b/README index 62913ed..3f04e8a 100644 --- a/README +++ b/README @@ -1119,6 +1119,8 @@ tg info branches that depend on this one). Another ``--verbose`` annotates them with "[needs merge]" if the current tip of branch for which info is being shown has not yet been merged into the base of the dependent. + Two ``--verbose`` options also cause annihilated dependencies to be + shown in the "Depends:" list. Alternatively, if ``--heads`` is used then which of the independent TopGit branch heads (as output by ``tg summary --topgit-heads``) diff --git a/tg-info.sh b/tg-info.sh index 11c625c..f9bbc43 100644 --- a/tg-info.sh +++ b/tg-info.sh @@ -262,8 +262,34 @@ if has_remote "$name"; then echo "* Local head is ahead of the remote head." fi -cat_file "refs/heads/$name:.topdeps" ${noskipiw:+$head_from} 2>/dev/null | -awk 'NR == 1 {print "Depends: " $0} NR != 1 {print " " $0}' +anflag= +[ "${verbose:-0}" -lt 2 ] || anflag=1 +depslist="$(get_temp topdeps)" +cat_file "refs/heads/$name:.topdeps" ${noskipiw:+$head_from} >"$depslist" 2>/dev/null +eval run_awk_topgit_msg "$tm_opt" '"refs/$topbases"' "$(awk -v p="refs/$topbases/" <"$depslist" ' + function sq(x) { + gsub(/\047/, "\047\\\047\047", x) + return "\047" x "\047" + } + {sub(/\r$/, "")} + NF == 1 && $0 != "" && $0 !~ /[ \t\r\n*?:[^~\\]/ {printf "%s ", sq(p $0)} +')" | awk -v an="$anflag" -v df="$depslist" ' + NF >= 2 && $1 != "" && $2 ~ /^[0-4]$/ {bt[$1] = 0 + $2} + END { + prefix = "Depends: " + while ((e = (getline adep 0) { + sub(/\r$/, "", adep) + if (adep == "" || adep ~ /[ \t\r\n*?:[^~\\]/) continue + if (!an && bt[adep] == 2) continue + suffix = "" + if (bt[adep] == 2) suffix = " (annihilated)" + print prefix adep suffix + prefix = " " + } + close(df) + if (e < 0) exit 2; + } +' depcheck="$(get_temp tg-depcheck)" missing_deps= -- 2.11.4.GIT