[p4] determining the status of a clientspec

Jeff A. Bowles jab at piccoloeng.com
Tue Oct 9 10:37:27 PDT 2001


At 01:01 PM 10/9/2001 -0400, Marc Unangst wrote:
>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.).

This is a two-part answer.

"p4 files   //depot/main/src/..."  tells you about the list of files
under a directory, telling you about the top-level (most current)
revision since you didn't specify anything else.

"p4 files  //depot/main/src/... at garfield" tells you about the
list of files under that directory AS THEY WERE GIVEN TO
CLIENT NAME "garfield".  So it'll actually give you, one line
of output per file on "garfield", the filename and revision of
what was given to "garfield". (That's a client workspace name,
not the name of the cat who created it.)   Note the similarity
to "p4 have" when it's run from client workspace "garfield".

That doesn't entirely answer your question, but it tells us that
we can use the client workspace name to restrict which revisions
we're interested in looking at. Let's remember that for the next
part.

"p4 changes  //depot/main/src/..."  tells us about all changelists
that affected files under //depot/main/src/, and
"p4 changes -m1 will restrict the output so that it's only the
most recent one ('-m1') changelist.

So, "p4 changes -m1  //depot/main/src/... at garfield" will tell
us about the most recent changelist GIVEN to client workspace
"garfield".

For the person writing the automated script or needing to be
as precise as possible: you'll notice that many examples on
the Perforce mailing list augment this slightly. Here's a finished
version:
         p4 changes -m1 -s submitted //depot/main/src/... at garfield
(the '-s submitted' acknowledges that there might be pending
changeslists in play that we don't care about. For this particular
example, I don't believe it would be necessary, but the '-s' flag
can be really important if you're trying to script for more general
cases.)

Hope this helps.

         -Jeff Bowles
         Perforce Consulting Partner and Certified Trainer




More information about the perforce-user mailing list