Craig
Craig

Reputation: 4409

p4 CLI: How to find new files not yet "added" to perforce control

I have looked at different ways of doing this using diff. The first option I tried is:

p4 diff -sa

Opened files that are different from the revision in the depot, or missing.

Initially I figured that this was a file with write permission bit set that did not exist in the depot. However, I have since learned p4 doesn't use mode bits to track opened/unopened states as I first thought.

Next I figured this option would work:

p4 diff -sl

Every unopened file, along with the status of 'same', 'diff' or 'missin' as compared to its revision in the depot.

This would be okay, except "unopened" is not inclusive of "untracked" files. Although, when I ran this, it produced something quite different that contradicts the documentation; it output pretty much everything that was tracked, but also output everything that wasn't tracked, but flagged them as 'same'. Maybe this means that it hasn't been added and doesn't exist in the depot, so the client is the same as the depot...? In my SVN biased opinion, a rather pointless option.

Then there is the 'opened' option. But this does exactly that. It lists all the files in the depot that have been opened on the client; so not the files modified on the client not yet added.

So is there an option I am missing somewhere, that will provide some valuable answer, like SVN and CVS are able to do with one simple command?

$ svn status
A added
M modified
R deleted
? untracked
L locked
C conflict

Or:

$ cvs -q up -Pd

Upvotes: 2

Views: 5651

Answers (2)

Craig
Craig

Reputation: 4409

Okay, looking around and playing with the 'add' command, it seems that a read-only add will output successful message if the file is not currently controlled:

$ p4 add -n -f somefile
//source/somefile#1 - opened for add

I applied this to the following command and pretty much get what I need:

$ find . -type f | while read f ; do p4 add -f -n "$f" | grep -e '- opened for add' >/dev/null && echo "A $f"; done
A ./somefile

Or if you're not bothered about local paths:

$ find . -type f | xargs -l1 p4 add -f -n | grep -e '- opened for add'
//source/somefile#1 - opened for add

Upvotes: 3

Bryan Pendleton
Bryan Pendleton

Reputation: 16389

Well, there exists "p4 status", which is very similar in both purpose and behavior to "svn status".

For more ideas, see: http://answers.perforce.com/articles/KB_Article/Working-Disconnected-From-The-Perforce-Server

Upvotes: 1

Related Questions