Is there a way to get code-reviews done by PEER before submitting the changes in Perforce?I heard p4 shelve is an option,is it right?is there a better way?
p4 [g-opts] shelve [files ...]
I would say that "p4 shelve" is the best way to do code review. You might want to look at Swarm, which offers code review features that are based around shelving.
https://www.perforce.com/perforce/r16.1/manuals/cmdref/p4_shelve.html
https://www.perforce.com/perforce/r16.1/manuals/swarm/chapter.code_reviews.html
Related
The scenario is as follows: A user has opened a merge request that adds a new feature to my code. Their code however contains a few bugs. I know how to fix the appropriate parts but I'd prefer keeping my repository free of code that has known issues. Therefore I'd like to modify their code before merging it.
I know I could also manually copy over the changes but I would still like to give the user that opened the merge request credit for their contribution.
You could take the user's changes (pull them over to your development environment) using Git, and then add your changes, and then merge the lot -- this way your user's commits are visible, and your commits are visible.
You could also add your user to a CREDITS file to give them credit as a contributor.
You could also ask the user to fix the bugs (which helps the user too, to learn how to improve their code) and then merge the change.
I am a git person. In git, after I finishing a little feature, I will submit the branch to review and start a new branch to work on new features.
For example, I had submitted a code recview for feature A, and it is still under review. At this time, I want to start working on feature B, assuming feature A's code will be merged in the near future. In Git, typically I just create a new branch to work on the new feature, if there is some problem with feature A I can easily switch back to branch A to fix it and merge the fixed version to my new feature branch.
How's it achieved in perforce? Should I copy the whole code somewhere as a way to manage branch myself?
You can do this in Perforce exactly the same way you'd do it in Git, if you like -- create your feature B branch and work on feature B there. If you need to make changes to your feature A branch, those can be merged back to your mainline and/or your feature B branch.
If you do your code reviews as shelves, you can have any number of them in development at a time; a shelved change is effectively "rebased" onto submitted changes when you sync+resolve.
FWIW, usually the way I've done reviews in Perforce is to make my changes on my own development branch, set up the merge to the mainline, and then shelve that for review. That way I can continue work on my development branch uninterrupted, I don't need to create a new branch, and if there's a fix needed to my merge-in-progress I can just amend the shelved change (either by submitting the fix to my branch and adding it to the merge, or making the edit as part of the merge operation); it also has the benefit of making conflict resolution (if any) part of the change under review.
Changelist during submission might be re-enumerated. I need to get old changelist number for already submitted changelist. I can do that using p4:
p4 -Ztag -F%oldChange% describe 1234
I want to do that using p4api.net but I cannot find the way.
Do you know if there is such option?
It doesn't appear to be part of the P4.Changelist interface, but you should be able to just run the describe command with tagged output and get the oldChange field.
https://www.perforce.com/perforce/doc.current/manuals/p4api.net/p4api.net_reference/Index.html
Look at P4CommandResult.TaggedOutput, P4Command, and Connection.
Problem :
I have a strange requirement to move a specific CLN (Foo) from SERVER-1 to SERVER-2.
Possible Solutions I can think of :
Sol #1
Create a patch of Foo in SERVER-1 to Foo.patch
Apply the Foo.patch to SERVER-2
Sol #2
Manually merge changes of "Foo" CLN from SERVER-1 to SERVER-2 ?
If anyone have faced a similar situation, Please provide the best recommendation.
If this will only be a one off act, then syncing the files from the original server, copying them to a workspace on the new server, then adding them with 'p4 add' is the easiest way of getting the files in to the new server.
The disadvantage with this method, is that the new server, won't have any details about the files history, before they were added.
If you do need to see details of the file history on the new server, please leave a comment.
Depending on your requirements there are a few possible solutions, so I do not want to elaborate on all of them in this answer.
Cheers,
Jen.
Say, I have a project called example.vcproj to which I have added files:
1. first_file.c
2. second_file.c
first_file.c was added 10 days ago and has still not been code reviewed. Therefore I am still waiting for it and at this moment I cannot check in the files.
second_file.c was added recently. It has gone through the code review and is ready to be checked in. However since my first file is still on review, I am not able to go ahead and submit the second one, mainly because of the dependency on example.vcproj.
Please let me know the simplest way to resolve this conflict other than temporarily removing the first_file.c and reverting the example.vcproj and checking in the most recent changes. Thanks.
There are a couple of things you can try.
First, you can shelve all of your files prior to submit. That at least means you are in no danger of losing any work, as the files will be stored on the Perforce server. After you receive code review you can check them in.
Second, you can create a private branch or stream for your work-in-progress. Then whenever you hit a stable milestone on your private branch, you can get code review approval and promote it to the shared branch.