📅 2018-Jun-12 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ changelist, cheatsheet, p4 ⬩ 📚 Archive
A changelist in Perforce is identified by an unique number and contains a list of modified files and a description (among other things). When you inform Perforce that you have created a file, deleted a file or modified a file, such changed files are by default added to a default changelist that has no changelist number.
$ p4 change
This opens your default editor to a temporary text file showing an empty description and the list of files from the default changelist. You have to use the editor and provide a description. If you do not want some of the files to be in the changelist you are creating, you can delete those lines in the editor. Once you save the file, the changelist is created with a unique number identifying it. After this command ends, p4 prints out its changelist number, say 123456.
Note that this command moves all the files in the default changelist to the new changelist you created. That is, unless you removed a few of them while creating the changelist.
$ p4 change -o 123456
$ p4 reopen -c 123456 joe/foobar.cpp
$ p4 reopen -c default joe/foobar.cpp
$ p4 describe 123456
$ p4 change -u 123456
$ p4 shelve -c 123456
$ p4 describe -s -S 123456
$ p4 shelve -f -c 123456
Note that there might be files that are present in the shelve but not present in the pending changelist. This operation will not touch those file in the shelve and those files will continue to exist in the shelve.
$ p4 shelve -r -c 123456
Note how this is different from the -f
option. This operation completely replaces the current shelve with the pending changelist. After this operation the shelve and the pending changelist will be perfect replicas of each other. Files that were present in the shelve and not in the pending changelist will be lost.
$ p4 shelve -f -c 123456 foobar.cpp
$ p4 shelve -d -c 123456
$ p4 shelve -d -c 123456 joe/foo.cpp joe/foo.h
$ p4 unshelve -s 123456 -c 123456
$ p4 unshelve -s 123456 -c 789012
$ p4 unshelve -s 123456
$ p4 submit
$ p4 submit -c 123456