#!/bin/sh
# Print clients in descending order of client map complexity.
#
# Since "p4 where //..." lists the combinations resulting from expanding the
# client map, the number of lines in the "p4 where //..." output can be used
# as a measure of the client's complexity.
#
# Locked clients are problematic; this script ignores locked clients. Clients
# with bad mappings (e.g. mapping to nonexistent depots) are also ignored.
awk=awk
egrep=egrep
p4=p4
printf=printf
sh=sh
sort=sort
wc=wc
# Print the clients.
$p4 -Ztag clients | $egrep '^\.\.\. client |^\.\.\. Host ' | $awk '{ client = $3; getline; printf "'"$printf"' \"%%-64s \" \"%s\"; '"$p4"' -c \"%s\" -H \"%s\" where //... | '"$wc"' -l\n", client, client, $3 }' | $sh 2>&1 | $egrep -v ' Locked client |^[ ]*0$| - file\(s\) not in client view\.$' | $sort -k 2nr -k 1