[p4] determining the status of a clientspec

Todd Short tshort at cisco.com
Tue Oct 9 10:25:40 PDT 2001


We use the following shell script to set a variable to the latest changelist
a user synced to when they build (so the version number has the changelist
number in it). It is not entirely accurate. If you sync to change 2000, and
then make a submit as change 2005. It will appear as though you are synced
to 2005.

lastchange.sh:
#! /bin/sh
err=`p4 info 2>nul | wc -l`
if [ $err -eq 0 ]; then
  echo "0"
  exit
fi
# otherwise, get the value
P4CLIENT=`p4 set P4CLIENT\
    | gawk 'BEGIN { client = 0 }\
            \$1 ~ /P4CLIENT/ && client == 0 {\
              n = split(\$1, clientarray, "=");\
              client = clientarray[2]; gsub("\r","",client) }\
            END { print client }'`
if [ -z $P4CLIENT -o "$P4CLIENT" == "0" ]; then
    echo "0"
    exit
fi
p4 changes -m 1 @$P4CLIENT | gawk '{print $2}'

Usage example:

export TestVersion=`lastchange.sh`

This could be updated to give a particular path in the 'p4 changes' line.
--
-Todd Short
// tshort at cisco.com
// "One if by land, two if by sea, three if by the Internet."


> -----Original Message-----
> From: perforce-user-admin at perforce.com
> [mailto:perforce-user-admin at perforce.com]On Behalf Of Marc Unangst
> Sent: Tuesday, October 09, 2001 1:02 PM
> To: perforce-user at perforce.com
> Subject: [p4] determining the status of a clientspec
> 
> 
> Perhaps a simple question, but...Is there any way to determine what 
> changelist a client is sync'd to?  I know that you can use 
> "p4 have" to 
> see what version of a particular file your client has, but I'm 
> interested in something more comprehensive.  I suppose it might not 
> always be possible to generate this, if the user has been 
> creative about 
> syncing various subsets of their workspace, but it seems like 
> it should 
> be possible to generate largest-subset information (i.e., 
> this subdir is 
> sync'd to change #1234, this subdir to change #1245, etc.).
> 
>     -Marc
> 
> 
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
> 



More information about the perforce-user mailing list