1762 #
1763 function flist_from_mercurial
1764 {
1765 typeset child=$1
1766 typeset parent=$2
1767
1768 print " File list from: hg-active -p $parent ...\c"
1769
1770 if [[ ! -x $HG_ACTIVE ]]; then
1771 print # Blank line for the \c above
1772 print -u2 "Error: hg-active tool not found. Exiting"
1773 exit 1
1774 fi
1775 hg_active_wxfile $child $parent
1776
1777 # flist_from_wx prints the Done, so we don't have to.
1778 flist_from_wx $TMPFLIST
1779 }
1780
1781 #
1782 # flist_from_subversion
1783 #
1784 # Generate the file list by extracting file names from svn status.
1785 #
1786 function flist_from_subversion
1787 {
1788 CWS=$1
1789 OLDPWD=$2
1790
1791 cd $CWS
1792 print -u2 " File list from: svn status ... \c"
1793 svn status | $AWK '/^[ACDMR]/ { print $NF }' > $FLIST
1794 print -u2 " Done."
1795 cd $OLDPWD
1796 }
1797
1798 function env_from_flist
1799 {
1800 [[ -r $FLIST ]] || return
1801
1981 #
1982 if [[ -n $parent_webrev && -e $PWS/$PDIR/$PF ]]; then
1983 cp $PWS/$PDIR/$PF $olddir/$PDIR/$PF
1984 elif [[ -n $HG_PARENT ]]; then
1985 hg cat -R $CWS -r $HG_PARENT $CWS/$PDIR/$PF > \
1986 $olddir/$PDIR/$PF 2>/dev/null
1987
1988 if (( $? != 0 )); then
1989 rm -f $olddir/$PDIR/$PF
1990 else
1991 if [[ -n $old_mode ]]; then
1992 chmod $old_mode $olddir/$PDIR/$PF
1993 else
1994 # should never happen
1995 print -u2 "ERROR: set mode of $olddir/$PDIR/$PF"
1996 fi
1997 fi
1998 fi
1999 }
2000
2001 function build_old_new_subversion
2002 {
2003 typeset olddir="$1"
2004 typeset newdir="$2"
2005
2006 # Snag new version of file.
2007 rm -f $newdir/$DIR/$F
2008 [[ -e $CWS/$DIR/$F ]] && cp $CWS/$DIR/$F $newdir/$DIR/$F
2009
2010 if [[ -n $PWS && -e $PWS/$PDIR/$PF ]]; then
2011 cp $PWS/$PDIR/$PF $olddir/$PDIR/$PF
2012 else
2013 # Get the parent's version of the file.
2014 svn status $CWS/$DIR/$F | read stat file
2015 if [[ $stat != "A" ]]; then
2016 svn cat -r BASE $CWS/$DIR/$F > $olddir/$PDIR/$PF
2017 fi
2018 fi
2019 }
2020
2041 function build_old_new
2042 {
2043 typeset WDIR=$1
2044 typeset PWS=$2
2045 typeset PDIR=$3
2046 typeset PF=$4
2047 typeset CWS=$5
2048 typeset DIR=$6
2049 typeset F=$7
2050
2051 typeset olddir="$WDIR/raw_files/old"
2052 typeset newdir="$WDIR/raw_files/new"
2053
2054 mkdir -p $olddir/$PDIR
2055 mkdir -p $newdir/$DIR
2056
2057 if [[ $SCM_MODE == "teamware" ]]; then
2058 build_old_new_teamware "$olddir" "$newdir"
2059 elif [[ $SCM_MODE == "mercurial" ]]; then
2060 build_old_new_mercurial "$olddir" "$newdir"
2061 elif [[ $SCM_MODE == "subversion" ]]; then
2062 build_old_new_subversion "$olddir" "$newdir"
2063 elif [[ $SCM_MODE == "unknown" ]]; then
2064 build_old_new_unknown "$olddir" "$newdir"
2065 fi
2066
2067 if [[ ! -f $olddir/$PDIR/$PF && ! -f $newdir/$DIR/$F ]]; then
2068 print "*** Error: file not in parent or child"
2069 return 1
2070 fi
2071 return 0
2072 }
2073
2074
2075 #
2076 # Usage message.
2077 #
2078 function usage
2079 {
2080 print 'Usage:\twebrev [common-options]
2107 '
2108
2109 exit 2
2110 }
2111
2112 #
2113 #
2114 # Main program starts here
2115 #
2116 #
2117
2118 trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
2119
2120 set +o noclobber
2121
2122 PATH=$(dirname $(whence $0)):$PATH
2123
2124 [[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
2125 [[ -z $WX ]] && WX=`look_for_prog wx`
2126 [[ -z $HG_ACTIVE ]] && HG_ACTIVE=`look_for_prog hg-active`
2127 [[ -z $WHICH_SCM ]] && WHICH_SCM=`look_for_prog which_scm`
2128 [[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
2129 [[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
2130 [[ -z $PERL ]] && PERL=`look_for_prog perl`
2131 [[ -z $RSYNC ]] && RSYNC=`look_for_prog rsync`
2132 [[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
2133 [[ -z $AWK ]] && AWK=`look_for_prog nawk`
2134 [[ -z $AWK ]] && AWK=`look_for_prog gawk`
2135 [[ -z $AWK ]] && AWK=`look_for_prog awk`
2136 [[ -z $SCP ]] && SCP=`look_for_prog scp`
2137 [[ -z $SED ]] && SED=`look_for_prog sed`
2138 [[ -z $SFTP ]] && SFTP=`look_for_prog sftp`
2139 [[ -z $MKTEMP ]] && MKTEMP=`look_for_prog mktemp`
2140 [[ -z $GREP ]] && GREP=`look_for_prog grep`
2141 [[ -z $FIND ]] && FIND=`look_for_prog find`
2142
2143 # set name of trash directory for remote webrev deletion
2144 TRASH_DIR=".trash"
2145 [[ -n $WEBREV_TRASH_DIR ]] && TRASH_DIR=$WEBREV_TRASH_DIR
2146
2272 #
2273 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
2274 if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then
2275 print -u2 "$codemgr_ws: no such workspace"
2276 exit 1
2277 fi
2278 [[ -z $codemgr_ws ]] && codemgr_ws=$(workspace name)
2279 codemgr_ws=$(cd $codemgr_ws;print $PWD)
2280 CODEMGR_WS=$codemgr_ws
2281 CWS=$codemgr_ws
2282 elif [[ $SCM_MODE == "mercurial" ]]; then
2283 #
2284 # Mercurial priorities:
2285 # 1. hg root from CODEMGR_WS environment variable
2286 # 2. hg root from directory of invocation
2287 #
2288 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && \
2289 codemgr_ws=$(hg root -R $CODEMGR_WS 2>/dev/null)
2290 [[ -z $codemgr_ws ]] && codemgr_ws=$(hg root 2>/dev/null)
2291 CWS=$codemgr_ws
2292 elif [[ $SCM_MODE == "subversion" ]]; then
2293 #
2294 # Subversion priorities:
2295 # 1. CODEMGR_WS from environment
2296 # 2. Relative path from current directory to SVN repository root
2297 #
2298 if [[ -n $CODEMGR_WS && -d $CODEMGR_WS/.svn ]]; then
2299 CWS=$CODEMGR_WS
2300 else
2301 svn info | while read line; do
2302 if [[ $line == "URL: "* ]]; then
2303 url=${line#URL: }
2304 elif [[ $line == "Repository Root: "* ]]; then
2305 repo=${line#Repository Root: }
2306 fi
2307 done
2308
2309 rel=${url#$repo}
2310 CWS=${PWD%$rel}
2311 fi
2357 elif [[ -n $1 ]]; then
2358 if [[ ! -r $1 ]]; then
2359 print -u2 "$1: no such file or not readable"
2360 usage
2361 fi
2362 cat $1 > $FLIST
2363 flist_mode="file"
2364 flist_file=$1
2365 flist_done=1
2366 shift
2367 else
2368 flist_mode="auto"
2369 fi
2370 fi
2371
2372 #
2373 # Before we go on to further consider -l and -w, work out which SCM we think
2374 # is in use.
2375 #
2376 case "$SCM_MODE" in
2377 teamware|mercurial|subversion)
2378 ;;
2379 unknown)
2380 if [[ $flist_mode == "auto" ]]; then
2381 print -u2 "Unable to determine SCM in use and file list not specified"
2382 print -u2 "See which_scm(1) for SCM detection information."
2383 exit 1
2384 fi
2385 ;;
2386 *)
2387 if [[ $flist_mode == "auto" ]]; then
2388 print -u2 "Unsupported SCM in use ($SCM_MODE) and file list not specified"
2389 exit 1
2390 fi
2391 ;;
2392 esac
2393
2394 print -u2 " SCM detected: $SCM_MODE"
2395
2396 if [[ -n $lflag ]]; then
2397 #
2501 # If by hook or by crook we've gotten a file list by now (perhaps
2502 # from the command line), eval it to extract environment variables from
2503 # it: This is method 3 for finding the parent.
2504 #
2505 if [[ -z $flist_done ]]; then
2506 flist_from_teamware
2507 fi
2508 env_from_flist
2509
2510 #
2511 # (4) If we still don't have a value for codemgr_parent, get it
2512 # from workspace.
2513 #
2514 [[ -z $codemgr_parent ]] && codemgr_parent=`workspace parent`
2515 if [[ ! -d $codemgr_parent ]]; then
2516 print -u2 "$CODEMGR_PARENT: no such parent workspace"
2517 exit 1
2518 fi
2519
2520 PWS=$codemgr_parent
2521
2522 [[ -n $parent_webrev ]] && RWS=$(workspace parent $CWS)
2523
2524 elif [[ $SCM_MODE == "mercurial" ]]; then
2525 #
2526 # Parent can either be specified with -p
2527 # Specified with CODEMGR_PARENT in the environment
2528 # or taken from hg's default path.
2529 #
2530
2531 if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then
2532 codemgr_parent=$CODEMGR_PARENT
2533 fi
2534
2535 if [[ -z $codemgr_parent ]]; then
2536 codemgr_parent=`hg path -R $codemgr_ws default 2>/dev/null`
2537 fi
2538
2539 CWS_REV=`hg parent -R $codemgr_ws --template '{node|short}' 2>/dev/null`
2540 PWS=$codemgr_parent
2583 # At this point we must have a wx flist either from hg-active,
2584 # or in general. Use it to try and find our parent revision,
2585 # if we don't have one.
2586 #
2587 if [[ -z $HG_PARENT ]]; then
2588 eval `$SED -e "s/#.*$//" $wxfile | $GREP HG_PARENT=`
2589 fi
2590
2591 #
2592 # If we still don't have a parent, we must have been given a
2593 # wx-style active list with no HG_PARENT specification, run
2594 # hg-active and pull an HG_PARENT out of it, ignore the rest.
2595 #
2596 if [[ -z $HG_PARENT && -x $HG_ACTIVE ]]; then
2597 $HG_ACTIVE -w $codemgr_ws -p $real_parent | \
2598 eval `$SED -e "s/#.*$//" | $GREP HG_PARENT=`
2599 elif [[ -z $HG_PARENT ]]; then
2600 print -u2 "Error: Cannot discover parent revision"
2601 exit 1
2602 fi
2603 elif [[ $SCM_MODE == "subversion" ]]; then
2604
2605 #
2606 # We only will have a real parent workspace in the case one
2607 # was specified (be it an older webrev, or another checkout).
2608 #
2609 [[ -n $codemgr_parent ]] && PWS=$codemgr_parent
2610
2611 if [[ -z $flist_done && $flist_mode == "auto" ]]; then
2612 flist_from_subversion $CWS $OLDPWD
2613 fi
2614 else
2615 if [[ $SCM_MODE == "unknown" ]]; then
2616 print -u2 " Unknown type of SCM in use"
2617 else
2618 print -u2 " Unsupported SCM in use: $SCM_MODE"
2619 fi
2620
2621 env_from_flist
2622
|
1762 #
1763 function flist_from_mercurial
1764 {
1765 typeset child=$1
1766 typeset parent=$2
1767
1768 print " File list from: hg-active -p $parent ...\c"
1769
1770 if [[ ! -x $HG_ACTIVE ]]; then
1771 print # Blank line for the \c above
1772 print -u2 "Error: hg-active tool not found. Exiting"
1773 exit 1
1774 fi
1775 hg_active_wxfile $child $parent
1776
1777 # flist_from_wx prints the Done, so we don't have to.
1778 flist_from_wx $TMPFLIST
1779 }
1780
1781 #
1782 # Call git-active to get the active list output in the wx active list format
1783 #
1784 function git_active_wxfile
1785 {
1786 typeset child=$1
1787 typeset parent=$2
1788
1789 TMPFLIST=/tmp/$$.active
1790 $GIT_ACTIVE -w $child -p $parent -o $TMPFLIST
1791 wxfile=$TMPFLIST
1792 }
1793
1794 #
1795 # flist_from_git
1796 # Call git-active to get a wx-style active list, and hand it off to
1797 # flist_from_wx
1798 #
1799 function flist_from_git
1800 {
1801 typeset child=$1
1802 typeset parent=$2
1803
1804 print " File list from: git-active -p $parent ...\c"
1805
1806 if [[ ! -x $GIT_ACTIVE ]]; then
1807 print # Blank line for the \c above
1808 print -u2 "Error: git-active tool not found. Exiting"
1809 exit 1
1810 fi
1811 git_active_wxfile $child $parent
1812
1813 # flist_from_wx prints the Done, so we don't have to.
1814 flist_from_wx $TMPFLIST
1815 }
1816
1817 #
1818 # flist_from_subversion
1819 #
1820 # Generate the file list by extracting file names from svn status.
1821 #
1822 function flist_from_subversion
1823 {
1824 CWS=$1
1825 OLDPWD=$2
1826
1827 cd $CWS
1828 print -u2 " File list from: svn status ... \c"
1829 svn status | $AWK '/^[ACDMR]/ { print $NF }' > $FLIST
1830 print -u2 " Done."
1831 cd $OLDPWD
1832 }
1833
1834 function env_from_flist
1835 {
1836 [[ -r $FLIST ]] || return
1837
2017 #
2018 if [[ -n $parent_webrev && -e $PWS/$PDIR/$PF ]]; then
2019 cp $PWS/$PDIR/$PF $olddir/$PDIR/$PF
2020 elif [[ -n $HG_PARENT ]]; then
2021 hg cat -R $CWS -r $HG_PARENT $CWS/$PDIR/$PF > \
2022 $olddir/$PDIR/$PF 2>/dev/null
2023
2024 if (( $? != 0 )); then
2025 rm -f $olddir/$PDIR/$PF
2026 else
2027 if [[ -n $old_mode ]]; then
2028 chmod $old_mode $olddir/$PDIR/$PF
2029 else
2030 # should never happen
2031 print -u2 "ERROR: set mode of $olddir/$PDIR/$PF"
2032 fi
2033 fi
2034 fi
2035 }
2036
2037 function build_old_new_git
2038 {
2039 typeset olddir="$1"
2040 typeset newdir="$2"
2041 typeset old_mode=
2042 typeset new_mode=
2043 typeset old_object=
2044 typeset new_object=
2045 typeset file
2046 typeset type
2047
2048 #
2049 # Get old file and its mode from the git object tree
2050 #
2051 if [[ "$PDIR" == "." ]]; then
2052 file="$PF"
2053 else
2054 file="$PDIR/$PF"
2055 fi
2056 git ls-tree $GIT_PARENT $file | read old_mode type old_object junk
2057 git cat-file $type $old_object > $olddir/$file 2>/dev/null
2058
2059 if (( $? != 0 )); then
2060 rm -f $olddir/$PDIR/$PF
2061 else
2062 if [[ -n $old_mode ]]; then
2063 chmod $old_mode $olddir/$PDIR/$PF
2064 else
2065 # should never happen
2066 print -u2 "ERROR: set mode of $olddir/$PDIR/$PF"
2067 fi
2068 fi
2069
2070 #
2071 # new version of the file.
2072 #
2073 rm -rf $newdir/$DIR/$F
2074 if [[ -e $CWS/../$DIR/$F ]]; then
2075 cp $CWS/../$DIR/$F $newdir/$DIR/$F
2076 # Temporary new_node = old_mode
2077 new_mode=$old_mode
2078 if [[ -n $new_mode ]]; then
2079 chmod $new_mode $newdir/$DIR/$F
2080 else
2081 # should never happen
2082 print -u2 "ERROR: set mode of $newdir/$DIR/$F"
2083 fi
2084 fi
2085
2086 }
2087
2088 function build_old_new_subversion
2089 {
2090 typeset olddir="$1"
2091 typeset newdir="$2"
2092
2093 # Snag new version of file.
2094 rm -f $newdir/$DIR/$F
2095 [[ -e $CWS/$DIR/$F ]] && cp $CWS/$DIR/$F $newdir/$DIR/$F
2096
2097 if [[ -n $PWS && -e $PWS/$PDIR/$PF ]]; then
2098 cp $PWS/$PDIR/$PF $olddir/$PDIR/$PF
2099 else
2100 # Get the parent's version of the file.
2101 svn status $CWS/$DIR/$F | read stat file
2102 if [[ $stat != "A" ]]; then
2103 svn cat -r BASE $CWS/$DIR/$F > $olddir/$PDIR/$PF
2104 fi
2105 fi
2106 }
2107
2128 function build_old_new
2129 {
2130 typeset WDIR=$1
2131 typeset PWS=$2
2132 typeset PDIR=$3
2133 typeset PF=$4
2134 typeset CWS=$5
2135 typeset DIR=$6
2136 typeset F=$7
2137
2138 typeset olddir="$WDIR/raw_files/old"
2139 typeset newdir="$WDIR/raw_files/new"
2140
2141 mkdir -p $olddir/$PDIR
2142 mkdir -p $newdir/$DIR
2143
2144 if [[ $SCM_MODE == "teamware" ]]; then
2145 build_old_new_teamware "$olddir" "$newdir"
2146 elif [[ $SCM_MODE == "mercurial" ]]; then
2147 build_old_new_mercurial "$olddir" "$newdir"
2148 elif [[ $SCM_MODE == "git" ]]; then
2149 build_old_new_git "$olddir" "$newdir"
2150 elif [[ $SCM_MODE == "subversion" ]]; then
2151 build_old_new_subversion "$olddir" "$newdir"
2152 elif [[ $SCM_MODE == "unknown" ]]; then
2153 build_old_new_unknown "$olddir" "$newdir"
2154 fi
2155
2156 if [[ ! -f $olddir/$PDIR/$PF && ! -f $newdir/$DIR/$F ]]; then
2157 print "*** Error: file not in parent or child"
2158 return 1
2159 fi
2160 return 0
2161 }
2162
2163
2164 #
2165 # Usage message.
2166 #
2167 function usage
2168 {
2169 print 'Usage:\twebrev [common-options]
2196 '
2197
2198 exit 2
2199 }
2200
2201 #
2202 #
2203 # Main program starts here
2204 #
2205 #
2206
2207 trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
2208
2209 set +o noclobber
2210
2211 PATH=$(dirname $(whence $0)):$PATH
2212
2213 [[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
2214 [[ -z $WX ]] && WX=`look_for_prog wx`
2215 [[ -z $HG_ACTIVE ]] && HG_ACTIVE=`look_for_prog hg-active`
2216 [[ -z $GIT_ACTIVE ]] && GIT_ACTIVE=`look_for_prog git-active`
2217 [[ -z $WHICH_SCM ]] && WHICH_SCM=`look_for_prog which_scm`
2218 [[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
2219 [[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
2220 [[ -z $PERL ]] && PERL=`look_for_prog perl`
2221 [[ -z $RSYNC ]] && RSYNC=`look_for_prog rsync`
2222 [[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
2223 [[ -z $AWK ]] && AWK=`look_for_prog nawk`
2224 [[ -z $AWK ]] && AWK=`look_for_prog gawk`
2225 [[ -z $AWK ]] && AWK=`look_for_prog awk`
2226 [[ -z $SCP ]] && SCP=`look_for_prog scp`
2227 [[ -z $SED ]] && SED=`look_for_prog sed`
2228 [[ -z $SFTP ]] && SFTP=`look_for_prog sftp`
2229 [[ -z $MKTEMP ]] && MKTEMP=`look_for_prog mktemp`
2230 [[ -z $GREP ]] && GREP=`look_for_prog grep`
2231 [[ -z $FIND ]] && FIND=`look_for_prog find`
2232
2233 # set name of trash directory for remote webrev deletion
2234 TRASH_DIR=".trash"
2235 [[ -n $WEBREV_TRASH_DIR ]] && TRASH_DIR=$WEBREV_TRASH_DIR
2236
2362 #
2363 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
2364 if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then
2365 print -u2 "$codemgr_ws: no such workspace"
2366 exit 1
2367 fi
2368 [[ -z $codemgr_ws ]] && codemgr_ws=$(workspace name)
2369 codemgr_ws=$(cd $codemgr_ws;print $PWD)
2370 CODEMGR_WS=$codemgr_ws
2371 CWS=$codemgr_ws
2372 elif [[ $SCM_MODE == "mercurial" ]]; then
2373 #
2374 # Mercurial priorities:
2375 # 1. hg root from CODEMGR_WS environment variable
2376 # 2. hg root from directory of invocation
2377 #
2378 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && \
2379 codemgr_ws=$(hg root -R $CODEMGR_WS 2>/dev/null)
2380 [[ -z $codemgr_ws ]] && codemgr_ws=$(hg root 2>/dev/null)
2381 CWS=$codemgr_ws
2382 elif [[ $SCM_MODE == "git" ]]; then
2383 #
2384 # Git priorities:
2385 # 1. git rev-parse --git-dir from CODEMGR_WS environment variable
2386 # 2. git rev-parse --git-dir from directory of invocation
2387 #
2388 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && \
2389 codemgr_ws=$(git --git-dir=$CODEMGR_WS rev-parse --git-dir \
2390 2>/dev/null)
2391 [[ -z $codemgr_ws ]] && \
2392 codemgr_ws=$(git rev-parse --git-dir 2>/dev/null)
2393 CWS=$codemgr_ws
2394 elif [[ $SCM_MODE == "subversion" ]]; then
2395 #
2396 # Subversion priorities:
2397 # 1. CODEMGR_WS from environment
2398 # 2. Relative path from current directory to SVN repository root
2399 #
2400 if [[ -n $CODEMGR_WS && -d $CODEMGR_WS/.svn ]]; then
2401 CWS=$CODEMGR_WS
2402 else
2403 svn info | while read line; do
2404 if [[ $line == "URL: "* ]]; then
2405 url=${line#URL: }
2406 elif [[ $line == "Repository Root: "* ]]; then
2407 repo=${line#Repository Root: }
2408 fi
2409 done
2410
2411 rel=${url#$repo}
2412 CWS=${PWD%$rel}
2413 fi
2459 elif [[ -n $1 ]]; then
2460 if [[ ! -r $1 ]]; then
2461 print -u2 "$1: no such file or not readable"
2462 usage
2463 fi
2464 cat $1 > $FLIST
2465 flist_mode="file"
2466 flist_file=$1
2467 flist_done=1
2468 shift
2469 else
2470 flist_mode="auto"
2471 fi
2472 fi
2473
2474 #
2475 # Before we go on to further consider -l and -w, work out which SCM we think
2476 # is in use.
2477 #
2478 case "$SCM_MODE" in
2479 teamware|mercurial|git|subversion)
2480 ;;
2481 unknown)
2482 if [[ $flist_mode == "auto" ]]; then
2483 print -u2 "Unable to determine SCM in use and file list not specified"
2484 print -u2 "See which_scm(1) for SCM detection information."
2485 exit 1
2486 fi
2487 ;;
2488 *)
2489 if [[ $flist_mode == "auto" ]]; then
2490 print -u2 "Unsupported SCM in use ($SCM_MODE) and file list not specified"
2491 exit 1
2492 fi
2493 ;;
2494 esac
2495
2496 print -u2 " SCM detected: $SCM_MODE"
2497
2498 if [[ -n $lflag ]]; then
2499 #
2603 # If by hook or by crook we've gotten a file list by now (perhaps
2604 # from the command line), eval it to extract environment variables from
2605 # it: This is method 3 for finding the parent.
2606 #
2607 if [[ -z $flist_done ]]; then
2608 flist_from_teamware
2609 fi
2610 env_from_flist
2611
2612 #
2613 # (4) If we still don't have a value for codemgr_parent, get it
2614 # from workspace.
2615 #
2616 [[ -z $codemgr_parent ]] && codemgr_parent=`workspace parent`
2617 if [[ ! -d $codemgr_parent ]]; then
2618 print -u2 "$CODEMGR_PARENT: no such parent workspace"
2619 exit 1
2620 fi
2621
2622 PWS=$codemgr_parent
2623 \
2624
2625 [[ -n $parent_webrev ]] && RWS=$(workspace parent $CWS)
2626
2627 elif [[ $SCM_MODE == "mercurial" ]]; then
2628 #
2629 # Parent can either be specified with -p
2630 # Specified with CODEMGR_PARENT in the environment
2631 # or taken from hg's default path.
2632 #
2633
2634 if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then
2635 codemgr_parent=$CODEMGR_PARENT
2636 fi
2637
2638 if [[ -z $codemgr_parent ]]; then
2639 codemgr_parent=`hg path -R $codemgr_ws default 2>/dev/null`
2640 fi
2641
2642 CWS_REV=`hg parent -R $codemgr_ws --template '{node|short}' 2>/dev/null`
2643 PWS=$codemgr_parent
2686 # At this point we must have a wx flist either from hg-active,
2687 # or in general. Use it to try and find our parent revision,
2688 # if we don't have one.
2689 #
2690 if [[ -z $HG_PARENT ]]; then
2691 eval `$SED -e "s/#.*$//" $wxfile | $GREP HG_PARENT=`
2692 fi
2693
2694 #
2695 # If we still don't have a parent, we must have been given a
2696 # wx-style active list with no HG_PARENT specification, run
2697 # hg-active and pull an HG_PARENT out of it, ignore the rest.
2698 #
2699 if [[ -z $HG_PARENT && -x $HG_ACTIVE ]]; then
2700 $HG_ACTIVE -w $codemgr_ws -p $real_parent | \
2701 eval `$SED -e "s/#.*$//" | $GREP HG_PARENT=`
2702 elif [[ -z $HG_PARENT ]]; then
2703 print -u2 "Error: Cannot discover parent revision"
2704 exit 1
2705 fi
2706 elif [[ $SCM_MODE == "git" ]]; then
2707 #
2708 # Parent can either be specified with -p
2709 # Specified with CODEMGR_PARENT in the environment
2710 # or taken from git config.
2711 #
2712
2713 if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then
2714 codemgr_parent=$CODEMGR_PARENT
2715 fi
2716
2717 if [[ -z $codemgr_parent ]]; then
2718 codemgr_parent=$(git --git-dir=$codemgr_ws config \
2719 remote.origin.url 2>/dev/null)
2720 fi
2721
2722 CWS_REV=$(git --git-dir=$codemgr_ws rev-parse HEAD 2>/dev/null)
2723 PWS=$codemgr_parent
2724
2725 #
2726 # If the parent is a webrev, we want to do some things against
2727 # the natural workspace parent (file list, comments, etc)
2728 #
2729 if [[ -n $parent_webrev ]]; then
2730 real_parent=$(git --git-dir $codemgr_ws config \
2731 remote.origin.url 2>/dev/null)
2732 else
2733 real_parent=$PWS
2734 fi
2735
2736 #
2737 # If git-active exists, then we run it. In the case of no explicit
2738 # flist given, we'll use it for our comments. In the case of an
2739 # explicit flist given we'll try to use it for comments for any
2740 # files mentioned in the flist.
2741 #
2742 if [[ -z $flist_done ]]; then
2743 flist_from_git $CWS $real_parent
2744 flist_done=1
2745 fi
2746
2747 #
2748 # If we have a file list now, pull out any variables set
2749 # therein. We do this now (rather than when we possibly use
2750 # git-active to find comments) to avoid stomping specifications
2751 # in the user-specified flist.
2752 #
2753 if [[ -n $flist_done ]]; then
2754 env_from_flist
2755 fi
2756
2757 #
2758 # Only call git-active if we don't have a wx formatted file already
2759 #
2760 if [[ -x $GIT_ACTIVE && -z $wxfile ]]; then
2761 print " Comments from: git-active -p $real_parent ...\c"
2762 git_active_wxfile $CWS $real_parent
2763 print " Done."
2764 fi
2765
2766 #
2767 # At this point we must have a wx flist either from git-active,
2768 # or in general. Use it to try and find our parent revision,
2769 # if we don't have one.
2770 #
2771 if [[ -z $GIT_PARENT ]]; then
2772 eval `$SED -e "s/#.*$//" $wxfile | $GREP GIT_PARENT=`
2773 fi
2774
2775 #
2776 # If we still don't have a parent, we must have been given a
2777 # wx-style active list with no GIT_PARENT specification, run
2778 # git-active and pull an GIT_PARENT out of it, ignore the rest.
2779 #
2780 if [[ -z $GIT_PARENT && -x $GIT_ACTIVE ]]; then
2781 $GIT_ACTIVE -w $codemgr_ws -p $real_parent | \
2782 eval `$SED -e "s/#.*$//" | $GREP GIT_PARENT=`
2783 elif [[ -z $GIT_PARENT ]]; then
2784 print -u2 "Error: Cannot discover parent revision"
2785 exit 1
2786 fi
2787 WDIR=${WDIR:-$CWS/../webrev}
2788 elif [[ $SCM_MODE == "subversion" ]]; then
2789
2790 #
2791 # We only will have a real parent workspace in the case one
2792 # was specified (be it an older webrev, or another checkout).
2793 #
2794 [[ -n $codemgr_parent ]] && PWS=$codemgr_parent
2795
2796 if [[ -z $flist_done && $flist_mode == "auto" ]]; then
2797 flist_from_subversion $CWS $OLDPWD
2798 fi
2799 else
2800 if [[ $SCM_MODE == "unknown" ]]; then
2801 print -u2 " Unknown type of SCM in use"
2802 else
2803 print -u2 " Unsupported SCM in use: $SCM_MODE"
2804 fi
2805
2806 env_from_flist
2807
|