开发者

Use perforce to capture current state of external directory

开发者 https://www.devze.com 2023-01-14 05:46 出处:网络
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

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.

  1. Add the files you are interested in to the repository.
  2. Check out the file.
  3. Right click in P4V and select Change Filetype
  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消