New in 2012.1: 'p4 status' and 'p4 reconcile'
The 2012.1 release of Perforce is just about to be released for beta. It's loaded with great new features. One is the p4 reconcile command, with its fraternal twin, p4 status.
As you know, Perforce expects you to open files as you work, but it does not require you to do so. You are free to create files, remove files, change file permissions, and modify files in your workspace without using any Perforce commands. Whether you open files before or after you make local file changes is up to you.
Eventually, however, you have to open the files you've been working on in order to submit them. This always been easy with P4V. But in a command shell, finding the files you need to open has been a challenge.
As of Release 2012.1, we denizens of the shell can use p4 status to find the files we need to open. For example:
p4 status src/tools/this.rb - reconcile to edit //depot/stuff/src/tools/this.rb#3 src/tools/that.rb - reconcile to add //depot/stuff/src/tools/that.rb#1 src/tools/other.rb - reconcile to delete //depot/stuff/src/tools/other.rb#2
The p4 reconcile command finds the same files, but goes so far as to open them:
p4 reconcile //depot/stuff/src/tools/this.rb#3 - opened for edit //depot/stuff/src/tools/that.rb#1 - opened for add //depot/stuff/src/tools/other.rb#2 - opened for delete
Both commands have the same underlying logic. (In fact, p4 status is simply an alias for p4 reconcile -n, with slightly different outputs and options.) They compare the actual files in your workspace to your workspace's “have” list:
- Files on the “have” list and whose contents have changed can be opened for editing.
- Files on the “have” list but missing from your workspace can be opened for deleting.
- Files found within the workspace view but not on the “have” list can be opened for adding.
The new commands take Perforce filespec arguments, of course. For example:
p4 status docs/... themes/.../*.css
With p4 status and p4 reconcile, the "
..." wildcard gives us just what we want: a recursive search of local workspace files. (With the old p4 add command, by comparison, "
..." gives a recursive search of depot files.)
You may find it easier to open files to be added, edited, and deleted separately. The p4 status and p4 reconcile commands have flags for this. For example, to reconcile only the files that will be opened for adding:
p4 reconcile -a
I've been using these two commands for a few weeks, and have these tips to pass on:
- It's a good idea to run p4 status first. p4 reconcile can open lots of files you didn't expect to open!
- Reconciling added or edited files doesn't change the content of your workspace files. However, it will make files writable if they aren't already.
- Reconciling deleted files doesn't affect the workspace.
- Renamed or moved files can't be reconciled after the fact. Always use p4 rename or p4 move for renaming files.
- Local filetype changes can't be reconciled. You have to open files and set their new types explicitly.
- But wait, there's more! Be sure to run p4 help reconcile to see all the ways these commands can be used.
And I can't tell you how happy I am to get rid of my old '
find|p4 add' wrapper!