Table of Contents
- update: 2020-06-10
- p4 opened (workspace in clean state?)
- perforce Time-Lapse cli
- BROWSING (folder) HISTORY
- p4 describe (GUI)
- merge
- p4 print
- p4 diff
- p4 open
- p4 reopen, move files between changelists
- p4 edit changelist description
- p4 unshelve
- Shelve
- p4 clean
- p4 labels
- p4 merge
- p4 integrate
- p4 user
- p4 view changelist diff with magit
- p4 code owner
- p4 - find workspace path
update: 2020-06-10
p4 diff
p4 opened (workspace in clean state?)
Run "p4 opened" "p4 resolve -n" to see if your worksapce is in a clean state
p4 opened p4 resolve -n
perforce Time-Lapse cli
p4 have Makefile p4v -cmd "annotate //depot/to/Makefile" In new p4 version: p4vc timelapse "//depot/to/Makefile"
BROWSING (folder) HISTORY
p4 changes -m10 //depot/folder/...
LISTING DIRECTORY HISTORY
listing the most recent changes first:
p4 changes -m5 //public/revml/...
If you want to see entire descriptions, use changes -l.
In P4V you can use Folder History to see the history of a directory
p4 describe (GUI)
p4 describe changelist
p4v
Search Go To... (Ctrl-G) Show File Diffs Diff Against Prvious Revision
https://stackoverflow.com/questions/2328955/how-do-i-display-a-particular-changelist-number-in-p4v
merge
The changelist you’re currently synchronized with:
p4 changes -m1 ...#have Change 9284 on 2004/03/01 by jim 'Swap project names'
What’s happened in the depot since you last synchronized:
p4 changes "...@>9284" Change 9284 on 2004/03/01 by ... Change 9306 on 2004/03/05 by ... Change 9301 on 2004/03/05 by ... Change 9299 on 2004/03/05 by ...
p4 describe -s 9299
p4 sync ...@9299
Auto-resolve the files that don’t have conflicts, then resolve the rest of the files interactively:
p4 resolve -am p4 resolve
p4 print
https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_print.html
To get solely version 3: p4 print -a readme.txt#3,3 To output a file at every revision within a specified revision range, such as versions 2, 3, and 4 of readme.txt: p4 print -a readme.txt#2,4 p4 print [-a -A -k -q] [-m max] [-o outfile] FileSpec[revSpec] p4 print -o c:/tmp/main-copy/... //depot/main/...
p4 diff
env P4DIFF=~/bin/python_/icdiff p4 diff env P4DIFF=meld p4 diff env P4DIFF=tkdiff p4 diff env P4DIFF=p4merge p4 diff env P4DIFF=vimdiff p4 diff
p4 open
p4 -ztag opened | grep clientFile| awk ' {print $3}' p4 -ztag opened | grep clientFile| awk ' {print $3}' | sed s+//master_ming_138+.+ p4 -ztag opened | grep clientFile| awk ' {print $3}' | sed s+//master_ming_138+.+ | xargs -n1 echo p4 edit # echo: dry-run
p4 reopen, move files between changelists
p4 reopen -c changenum filenames
If you are moving files to the default changelist
p4 reopen -c default filenames
p4 edit changelist description
p4 change -u 123456
p4 unshelve
See https://codeyarns.com/tech/2018-06-12-p4-changelist-cheatsheet.html
Unshelve
To unshelve the files that were shelved from a changelist 123456 back to the default changelist:
p4 unshelve -s 123456
To unshelve the files that were shelved from a changelist 123456 back to a different changelist 789012:
p4 unshelve -s 123456 -c 789012
https://stackoverflow.com/questions/9315884/perforce-move-a-shelved-changelist-from-main-to-branch https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_unshelve.html -b branch
cat .p4branch p4 unshelve -s 3891887 -b <other_branch>
https://stackoverflow.com/questions/37478182/in-perforce-how-to-unshelve-change-from-one-branch-to-another-one p4 files @=changelistA p4 branch -o branchB
Shelve
To create a changelist from the current default changelist
p4 change
To shelve the files from a changelist 123456
p4 shelve -c 123456
p4 clean
p4 sync directory/...#0 p4 sync ...#0
remove files that aren’t open for edit
p4 labels
p4 labels -u product | grep 2018.09
p4 merge
Manually resolve the conflicts
$ p4 resolve ... - ... Diff chunks: 1 yours + 0 theirs + 1 both + 1 conflicting Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) e: a There are still change markers: confirm accept (y/n)? y ... ... - merging ... Diff chunks: 0 yours + 0 theirs + 0 both + 1 conflicting Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) e: a There are still change markers: confirm accept (y/n)? y
Select e -> pop up a editor with the conflict content -> save it after resolving the conflicts Select a to accpet the result of e
If you select a without doing anything, it would result in a file with
>>>>> ORIGINAL //path/to#22 Hello ====THEIRS //path/to#18 World ==== YOURS //path/to <<<<
In this situation, you shuld resolve this file afterwards.
P4MERGE='p4merge' P4DIFF='emacs -diff' p4 resolve P4MERGE='emacs -diff' P4DIFF='emacs -diff' p4 resolve
https://stackoverflow.com/questions/3822473/p4config-with-emacs
p4 integrate
Use p4 client to check depo path
p4 integrate //path/to/depot/vg/eve/TD...@3332409,3332409 //path/to/depot/vg/eve/ZEBU2020.03/...
Use -f switch also to forcefully integrate. Sometimes we noticed p4 integ operation was performed but changes were not checked-in. -f will help to catch those issues.
p4 integrate -f //path/to/depot/vg/eve/TD...@3332409,3332409 //path/to/depot/vg/eve/ZEBU2020.03/...
p4 user
Reviews: //path/to/depot/...
https://stackoverflow.com/questions/588264/perforce-getting-email-on-every-checkin
p4 view changelist diff with magit
git p4 clone //path/to/depot/...@3425565,3447885 git p4 rebase emacs
To reproduce the entire p4 history in Git
git p4 clone //path/to/depot/...@all
p4 code owner
cat ,p4own #!/bin/bash p4 annotate -uI "$@" | awk '{print $2}' | sort | uniq -c | sort -rnk1
p4 - find workspace path
List submitted and pending changelists.
p4 changes -m 5 -s pending -u ming p4 changes -m 5 -s shelved -u ming p4 changes -m 5 -s submitted -u ming https://www.perforce.com/manuals/v15.1/cmdref/p4_changes.html
p4 clients|grep client_name
Your code review system might also proivde changelist informaiton like Review Title @4016910 - …
p4 describe 4016910 p4 clients|grep client_name