# # # patch "contrib/mtbrowse.sh" # from [4b996371e141ebf9db6ce6a317fdd3ecd573039a] # to [69fc9d37bb390e3d75ea66b07ff06386644fc054] # ============================================================ --- contrib/mtbrowse.sh 4b996371e141ebf9db6ce6a317fdd3ecd573039a +++ contrib/mtbrowse.sh 69fc9d37bb390e3d75ea66b07ff06386644fc054 @@ -115,12 +115,17 @@ # 2006-01-17 Version 0.1.14 address@hidden # One call for getting monotone version. # Warn before using "automate ancestor" on big database. -# (commit/sync with mt 0.26pre1) +# +# 2006-01-21 Version 0.1.15 address@hidden +# Fix: Author colors >8 wrong handled. +# Faster brief selection menu, without changelog (do_log_brief_ancestors). +# Skip merges from more as one person in brief selection. +# Remove forbitten chars from changelog with tr. added backslash. # Known Bugs / ToDo-List: # * better make "sed -n -e '1p'" for merge two different branches. -VERSION="0.1.14" +VERSION="0.1.15" # Save users settings # Default values, can overwrite on .mtbrowserc @@ -167,7 +172,7 @@ FORMAT_COLOR="\\Z7\\Zb" # How get automate ancestors: I=interal function, A=automate ancestors, -# L=Log brief +# L=log brief with changelog, B=brief log ANCESTORS="L" # read saved settings @@ -293,7 +298,7 @@ { local in_file=$1 local out_file=$2 - local short_hash dat bra aut log lineno color count tfc + local hash short_hash dat bra aut log lineno color tfc line_count=`wc -l < $in_file` if [ "$line_count" -eq 0 ] @@ -319,8 +324,8 @@ short_hash=`echo $hash | cut -c 1-$HASH_TRIM` - # get certs of revision, cache it - monotone --db=$DB list certs $hash > $tfc + # get certs of revision, remove special chars, cache it + monotone --db=$DB list certs $hash | tr '\\\t\042' '/ \047' > $tfc # Date format case $FORMAT_DATE in @@ -381,15 +386,15 @@ # Changelog format case $FORMAT_LOG in - F) # full TAB here ----v - log=`sed -n -r -e "y/\" /' /" -e \ + F) # full + log=`sed -n -r -e \ '/^Name : changelog/,+1s/Value : (.+)$/ \1/p' \ - < $tfc` + < $tfc | sed -n -e '1p'` ;; S) # short - log=`sed -n -r -e "y/\" /' /" -e \ + log=`sed -n -r -e \ '/^Name : changelog/,+1s/Value : (.{1,20}).*$/ \1/p' \ - < $tfc` + < $tfc | sed -n -e '1p'` ;; esac @@ -415,7 +420,8 @@ then color="\\Zb\\Z$color" else - color="\\Z$color" + color8=$(( $color - 8 )) + color="\\Z$color8" fi else color="$FORMAT_COLOR" @@ -431,7 +437,118 @@ rm $tfc } +do_log_brief_ancestors() +{ + local out_file=$1 + local hash short_hash dat bra aut lineno color + # Brief output + # e51dc90425c6371a176e87df294b47fcdba3f0bb Full Name 2005-11-20T20:31:34 mtbrowse + + lineno=0 + monotone log --brief --last=$CERTS_MAX --revision=$HEAD --db=$DB |\ + while read line + do + let lineno++ + # TODO: Why MT give more than "--last"? + if [ $lineno -le $CERTS_MAX ] + then + echo "$(( 100*lineno/CERTS_MAX ))" + fi + + set -- `echo "$line" | sed -n -r -e 's/^([^ ]+) (.+) ([0-9\-]{10})T([0-9:]{8}) (.+)$/\1 \3 \4 \5/p'` + author=`echo "$line" | sed -n -r -e 's/^([^ ]+) (.+) ([0-9\-]{10})T([0-9:]{8}) (.+)$/\2/p'` + hash=$1 + date=$2 + time=$3 + branch="$4" + + # Skip wrong formats, special case + # 37416b924fc25a48bba11ed8b2cd62e9dab7e637 First Name ,address@hidden,address@hidden 2006-01-20T08:21:37,2006-01-20T08:35:46,2006-01-20T08:35:33 net.venge.monotone + + if [ -n "$hash" -a -n "$date" -a -n "$time" -a -n "$author" ] + then + + short_hash=`echo $hash | cut -c 1-$HASH_TRIM` + + # Date format + case $FORMAT_DATE in + F) # 2005-12-31T23:59:59 + dat="${date}T$time " + ;; + L) # 2005-12-31 23:59 + dat="`echo "$date $time" | cut -c 1-16` " + ;; + D) # 2005-12-31 + dat=$date + ;; + S) # 12-31 23:59 + dat=`echo "$date $time" | sed -n -r -e \ + '.{4}-(.+) (.{5}).+/\1 \2 /p'` + ;; + T) # 23:59:59 + dat=$time + ;; + esac + + # Branch format + case $FORMAT_BRANCH in + F) # full + bra=$branch + ;; + S) # short + bra=`echo "$branch" | sed -n -r -e \ + '/.*\.([^\.]+)$/\1 /p' ` + ;; + esac + + # Author format + case $FORMAT_AUTHOR in + F) # full + aut="$author" + ;; + S) # short + aut=`echo "$author " | sed -n -r -e \ + 's/(.{1,10}).*[@ ].+$/\1/p'` + ;; + esac + + # TODO: Copied from fill_date_key + # Author coloring? + if [ -n "$FORMAT_COLOR" -a "$FORMAT_AUTHOR" != "N" ] + then + if [ "$last_aut" != "$aut" ] + then + # Automatic color by author? + if [ "$FORMAT_COLOR" = "A" ] + then + color=`grep -n "$aut" $TEMPFILE.ncolor | cut -d ':' -f 1` + if [ -z "$color" ] + then + color=$(( `wc -l < $TEMPFILE.ncolor` % 16 + 1 )) + echo "$aut" >> $TEMPFILE.ncolor + fi + + if [ $color -le 8 ] + then + color="\\Zb\\Z$color" + else + color8=$(( $color - 8 )) + color="\\Z$color8" + fi + else + color="$FORMAT_COLOR" + fi + last_aut="$aut" + fi + echo "$short_hash \"$dat$bra\\ZR$color$aut\"" >> $out_file + else + echo "$short_hash \"$dat$bra\\ZR$aut\"" >> $out_file + fi + fi + done | dialog --gauge "$CERTS_MAX certs reading" 6 60 +} + # Select a branch # Is parameter given: No user select, if branch known. do_branch_sel() @@ -718,6 +835,10 @@ echo "Reading ancestors ($HEAD)" case $ANCESTORS in + B) # TODO: + # Get ancestors from log, brief format + do_log_brief_ancestors $TEMPFILE.certs3tmp + ;; L) # Get ancestors from log monotone log --brief --last=$CERTS_MAX --revision=$HEAD \ @@ -738,9 +859,11 @@ ;; esac - # Must toposort, if enabled by user, or before tailing - if [ "$TOPOSORT" = "T" -o "$CERTS_MAX" -gt 0 -a "$ANCESTORS" != 'L' ] + if [ "$ANCESTORS" != 'B' ] then + # Must toposort, if enabled by user, or before tailing + if [ "$TOPOSORT" = "T" -o "$CERTS_MAX" -gt 0 -a "$ANCESTORS" != 'L' ] + then echo "Toposort..." monotone --db=$DB automate toposort `cat $TEMPFILE.ancestors` \ > $TEMPFILE.toposort || exit 200 @@ -752,12 +875,13 @@ > $TEMPFILE.toposort2 mv $TEMPFILE.toposort2 $TEMPFILE.toposort fi - else + else mv $TEMPFILE.ancestors $TEMPFILE.toposort - fi + fi - # Reading revisions and fill with date, names and changelog - fill_date_key $TEMPFILE.toposort $TEMPFILE.certs3tmp + # Reading revisions and fill with date, names and changelog + fill_date_key $TEMPFILE.toposort $TEMPFILE.certs3tmp + fi case $TOPOSORT in D) @@ -982,7 +1106,8 @@ # How to get ancestors if dialog --default-item "$ANCESTORS" \ --menu "Get ancestors by using" 0 0 0 \ - "L" "Monotone \"log --brief\" (fastest)" \ + "B" "Brief log, without changelog (fastest)" \ + "L" "Monotone \"log --brief\" with changelog" \ "I" "Internal function with depth limit (faster)" \ "A" "Monotone \"automate ancestor\" (save mode, very slow)" \ 2> $TEMPFILE.input @@ -994,8 +1119,9 @@ # functions don't work with big database dialog --title " Info " --msgbox \ "\"automate ancestor\": + Big database can overflow command line. -It's save to use internal function (I)." 0 0 +It's saver to use internal function (I)." 0 0 fi fi ;; @@ -1053,7 +1179,8 @@ # functions don't work without limit dialog --title " Info " --msgbox \ "Certs limit in Select-List: -negative or zero limit not allowed + +Negative or zero limit not allowed Automatic corrected" 0 0 CERTS_MAX=20 fi