Is there a direct command that can compare the workspace file with the depot file and return the state of the file?
e.g.
p4 fstat D:/path/my_file.txt => inwork
p4 fstat D:/path/my_file.txt => up-to-date
In answer to the rephrased question:
Is there a direct command that can compare the workspace file with the
depot file and return the state of the file?
p4 diff -f [filename] will force a comparison (diff) regardless of whether the file is open.
The question is a bit unclear since you don't define what exactly you mean by "state" -- the p4 fstat command returns a lot of information about a file's state, and it sounds like you want some subset of that but you don't specify what.
That said, I'm guessing that you might like the p4 status command.
https://www.perforce.com/perforce/r16.2/manuals/cmdref/p4_status.html
This will tell you about files that are currently open as well as files that have been modified without being opened.
It sounds like you're looking for the -s flag to p4 diff, which I always mnemonically remember as the 'summary' flag.
https://www.perforce.com/perforce/r17.1/manuals/cmdref/Content/CmdRef/p4_diff.html
For example, p4 diff -sa: Show only the names of opened files that are different from the revision in the depot, or are missing.
Related
My p4 client version is P4/NTX64/2018.1/1705517.
I noticed that some files had accidentally been deleted in my workspace. I synced, but even so, the files did not appear.
I then ran the p4 have command and saw that it contained the missing files, and so p4 will not include those files in the sync.
Of course I can give the p4 sync command with the -f flag, but my workspace is rather large, so that would take a long time.
I then ran the flush command even with the -f flag thinking that it would correct my have list to reflect what I actually had on the filesystem of my workspace, but it didn't. What am I doing wrong?
p4 flush changes the have list to match whatever you tell it to match (if no arguments, then #head is the default). If that's not what your workspace actually contains, then the have list is now out of sync with the workspace, and future p4 sync commands will probably skip a bunch of files (exactly like you're seeing now).
The command you want is p4 clean, which syncs your workspace to match your have list. (If you have changes in unopened files, including "new" files that you haven't opened with p4 add, this will irrevocably blast them. Careful!)
If you want to open the files that don't match your have list, use p4 reconcile instead. (You can follow it up with p4 revert to discard the changes, or p4 submit to keep them permanently.)
New to perforce (and stackoverflow). I'm trying determine what has changed in my local view: I want to list all the recent changes under a directory in my workspace.
Perforce documentation seems to suggest everything is file based. Is there not a simple solution that does not require either probing each file individually and recursively down the directory tree, or filtering and processing changelists (multiple projects are sharing the same depot in my case)?
Ideally, I'm looking for the SVN equivalent of "svn log -v" (i.e., no path specification).
I'm also looking for a command-line solution.
Take a look at p4 changes and the documentation.
There are some examples, which might already help you. Moreover there are some global options, which you can use to specify the client, port, etc.
You are probably looking for something like
p4 changes -m 5 -s submitted //depot/project/..., which return the last 5 submitted changelists under the given depot path.
To see the last N changes under a particular workspace directory, do:
p4 changes -m N path/...
Note that path/... can be a relative local path, an absolute local path, or an absolute depot path. This is true for almost any Perforce command that accepts a file argument -- if you can specify one file you can usually specify an arbitrary pattern like "foldername/...", and you can usually specify it in either local or depot syntax.
I'm working on a script that processes the contents of a Perforce changelist. Each file in the changelist will be handled differently depending on the action associated with it.
I've already tackled the actions edit, add, integrate, and delete. So far, so good. However, for move/add and move/delete, I need a reliable means of determining the file's origin and destination, respectively. I've looked through the documentation for p4 fstat and haven't turned up anything of use.
Any ideas? Thanks.
Look at p4 filelog . It will give you the history of the moves. The -ztag output might or might not be useful for your purposes.
When "p4 describe changelist#" is issued, sometimes the affected files are listed; sometimes they are not and just show:
Affected files ...
Anyone knows why that is?
Most likely explanation: You do not have 'list' rights for the affected files. The docu for p4 protect explains the respective rights.
For example, if you have list, but no read rights, p4 describe will output:
Affected files:
//depot/path/to/file
Difference:
...
Likewise, if the list right is also missing, p4 describe will have the output that you saw. Check with your Perforce admin what the rights are for the respective depot path (let him issue p4 describe for the mentioned checklist :))
If the changelist only contains shelved files, you will see that behavior. For example:
d:\projects>p4 describe -s 925745
Change 925745 by mark.allender#client-mark.allender on 2011/08/11 07:48:04 *pending*
New SDK
Affected files ...
but since I have files that are shelved, I can use the -S option with describe to see the files that are shelved.
d:\projects>p4 describe -S -s 925745
Change 925745 by mark.allender#client-mark.allender on 2011/08/11 07:48:04 *pending*
New SDK
Shelved files ...
... //path/to/fileA#8 edit
... //path/to/fileB#11 edit
... //path/to/fileC#1 edit
... //path/to/fileD#3 edit
Also, it will display no files if there are indeed no files in the changelist, which might be the case for pending changelists. Notice that the first line of the describe output above says pending, which means that this changelist hasn't been submitted yet. Pending changelists can be empty, contain files, contain files and shelved file, or only shelved files. Depending on that state, the output of 'p4 describe' might not show any files.
Another possibility: files or file revisions have been obliterated.
Obliterating can leave submitted changelists that refer to no files.
How can I figure out the state of the files in my client, I want to know if the file needs an updated, or patched, or modified etc. In CVS, I used to simply run "cvs -n -q update . > file". Later look for M,U,P,C attributes to get the current status of the file.
In perforce, "p4 sync -n" doesn't give output like "cvs -n -q update". How can I see the current status of files, in case of Perforce?
To my knowledge, there isn't a command that will give you exactly what you want. In looking what the update command does, there is no single alternative in Perforce. I think that the closest that you will come will be to use the 'p4 fstat' command and parse the output from there to get the information that you need.
You might find this page helpful.
I also found this link to a p4wrapper that claims to wrap in come CVS commands (including update) into a script. There might be others like this one around as well.
I also wanted to comment that the answer to this question is like many with Perforce when asking "how do I do...". The answer usually comes down to writing a script to take the output from perforce commands to get the results that you need. Their philosophy is to provide bare bones commands and have developers build off of the basic functionality. Love it or hate it, that's the basic model. Many good scripts can be found in the Perforce Public Depot here.
Not sure if this is what you're looking for, but the p4 diff command has a few useful options. From the usage:
-sa Opened files that are different from the revision
in the depot, or missing.
-sb Opened for integrate files that have been resolved
but have been modified after being resolved.
-sd Unopened files that are missing on the client.
-se Unopened files that are different from the revision
in the depot.
-sl Every unopened file, along with the status of
'same, 'diff', or 'missing' as compared to its
revision in the depot.
-sr Opened files that are the same as the revision in the
depot.
Full disclosure: I work for Perforce
There will be a 2 new commands "p4 status" and "p4 reconcile" in the up-coming 2012.1 release. See the following for more details:
http://www.perforce.com/blog/120126/new-20121-p4reconcile-p4status
Not quite sure what you mean. If you are talking about seeing what files need "resolving" (in perforce language) then you can use:
p4 resolve -n
See the p4 command line manual website here:
http://www.perforce.com/perforce/doc.current/manuals/cmdref/resolve.html#1040665
Also P4V has a nice feature to highlight unsubmitted and dirty files, if you use that client. Right-click on a fodler in the workspace view, and select "reconcile offline work." After a bit of processing you'll get a list of files that are out of sync with the depot.
Hope this helps.