Get only one folder from a stream depot in Perforce - perforce

I am new to Perforce "stream depots" and stuck at step 1. I am trying to create a workspace that includes only one folder from a huge stream depot.
Every time I try, it seems to want to download the entire stream, which is a huge amount of files. I can see now way to limit it to just one folder.

This is what virtual streams are for.
Create a new stream that is a child of the stream in question, with type "virtual", and specify its Paths as the single folder, e.g.:
Stream: //streams/just_the_facts
Parent: //streams/main
Type: virtual
Paths:
share path/to/the/facts/...
Now switch to that stream:
p4 switch just_the_facts
and you only have the files from the facts folder.

What I ended up doing was:
p4 set P4CLIENT=MyWorkspace then
p4 client -s -S //My/Stream to create the workspace.
Then p4 sync //My/Stream/just/the/dir/I/want...

Related

Perforce Skip File Download Based on Extension [duplicate]

I am using the command line tools of Perforce.
And with the p4 tool, I want to sync to a stream.
The problem is that I want to exclude a directory from my workspace.
If my work space was defined as a view, this would be possible with something like:
View:
//depot/Foo/... //Client/Foo/...
-//depot/Foo...bin/... //Client/Foo...bin/...
But the Stream: setting overrides the View: specification.
I have set the Stream using the command:
$ p4 client
I also looked into P4IGNORE mechanism, but this is of no use to my problem, as P4IGNORE will not influence the sync command.
I tried adding a Paths: command to my client spec, but that is not recognized in this context. I think it is used when specifying the stream, as done by the administrator of the depot?
This is exactly what virtual streams are for. :) Create a child of the stream with type virtual, and exclude the directory from the virtual child stream (via either Paths or Ignore in the stream spec). This will generate you a client view that is the desired subset of the parent stream.
https://www.perforce.com/blog/virtual-streams-windows-big-projects

Removing child streams to delete Perforce stream depot

I have the following situation:
We created a stream depot and started using it. After that it was figured out that we want a different name for the stream depot, so we just created a new correctly named one and copied everything from the old depot. it's already in use for quite some time.
Now we want to get a rid of the old wrongly named stream depot.
I obliterated contents of the depot via Perforce Helix Admin client (GUI) then tried to Delete Depot and it replied with
Depot 'depotname' is the location of existing streams; cannot delete until they are removed.
So, I moved to P4 CLI to list and remove existing streams:
[root#linuxbox]# p4 streams //depotname/...
Stream //depotname/main mainline none 'main'
Stream //depotname/main.dev virtual //depotname/main 'main.dev'
[root#linuxbox]# p4 stream -df //depotname/main
Stream '//depotname/main' has child streams; cannot delete until they are removed.
So, the question is how can I delete those child streams from the stream depot? (what should I use instead of p4 stream -df //depotname/main)?
Will I be able to just delete the depot after that?
And wouldn't it impact other depots on the same p4d server?
See the answer here: https://stackoverflow.com/a/57892035/3799759
You need to delete all of the streams in the depot, not just the mainline stream. The steps described in that answer should do the job.
For your specific case, you could do it manually with:
p4 stream -d //depot/main.dev
p4 stream -d //depot/main
p4 depot -d depot
but only if you've already deleted all the clients of those streams (again, see the other answer, which covers that too).

Merging between streams in Perforce using Command line rather than P4V

I need to merge the streams using commands in P4. can anyone help me with this? the two streams are parent child streams. I need to merge down from parent to child.
I'm typing this from memory, without actually trying it, but I think this is pretty close:
Switch your client workspace to the child stream, since that is the target of the merge: p4 client -s -S child
Sync your client, to make sure you're building and testing with the latest files: p4 sync
Merge the parent stream's changes into your child stream: p4 merge
Resolve any conflicts: p4 resolve
Build and test, to confirm that you're happy with the results
Submit the merged code to the child stream: p4 submit
Of course, make sure that you're working with the correct client workspace, as the correct user, etc., by running p4 set before you start this process, to look at your P4CLIENT, P4USER, etc. settings.

In perforce how to check if any changes were made in the entire folder, and run a post processing script only if changes were made?

I am planning to create a cron job that does a p4 sync on a specific folder every day at a certain time and does some post processing of the files in the folder.
However, before doing the post processing I would like to check if the files in the folder differ from that of the perforce repository, and only if there are changes, I'd go ahead with the post processing.
How do I integrate a p4 diff with my csh script and if there's any other elegant way to check for differences and trigger the post processing.
In summary, I'm trying to achieve this:
if (check for differences in <my directory>) then
{ run my post-processing script }
else
{ dont run}
If you want to see if any new revisions have been added to the depot since your sync completed, you could run:
p4 have
in your workspace, and compare this to the output from:
p4 files
run against the corresponding depot files and/or directories.
Example:
jen#Jen: ~/workspaces/testing/depot/depot/testingjen#Jen:~/workspaces/testing/depot/depot/testing$ p4 have //depot/testing/...
//depot/testing/test#1 - /home/jen/workspaces/testing/depot/depot/testing/test
jen#Jen: ~/workspaces/testing/depot/depot/testingjen#Jen:~/workspaces/testing/depot/depot/testing$ p4 files //depot/testing/...
//depot/testing/test#2 - edit change 7445 (text)
Hope this helps,
Jen.

Uploading delta changes to perforce and label

Every month I need to sync big chunk of files from git and upload it to perforce and create a p4 label with all files uploaded, and from p4 I do builds, this is odd but we cannot change this now. so far I am uploading the files to new directory in p4 every time and creating label with all uploaded files, so I get a clean label for "this month's build" though most of the files didn't change compared to last month's upload, this happens through shell script, is there a way to upload only the delta changes and create label with old files (not uploaded as it didn't change) + changed/brand new files uploaded? any high level directions will help, thanks.
Do I understand correctly that "I am uploading the files to new directory in p4 every time" means that, each time you perform a 'p4 submit', the files in your changelist are actually different file names, not just newer revisions of the same files?
That is, if you did 'p4 describe' of the first changelist you submitted, would it look like:
//depot/dir/r1/A.c#1
//depot/dir/r1/B.c#1
//depot/dir/r1/C.c#1
while the next time you ran your tool, and did a 'p4 describe' of the changelist, it would look like:
//depot/dir/r2/A.c#1
//depot/dir/r2/B.c#1
//depot/dir/r2/C.c#1
If that is what you are doing, then if you could instead copy the files to the same location each time, so that the first time your tool ran you got:
//depot/dir/A.c#1
//depot/dir/B.c#1
//depot/dir/C.c#1
and the second time your tool ran you got:
//depot/dir/A.c#2
//depot/dir/B.c#2
//depot/dir/C.c#2
If you did things that way, then you could use the 'revertunchanged' feature of Perforce, and the files that were unchanged from the previous run of your tool would not be submitted, and the revision number would not change, so that over time you might get:
//depot/dir/A.c#7
//depot/dir/B.c#4
//depot/dir/C.c#19
Each time you run your tool, you can still create a label, because the label includes not just the file name but also the revision number, so the first label you created might include:
//depot/dir/A.c#1
//depot/dir/B.c#1
//depot/dir/C.c#1
while the 19th label you created might include:
//depot/dir/A.c#7
//depot/dir/B.c#4
//depot/dir/C.c#19
Hopefully this will get you pointed in a direction that is more suited to your goals.

Resources