views:

81

answers:

5

When creating partial builds for a project, I usually diff the project folder latest revision against a production label. Then I have to manually add all the changed/added files to a temporary folder before copying it to production.

Is there a way to automate this?

For example, if we need to update a client website, we only want to send the files that have changed. Currently, to determine the difference between their current production website and what we have in source control, we diff against two different labels on the website folder. Then we create a build with only the files that have changed.

A: 

I'm not sure if I understand correctly what you are trying to do, but diffing folder and then manually adding changed/added files sure sounds like integrating (or merging, in other versioning systems' slang).

p4 help integrate on the command line will help as well as (maybe) this Perforce KB article.

jhwist
Added more details to the question, hopefully that explains the goal better.
Kevin
A: 

Use one of the scripting APIs available for download to automate the process.

Which one you pick is largely a matter of personal taste, but if you're not especially familiar with any of the supported languages already I'd suggest the Ruby API.

Cwan
A: 

You use the term "create a build". It sounds like that means "create a file with the things that have changed in Perforce so that we can update somewhere else".

Assuming that, you want to have a Perforce client that contains the files you want to have in production, and then use a tool like rsync to move them to the webserver. Your script basically contains "p4 sync && rsync here there". Rsync will go through the process of figuring out what is different and moving the changes.

If that isn't the case, you need to be more precise about what you mean.

janm
I ended up creating a script which does "p4 sync //depot/folder...@labelv1" and then "p4 sync //depot/folder...@labelv2" then parsing the list of changed files and dumping them in a new folder. Thanks for pointing me in the right direction.
Kevin
A: 

If you store build products in depot, then I guess you should do the following (from beautiful book "Practical Perforce"):

Find the files that were changed and open them for editing:

p4 diff -se | p4 -x- edit

Find the files that were removed and open them for deleting:

p4 diff -sd | p4 -x- delete

Find the files that are new and open them for adding. Assuming that you're in the top-level directory of your workspace:

find . -type f | p4 -x- add -f

Having done this, you can either submit your pending changelist or continue working on your opened files.

Please ping me if you need additional explanations.

Alexander Poluektov
+1  A: 

@Kevin

You can probably skip the parsing of "p4 sync //depot/folder...@labelv2" by doing the following (*nix version):

p4 sync //depot/folder...@labelv1

# delete all files on client - but don't tell perforce about it
rm -r <root of your client> 

p4 sync //depot/folder...@labelv2

Now the client should only have the files that changed between labelv1 and labelv2. You can just copy all files from the client to your deployment location. The command below gives you a list of files:

find <root of your client> -type f
rahul