[p4] Shelf script.

Jeff Grills jgrills at drivensnow.org
Tue May 15 12:20:40 PDT 2007


p4tar only stores the information about a changelist (or all changelists, if
none was specified on the command line), including the revision of the files
that were opened for edit.  It makes no attempt to track the rest of the
client.  If you need to be able to track the full client state for
reproducibility for some reason (like doing code reviews), you can't really
rely on the state of the client staying the same.  You could do something
where you grab the results of "p4 changes -m 1 //...#have" and then store
that number as well.  To be really safe, you might want to scan the client
for files that are not sync'ed with respect to that changelist and store
that list off separately to individually sync those files.  That's basically
just a way to compress the output of "p4 files //...#have" for the client,
though.  That's still worthwhile IMO because the last time I sync'ed
thousands of files to specific revisions from the command line (even using
p4 -x file) it took much longer than I would have expected.  From what you
said at first, though, I don't think you want to do any of this.

If you just want to archive off your changes so that you can revert them,
work on another fix, and then restore your shelved work and continue with
it, p4tar probably does exactly what you need.  You probably will end up
with some newer files on your client after restoring, in particular those
files you changed for the other fix, but that's probably what you want
anyway since you want to be sync'ed to head at some point to test your
changes against the current state of the depot before you submit your
changed files anyway.  With the way p4tar works, if any of the files that
you had open in the shelved work had changed since you did the change, the
script would sync those files back to the revision you had at the time, open
them for edit, and then replace their contents with your modified copy.
You'll still have to resolve the new changes to those files before
submitting, but that's really what you want anyway so you can use the
standard perforce tools to deal with the merge.  I don't think you want to
go down the road of extracting the diffs and reapplying them yourself -
leverage perforce to do heavy lifting like that.

j

-----Original Message-----
From: jim.tilander at gmail.com [mailto:jim.tilander at gmail.com] On Behalf Of
Jim Tilander
Sent: Monday, May 14, 2007 5:37 PM
To: Jeff Grills
Cc: perforce-user at perforce.com
Subject: Re: [p4] Shelf script.


Ah, yes I've seen these scripts some while ago. I'm a bit constrained that I
can't require everybody to install perl though. Python is already out there
as a requirement so that would be fine. It looks like the simplest way would
just be to write a shelf.py script again, probably starting with ideas from
p4tar. The thing that I'd really would have liked was a command that could
give a diff from a changelist and the have command. I guess I can combine
the output from Steve's suggestion "p4 change -m 1" and "p4 have" and to
store that as a delta from the changelist. I would guess that it's way
faster to sync to a single changelist and then the deltas instead of syncing
*every* file in your clientspec to a specific version...

/j

On 5/14/07, Jeff Grills <jgrills at drivensnow.org> wrote:
> I have some scripts which can do this, located in the public perforce 
> depot (public.perforce.com).  They're in //guest/jeff_grills/p4tar/... 
> if you'd like to check them out.  They are perl scripts and currently 
> require a unix-ish environment, but in windows you can use cygwin.  
> They're also relatively hackable if you'd like to make them fit your 
> current environment. I do have some plans to make these scripts less 
> dependent on things other than perl, but I just haven't had the time 
> to do so yet.
>
> j
>
> -----Original Message-----
> From: perforce-user-bounces at perforce.com
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of Jim Tilander
> Sent: Saturday, May 12, 2007 4:42 PM
> To: perforce-user at perforce.com
> Subject: [p4] Shelf script.
>
>
> Some revision systems have a nifty feature to "shelf" work, i.e. store 
> the entire state of the client and save it off somewhere to allow you 
> to restore to that point again after doing various operations. This 
> comes especially in handy when you only have one clientspec and you 
> are working on one thing, but you need to interrupt your work and fix 
> some emergency bug.
>
> Does anyone know of any existing scripts that does this? I was 
> thinking of writing one of my own, but I lack one thing, I would like 
> to query the server for my client's state, i.e the revisions of the 
> files locally that I have. Preferably this list would be a changelist 
> number + any diffs I might have (e.g. synced individually to any 
> special revisions).
>
> Cheers,
> Jim Tilander
>
> --
> Beware of architect astronauts. 
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com 
> http://maillist.perforce.com/mailman/listinfo/perforce-user
>
>


-- 
Beware of architect astronauts.



More information about the perforce-user mailing list