Merging between streams in Perforce using Command line rather than P4V - perforce

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.

Related

Get only one folder from a stream depot in 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...

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).

With Perforce, How to merge files between different streams?

all
I got two streams such as Main and Dev. If I worked on Main and modified a file, called move.cs, for solving a problem, how can I merge move.cs to Dev. Since probably I have to change a lot of files on Main stream for correcting errors, it could be easy if the corrected files can be merged or copied to Dev stream, so that the same error can be solved on Dev stream, too.
Is there anyway to do it?
Thanks!
I assume that Dev is the child stream of Main.
From P4V graphical stream view, you can right click on the child stream, and select "Merge/Integrate to Dev...". By default it will try to merge from the parent stream up to parent #head revision.
More generally you have to use the p4 integrate command.
You can also shelf you changset in and unself it in another stream.

Populating a task stream with a revision different than head

I am trying to populate a task stream with an older revision than #head.
So I created a task stream, and did not chose to automatically branch any files.
Then I try :
>p4 populate -r -S //depot/dev //depot/main/...#some_label_vXXXX
Label 'some_label_vXXXX' is restricted to use on server 'Edge', not on server 'MASTER'.
I am connected to the edge server so I am not quite sure what is the issue there. If I need to have a global label to be able to branch, is there a way to convert an existing local to global label ?
Anyway, I try using a changelist instead.
>p4 populate -r -S //depot/dev //depot/main/...#1456175
//depot/main/...#1456175 - no target file(s) in branch view.
What happens there ? Is this an issue with the FromFile ? And what would be the proper way to populate a task stream using an existing label/changelist ?
Playing with P4V, it seems the command executed is (and this works) :
>p4 populate -o //depot/main/...#1456175 //depot/dev/...
I am still interested in understanding why the '-rS' does not work.
In this syntax:
p4 populate -r -S //depot/dev //depot/main/...#1456175
//depot/main/... is limiting the toFile, which is not what you want. This should work:
p4 populate -r -S //depot/dev #1456175
Giving the stream name already generates the fromFile->toFile view, so there's no need to specify either of them a second time.

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.

Resources