Perforce - How to get the list of files that have been modified locally? - diff

I am looking for a perforce command to get the list of the files that have been modified locally and "not" checked-in to the repository.
I understand that I "should" get the list of modified files in Pending changelist, but there are scenarios when I don't get to see a modified file in that list. And then on "manually" checking out a file and doing a diff i realize the difference.
Is there any command that could check all the files in a given folder and provide me a list of files that are not same as there state in the repository?
I tried "p4 sync", but that did not work.
Thanks for your interest.

Try
p4 diff -f -sa
(see manual for further details)

I use "p4 revert -n ./..."
where
-n
List the files that would be reverted without actually performing the revert.
This lets you make sure the revert does what you think it does before actually reverting the files.

In the recent versions of Perforce, try "p4 reconcile -e"
see: http://www.perforce.com/perforce/r12.1/manuals/cmdref/reconcile.html
It certainly takes its time though (not very fast).

I think, the modified files are submitted locallay (Otherwise, p4 opened ./... will help to find)
If files are already submitted to local perforce and still want to know which all are modified..
p4 changes -m 5 ./... (Should give changes lists)
p4 integrate -n ./... //server/code/base/... (This should list the files to be integrated to mainline.

Related

Perforce Commandline Get Contents of Deleted File

I've done this several times in git, but not sure how to do it in p4 commandline. Google is not helping me - or maybe I'm not searching correctly.
I have a file that was deleted: /path/to/file/index.html Now, I need to get the contents of that file as it was before being deleted. I do not want to bring it back to life, I just need the contents.
The changelist for the delete is 125325.
What would be the easiest way to do this?
To sync it to your workspace (this is kind of similar to the git checkout method that you're probably familiar with):
p4 sync /path/to/file/index.html#125324
If you just want to see the content (e.g. dump it to stdout), you can use p4 print (if you were to use the depot path of the file rather than a local path, p4 print doesn't require that the file is mapped to your workspace):
p4 print /path/to/file/index.html#125324
Note that the rev specifier I'm using is the changelist before the file was deleted. You can also use the prior revision number, or an earlier rev/changelist, a particular date, etc. See p4 help revisions for all the ways you can reference older versions of files.

Perforce - create patch file of differences against have revision

In Perforce, how can I create a patch file which has the changes that are in the file as currently saved, compared to the have revision? Instructions for either the GUI client or the CLI client would be great.
I can see how to get the diffs between two changelists, but not how to just get the difference between the last changelist and the current state of the files. Additionally, I can see that in the GUI client, I can right-click on a file and select "Diff Against Have Revision" from the contextual menu, which shows me what I'm looking for, but I can't figure out how to get that into a file.
I'm basically looking for the equivalent of what git diff <file> > patch.diff does in Git-land.
I think that p4 diff -du FILE > patch.diff should do what you want.
Single file
p4 diff -du file > file.patch.diff
Every file
p4 diff -du > patch.diff
The problem with p4 diff is that it doesn't take into account of new files. Also you can't get files that are only in a certain pending change list.
If there is a pending changelist, you can actually use an open source perforce patcher tool, which I have created for my project needs. You can directly download from this link of github.
In case you want to checkout the source, go to the github repo.
Documentation for the tool can be found here.

Perforce command line head revision file

What is the command line syntax to check whether this workspace currently has the latest revision of a certain file?
The command:
p4 sync -n
will preview the sync operation. This will tell you which files would be updated were you to use the actual command.
The command:
p4 have [file]
will tell you the version of the file you currently have. This coupled with:
p4 fstat -T "headRev" [file]
which tells you the head revision number, will tell you whether you have the latest version or not.
It's worth noting that all Perforce commands have a preview option that tell you what they would do. This allows you to verify you've got the correct command without fear of corrupting your workspace or depot.

Mercurial workflow for updating with uncommitted changes?

So i've made the switch from CVS to mercurial for my website.
The biggest issue I am having is that if i'm working on some files that I don't want to commit, I just save them.. I then have other files I want to push to the server, however if someone else has made changes to the repository, and I pull them down.. It asks me to merge or rebase.. either of these options will cause me to lose my local changes that I have not committed.
I've read that I should clone the repository for each project on my local host and merge it into the live when it's ready to do so. This not only seems tedious, but also takes a long time as it's a large repository.
Are there better solutions to this?
I would have hoped that Mercurial would see that I haven't committed my changes (even though I have changed the file from what's on the server) so it'd just overlook the file.
Any input on this would be greatly appreciated. Thank you!
Also, i'm using the hg eclipse plugin to work on my files and push/pull from the server.
hg shelve is your friend here I think.
which comes from the shelve extention (maybe - see below)
from the overview:
The shelve extension provides the
shelve command to lets you choose
which parts of the changes in a
working directory you'd like to set
aside temporarily, at the granularity
of patch hunks. You can later restore
the shelved patch hunks using the
unshelve command.
The shelve extension has been adapted
from Mercurial's RecordExtension.
or maybe its the attic extension
This module deals with a set of
patches in the folder .hg/attic. At
any time you can shelve your current
working copy changes there or unshelve
a patch from the folder.
it seems to have the same syntax as the shelve extension, so I'm not certain which one I've used
I second #Sam's answer. However, if you prefer to use standard Mercurial, a simple workflow is to
save your working dir changes in a temporary file,
sync your working dir with a specific revision, then
push, pull, merge .. whatever you want to do and which requires a clean working copy, and
get back your changes from the temporary file into the working dir.
For instance:
$ hg diff > snapshot.patch # save your uncommited changes
$ hg up -C # get a clean working copy
$ hg pull # do things ..
$ hg merge # .. you need a clean ..
$ hg commit -m "merge" # .. working copy for
$ hg import snapshot.patch # get back your uncommited work
First, are you working from the commandline, or using something like Tortoise?
If you're working from the commandline, and you've done a pull, mercurial will not ask you to do anything, as it merely updates your local repository.
If you then do an hg update and have local changes, it should do what you're used to from CVS. It will update to the tip of the current branch, and attempt to merge your outstanding changes in. There are some caveats to that, so refer to the official docs at http://www.selenic.com/mercurial/hg.1.html#update.
Also, for temporarily storing changes, I would recommend MQ over shelve. Shelve only provides one storage area, whereas MQ provides as many as you need. MQ takes some getting used to, but worth the investment.

Use perforce to capture current state of external directory

I have a directory outside the repository. I put generated sources in there. These generated sources take FOREVER to create. Rather than have everyone on the team generate these sources, I would like to use our build machine to generate the sources, and check them in to perforce. How do I do this and ensure that the source controlled directory only has only the most recent files and not any that were generated previously but not in the most recent build?
I was thinking of doing a p4 edit on all the files in the generated directory (for existing files), then doing a p4 add using wildcards to get any files that are new, but I do not know how to handle files that were previously generated, but not generated in the most recent build (should be deleted).
Start as you suggested - p4 edit and p4 add to capture all changes, then call
p4 revert -a
Which will revert any file in the depot that is open for edit but is actually unchanged or missing.
I found this on the perforce blog and it is exactly what I was looking for. Automating folder replacement using P4Java and Apache Ant
One idea is to, before the build, removing everything in this area manually (not through Perforce, but through the OS). After doing the build, do a "Reconcile Offline Work". This will reconcile in Perforce what you have in this area by adding new files, deleting ones that are not there anymore, and editing those that have changed.
You can reconcile offline work through P4V, as seen here. In your workspace browser, right-click the folder and choose "Reconcile Offline Work".
Or, you can do it through the command line if you prefer a more automated solution, as seen here. (Note: this link also talks about reconciling through p4v, but this is superseded by the previous link)
p4 diff -se //myclient/... | p4 -x - edit
to checkout changed files.
p4 diff -sd //myclient/... | p4 -x - delete
to delete files.
find . -type f -print | p4 -x - add
find . -type l -print | p4 -x - add
to add files and symlinks in Unix, or
dir /s /b /a-d | p4 -x - add
to add files in Windows.
For Binary files in Perforce you can set a FileType flag that only stores 1 (or a set number ) of revisions for the file in the repository. This way you will have history of the file but your other users will only have access to the binary for the latest version of the file and also your server will only store one copy which is much more storage efficient if you dont need to store multiple copies.
To make the change.
Add the files you are interested in to the repository.
Check out the file.
Right click in P4V and select Change Filetype
On the dialog pops up select +S "Server limits the number of revisions stored" at the bottom of the screen, which will restrict the number of files stored.
Hope this helps.