Useful ccollab (Smartbear) and p4 (Perforce) commands

Smartbear collaborator is a powerful tool used for code reviews and Perforce is a centralized version control system. Both of these tools have GUI and command line clients. I have been used to the cli so in this post, I will write up the commands that I use while working with the Perforce-Smartbear duo.


Since we use Perforce as your version control system, any changes we make to our workspace files we add them to a changelist.

A changelist is created by using the following command

p4 change

After this we will be populating the description and saving the file. Once the file is saved, we see an output giving us the changelist number.

We then add files to the changelist identified by the above changelist number.

If we are going to add a new file to the depot, then we use

p4 add -c <changelist_number> <path_to_file>

If we are going to modify an existing file, then we use

p4 open -c <changelist_number> <path_to_file>

If we are going to delete an existing file, then we use

p4 delete -c <changelist_number> <path_to_file>

If the file we are going to edit is already on another changelist (for example, the default changelist), then we should reopen it. You may notice that the files in the default changelist get added to the new changelist while you create it using p4 change itself. But anyways, this command will be useful to migrate files from one changelist to another changelist.

p4 reopen -c <changelist_number> <path_to_file>

This will reopen the file and move the file to the specified changelist.


Optionally, we can associate this changelist with a Jira, We do so by adding a job to the perforce which will associate the changelist with the given Jira ticket. You would need a plugin for this.

p4 fix -c <changelist_number> <JIRA_ID>

Note that the JIRA_ID contains the full id of the Jira including the project prefix. For example, ABC-1001 where ABC is the prefix.


After creating the changelist and adding files to it, we should be raising a code review in the Smartbear collaborator.

ccollab addchangelist new <changelist_number>

Sometimes (of course, most of the times :) ) we will be getting a rework. So, we will be modifying the files further. If we are going to add/delete new/old files, then we will be using the above steps as mentioned.
If you are going to modify the existing files that which you have already opened (i.e. added to the changelist), then you need not do anything further.

But, remember to update the review with the new files. For this, we do

ccollab addchangelist <review_id> <changelist_number>

The review can be found in the output of the previous command. You can go to your Smartbear URL (http://smartbear/ui#review:id=56203) and see your files.


Once the review is complete, we need to submit the files…

p4 submit -c <changelist_number>

All the files will be submitted successfully. Sometimes, you may need to merge. For this you need to do…

p4 resolve -c <changelist_number>

Important note!

Sometimes, it may happen that we may modify a file on our workspace but does not p4 open it. We simply make the file writable and make some changes, but the Perforce is not aware of it. But when we make the local build, these changes will be part of our local build.

This can get into serious problems, because, the build with your unchecked changes may work for you (locally) but not for others because the changes are not known to perforce, they will not be submitted to the depot.

So, what I generally do is, I will add all the files to change list using the following command.

find . -type f | xargs p4 open -c <changelist_number>

Here I go to a directory which I think, I could have changed and then open all the files there. Then I revert, the unchanged files using…

p4 revert -a -c <changelist_number>

Now that, my changelist contains only those files which are changed.

ధన్యవాదాలు (Thanks)

No comments: