1443 #
1444 comments_from_teamware()
1445 {
1446 fmt=$1
1447 pfile=$PWS/$2
1448 cfile=$CWS/$3
1449
1450 if [[ ! -f $PWS/${2%/*}/SCCS/s.${2##*/} && -n $RWS ]]; then
1451 pfile=$RWS/$2
1452 fi
1453
1454 if [[ -f $pfile ]]; then
1455 psid=$($SCCS prs -d:I: $pfile 2>/dev/null)
1456 else
1457 psid=1.1
1458 fi
1459
1460 set -A sids $($SCCS prs -l -r$psid -d:I: $cfile 2>/dev/null)
1461 N=${#sids[@]}
1462
1463 nawkprg='
1464 /^COMMENTS:/ {p=1; continue}
1465 /^D [0-9]+\.[0-9]+/ {printf "--- %s ---\n", $2; p=0; }
1466 NF == 0u { continue }
1467 {if (p==0) continue; print $0 }'
1468
1469 if [[ $N -ge 2 ]]; then
1470 sid1=${sids[$((N-2))]} # Gets 2nd to last sid
1471
1472 if [[ $fmt == "text" ]]; then
1473 $SCCS prs -l -r$sid1 $cfile 2>/dev/null | \
1474 $AWK "$nawkprg"
1475 return
1476 fi
1477
1478 $SCCS prs -l -r$sid1 $cfile 2>/dev/null | \
1479 html_quote | its2url | $AWK "$nawkprg"
1480 fi
1481 }
1482
1483 #
1484 # comments_from_wx {text|html} filepath
1485 #
1486 # Given the pathname of a file, find its location in a "wx" active
1487 # file list and print the following comment. Output is either text or
1488 # HTML; if the latter, embedded bugids (sequence of 5 or more digits)
1489 # are turned into URLs.
1490 #
1491 # This is also used with Mercurial and the file list provided by hg-active.
1492 #
1493 comments_from_wx()
1494 {
1495 typeset fmt=$1
1496 typeset p=$2
1497
1498 comm=`$AWK '
1499 $1 == "'$p'" {
2782 exit 1
2783 fi
2784
2785 pnode=$(trim_digest $HG_PARENT)
2786 PRETTY_PWS="${PWS} (at ${pnode})"
2787 cnode=$(hg parent -R $codemgr_ws --template '{node|short}' \
2788 2>/dev/null)
2789 PRETTY_CWS="${CWS} (at ${cnode})"}
2790 elif [[ $SCM_MODE == "git" ]]; then
2791 #
2792 # Parent can either be specified with -p, or specified with
2793 # CODEMGR_PARENT in the environment.
2794 #
2795
2796 if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then
2797 codemgr_parent=$CODEMGR_PARENT
2798 fi
2799
2800 # Try to figure out the parent based on the branch the current
2801 # branch is tracking, if we fail, use origin/master
2802 this_branch=$($GIT branch | nawk '$1 == "*" { print $2 }')
2803 par_branch="origin/master"
2804
2805 # If we're not on a branch there's nothing we can do
2806 if [[ $this_branch != "(no branch)" ]]; then
2807 $GIT for-each-ref \
2808 --format='%(refname:short) %(upstream:short)' refs/heads/ | \
2809 while read local remote; do \
2810 [[ "$local" == "$this_branch" ]] && par_branch="$remote"; \
2811 done
2812 fi
2813
2814 if [[ -z $codemgr_parent ]]; then
2815 codemgr_parent=$par_branch
2816 fi
2817 PWS=$codemgr_parent
2818
2819 #
2820 # If the parent is a webrev, we want to do some things against
2821 # the natural workspace parent (file list, comments, etc)
2822 #
|
1443 #
1444 comments_from_teamware()
1445 {
1446 fmt=$1
1447 pfile=$PWS/$2
1448 cfile=$CWS/$3
1449
1450 if [[ ! -f $PWS/${2%/*}/SCCS/s.${2##*/} && -n $RWS ]]; then
1451 pfile=$RWS/$2
1452 fi
1453
1454 if [[ -f $pfile ]]; then
1455 psid=$($SCCS prs -d:I: $pfile 2>/dev/null)
1456 else
1457 psid=1.1
1458 fi
1459
1460 set -A sids $($SCCS prs -l -r$psid -d:I: $cfile 2>/dev/null)
1461 N=${#sids[@]}
1462
1463 awkprg='
1464 /^COMMENTS:/ {p=1; continue}
1465 /^D [0-9]+\.[0-9]+/ {printf "--- %s ---\n", $2; p=0; }
1466 NF == 0u { continue }
1467 {if (p==0) continue; print $0 }'
1468
1469 if [[ $N -ge 2 ]]; then
1470 sid1=${sids[$((N-2))]} # Gets 2nd to last sid
1471
1472 if [[ $fmt == "text" ]]; then
1473 $SCCS prs -l -r$sid1 $cfile 2>/dev/null | \
1474 $AWK "$awkprg"
1475 return
1476 fi
1477
1478 $SCCS prs -l -r$sid1 $cfile 2>/dev/null | \
1479 html_quote | its2url | $AWK "$awkprg"
1480 fi
1481 }
1482
1483 #
1484 # comments_from_wx {text|html} filepath
1485 #
1486 # Given the pathname of a file, find its location in a "wx" active
1487 # file list and print the following comment. Output is either text or
1488 # HTML; if the latter, embedded bugids (sequence of 5 or more digits)
1489 # are turned into URLs.
1490 #
1491 # This is also used with Mercurial and the file list provided by hg-active.
1492 #
1493 comments_from_wx()
1494 {
1495 typeset fmt=$1
1496 typeset p=$2
1497
1498 comm=`$AWK '
1499 $1 == "'$p'" {
2782 exit 1
2783 fi
2784
2785 pnode=$(trim_digest $HG_PARENT)
2786 PRETTY_PWS="${PWS} (at ${pnode})"
2787 cnode=$(hg parent -R $codemgr_ws --template '{node|short}' \
2788 2>/dev/null)
2789 PRETTY_CWS="${CWS} (at ${cnode})"}
2790 elif [[ $SCM_MODE == "git" ]]; then
2791 #
2792 # Parent can either be specified with -p, or specified with
2793 # CODEMGR_PARENT in the environment.
2794 #
2795
2796 if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then
2797 codemgr_parent=$CODEMGR_PARENT
2798 fi
2799
2800 # Try to figure out the parent based on the branch the current
2801 # branch is tracking, if we fail, use origin/master
2802 this_branch=$($GIT branch | /usr/xpg4/bin/awk '$1 == "*" { print $2 }')
2803 par_branch="origin/master"
2804
2805 # If we're not on a branch there's nothing we can do
2806 if [[ $this_branch != "(no branch)" ]]; then
2807 $GIT for-each-ref \
2808 --format='%(refname:short) %(upstream:short)' refs/heads/ | \
2809 while read local remote; do \
2810 [[ "$local" == "$this_branch" ]] && par_branch="$remote"; \
2811 done
2812 fi
2813
2814 if [[ -z $codemgr_parent ]]; then
2815 codemgr_parent=$par_branch
2816 fi
2817 PWS=$codemgr_parent
2818
2819 #
2820 # If the parent is a webrev, we want to do some things against
2821 # the natural workspace parent (file list, comments, etc)
2822 #
|