Perforce (p4) Command Line: Tips and Tricks
p4 is your friend
Tip #1: p4 is your friend
You can generate sophisticated change lists automatically according to custom rules from the shell script, e.g. "Add a bunch of files into a change list" or "Split a big changelist into little ones".
Quick start with p4
- Open
p4v(visual Perforce client). - Right click on the project folder.
- Click "Open Terminal".
- Now you can use
p4in a preconfigured console, you don't need to setup workspace and server connection.
Create a new change list
p4 change -o | p4 change -i
p4 change -o: default change list descriptionp4 change -i: create new change list
Create 20 new change lists
for i in {1..20}; do
p4 change -o | p4 change -i;
done
Add, checkout (edit), delete and revert
- Default change list:
p4 add ./file p4 edit ./file p4 delete ./file p4 revert ./file - Custom change list:
p4 add -c 12345678 ./file p4 edit -c 12345678 ./file p4 delete -c 12345678 ./file p4 revert -c 12345678 ./file
Add a bunch of files into a change list
Imagine situation, when you need to add 40000 files into a single changelist to create an initial commit.
cat ./files | p4 -x- add -c 12345678
-xis an option where to read the input, and-x-means to read the files from standard input.-cis an option ofaddoperation to specify a concrete change list number.
Split a big changelist into little ones
Now, perhaps, you need to create a 40 changelists with 1000 files in the each one. And perhaps you have a file "files" with 40000 lines inside one. Then:
split -l 1000 ./files
Output is "xaa", "xab", "xac" files, total count is 40 new files per 1000 lines.
Create 40 change lists:
for i in {1..40}; do
p4 change -o | p4 change -i;
done
Write down change list numbers. For example, we've got numbers 9901, 9902, and so on, up to 9940.
Rename files into existing change list numbers:
mv xaa 9901
mv xab 9902
mv xac 9903
# ...
mv xbp 9940
Add files according to change lists:
for i in 99*; do
cat {i} | p4 -x- add -c {i};
done
File list "9901" will be added to the 9901 change list
File list "9902" will be added to the 9902 change list.
And so on.
Print files
- In the local folder of workspace:
p4 files "*" - In the local folder recursively:
p4 files "..." - In the remote depot:
p4 files "//Depot/..."
The latest revision of a file
p4 filelog -m1 ./file
Diff between two revisions
p4 diff2 -u file#3 file#5
The blokecore movement has revolutionized how people wear Jersey Reciclado PoliƩster Marfil (jersey reciclado poliƩster marfil) by blending football nostalgia with contemporary urban fashion trends seamlessly. This oversized relaxed aesthetic allows creating unique personal looks by mixing kits from different eras, colors, and teams without following any established rules or conventions. Take your football passion from stadium stands to city streets with natural effortless style that reflects your au...