I have a directory outside the repository. I put generated sources in there. These generated sources take FOREVER to create. Rather than have everyone on the team generate these sources, I would like to use our build machine to generate the sources, and check them in to perforce. How do I do this and ensure that the source controlled directory only has only the most recent files and not any that were generated previously but not in the most recent build?
I was thinking of doing a p4 edit on all the files in the generated directory (for existing files), then doing a p4 add using wildcards to get any files that are new, but I do not know how to handle files that were previously generated, but not generated in the most recent build (should be deleted).
Start as you suggested - p4 edit and p4 add to capture all changes, then call
p4 revert -a
Which will revert any file in the depot that is open for edit but is actually unchanged or missing.
I found this on the perforce blog and it is exactly what I was looking for. Automating folder replacement using P4Java and Apache Ant
One idea is to, before the build, removing everything in this area manually (not through Perforce, but through the OS). After doing the build, do a "Reconcile Offline Work". This will reconcile in Perforce what you have in this area by adding new files, deleting ones that are not there anymore, and editing those that have changed.
You can reconcile offline work through P4V, as seen here. In your workspace browser, right-click the folder and choose "Reconcile Offline Work".
Or, you can do it through the command line if you prefer a more automated solution, as seen here. (Note: this link also talks about reconciling through p4v, but this is superseded by the previous link)
p4 diff -se //myclient/... | p4 -x - edit
to checkout changed files.
p4 diff -sd //myclient/... | p4 -x - delete
to delete files.
find . -type f -print | p4 -x - add
find . -type l -print | p4 -x - add
to add files and symlinks in Unix, or
dir /s /b /a-d | p4 -x - add
to add files in Windows.
For Binary files in Perforce you can set a FileType flag that only stores 1 (or a set number ) of revisions for the file in the repository. This way you will have history of the file but your other users will only have access to the binary for the latest version of the file and also your server will only store one copy which is much more storage efficient if you dont need to store multiple copies.
To make the change.
Add the files you are interested in to the repository.
Check out the file.
Right click in P4V and select Change Filetype
On the dialog pops up select +S "Server limits the number of revisions stored" at the bottom of the screen, which will restrict the number of files stored.
Hope this helps.
Related
I need to copy files with Certain label from perforce and put it on some "Non workspace" folder lets say c:\Temp
When i do p4 sync #LABEL labelled files get copied to workspace but i want to pick up those files and dump it somewhere else.
I tried exploring few different options like p4 copy but i dont think they will serve the purpose.
Prob i can Delete all the files in workspace and then do
p4 sync #LABEL and that will give me exactly those files that are labelled but i think there could be better solution ...
Thanks
I'm guessing you're using Windows. If you do this regularly, I'd recommend creating a simplce .bat file to do this process for you. The script below would clean out the workspace, sync only the files in the label, then copy them to your C:\Temp directory. If the label would be changing, you might consider doing something similar as a Custom Tool.
p4 sync //...#0
p4 sync //...#mytestlabel,#mytestlabel
set TARGET=C:\Temp\MyFiles
copy C:\MyFiles %TARGET%
In Perforce, how can I create a patch file which has the changes that are in the file as currently saved, compared to the have revision? Instructions for either the GUI client or the CLI client would be great.
I can see how to get the diffs between two changelists, but not how to just get the difference between the last changelist and the current state of the files. Additionally, I can see that in the GUI client, I can right-click on a file and select "Diff Against Have Revision" from the contextual menu, which shows me what I'm looking for, but I can't figure out how to get that into a file.
I'm basically looking for the equivalent of what git diff <file> > patch.diff does in Git-land.
I think that p4 diff -du FILE > patch.diff should do what you want.
Single file
p4 diff -du file > file.patch.diff
Every file
p4 diff -du > patch.diff
The problem with p4 diff is that it doesn't take into account of new files. Also you can't get files that are only in a certain pending change list.
If there is a pending changelist, you can actually use an open source perforce patcher tool, which I have created for my project needs. You can directly download from this link of github.
In case you want to checkout the source, go to the github repo.
Documentation for the tool can be found here.
I'm currently using Perforce with P4V (Rev. Perforce Visual Client/MACOSX105X86_64/2012.1/490402) in Unity 3.5.5,
When you revert files marked for add, it only removes it from the changelist. Sometimes files are auto generated or I created some files that I don't want to add anymore and I want to remove them from the changelist and delete the local copy of it.
This also occurs when shelving files marked for add. I'm currently manually reverting and deleting each file. Is there a way to easily delete the local copies?
We haven't implemented it in P4V yet, but if you are on at least a 2013.2 server, you can use 'p4 revert -w' to do this in one step. If you follow the advice of the custom tool route, the command is super simple since it's a one-step process. You can just have the application be p4.exe (or p4 binary if you're on Linux or Mac) and the arguments are 'revert -w %F'.
There may not be an ability built into p4v, but you can call your own script from p4v, in which the script calls a revert and delete on the file.
Go to Tools->Manage Custom Tools..., and select New->Tool.
You'll get a dialog as seen below.
You would put your user script in the Application. For the Arguments, you can click the Select... button to choose the different variables. Here, %F refers to the file you right-clicked on (can be multiple).
I haven't actually written an entire script to test this, but I verified that you can at least right-click a file and this script is available (provided you check Add to applicable context menus).
You can do this from the "Reconcile offline work" tool.
Right-click on the pending-add, "Delete local file":
(p4v 2015 February 18 1007540)
This is a little dangerous, as you'll need to ensure you don't have anything on your client that you want to keep that isn't also in the P4 repository. Once you verify that you want to delete all non-p4-versioned files...
Right-click the containing directory or depot, and choose "reconcile offline work".
This opens a dialog box. You'll see a section called "Local files not in depot", which are the files that were presumably auto-generated that you want to delete.
Select all the files in "Local files not in depot" (ctrl+A), right-click on them, and choose "Delete Local File".
Answer yes, you're sure you want to delete the file(s).
This should remove any files from your p4 client (under the directory you choose) that aren't under p4 version control.
On the project I'm currently working on, we have lots of folders in the /branches and /tags folders (left after the migration from Subversion to Perforce).
I want to clean up the mess - I want to move/copy/rename folders remotely, directly on the depot, without getting them locally. I can't get them locally because we're talking about hundreds of GB and probably millions of files - dozens of branches x ~5GB.
Is it possible to order Perforce to move the folders just on the server?
(I do not have direct access to the Perforce machine, I cannot move folders around on the server or update the Perforce database).
p4 copy -v allows you to copy files in the depot without syncing those files to your workspace. (See the copy reference for more details.)
p4 delete -v allows you to delete files in the depot that are not synced to your workspace. (See the delete reference or KB Article #1148 for more details.)
Also p4 move -k allows you to move files in the depot without moving them locally, but I'm not sure if that applies if you don't have them synced to your workspace. (See the move reference for more details.)
You can also accomplish a move with a copy followed by a delete.
I think that you can construct a workspace that maps all the files in question. You can run sync -k to make Perforce think you have the files locally. Then you can run move -k to move the files on the server.
Just FYI, p4 copy creates a new branch, whereas p4 move moves an existing branch to a new location.
I am looking for a perforce command to get the list of the files that have been modified locally and "not" checked-in to the repository.
I understand that I "should" get the list of modified files in Pending changelist, but there are scenarios when I don't get to see a modified file in that list. And then on "manually" checking out a file and doing a diff i realize the difference.
Is there any command that could check all the files in a given folder and provide me a list of files that are not same as there state in the repository?
I tried "p4 sync", but that did not work.
Thanks for your interest.
Try
p4 diff -f -sa
(see manual for further details)
I use "p4 revert -n ./..."
where
-n
List the files that would be reverted without actually performing the revert.
This lets you make sure the revert does what you think it does before actually reverting the files.
In the recent versions of Perforce, try "p4 reconcile -e"
see: http://www.perforce.com/perforce/r12.1/manuals/cmdref/reconcile.html
It certainly takes its time though (not very fast).
I think, the modified files are submitted locallay (Otherwise, p4 opened ./... will help to find)
If files are already submitted to local perforce and still want to know which all are modified..
p4 changes -m 5 ./... (Should give changes lists)
p4 integrate -n ./... //server/code/base/... (This should list the files to be integrated to mainline.