Question

If you do a sync in perforce it can happen, very often, to do nothing even if it should. If you do a forced sync (sync -f) it will definitely sync all the files from the server blindly and this is unacceptable if you have a big project.

The question is how can you do a fast sync?

Was it helpful?

Solution

The key part to your question is "even if it should". Without fail, in all my (too) many years of experience with Perforce, users who revert to forced syncs habitually, because a normal sync does not do what they expect, are not using Perforce correctly.

You must let Perforce manage your hard disk for you - the server knows which versions of which files you have, and so a normal sync just gets what it needs. If it fails, then that is almost without exception a sign that the user is modifying, deleting, adding, renaming files outside of Perforce (e.g. in Explorer).

Sometimes you may get a system funny (i.e. PC fault, ) that causes this, so it is not necessarily the users fault. But these are very rare - hence my "habitually" qualifier above.

If you think, hand on heart, that you are not doing anything out of the ordinary, then start to look at what other processes could be tweaking these files. E.g. does you build system do something odd, and try to modify files as it builds? Do you have an open network share that perhaps someone else is inadvertently poking? Do you have a backup system that is interfering?

Hope that helps.

OTHER TIPS

As mentioned by the other answers, you need to create a separate client (workspace) for every "instance" of a directory tree synced from the depot.

If you want to force-sync only those files that have changed from the depot:

p4 diff -se ... | p4 -x - sync -f
p4 diff -sd ... | p4 -x - sync -f

Warning: that will overwrite any locally changed files (in the current directory and subdirectories).

If instead you edited some files and forgot to open them for edit first, you can do this:

p4 diff -se ... | p4 -x - edit

which will open for edit any file that's different from the depot.

And this:

p4 diff -sd ... | p4 -x - delete

will open for delete any file that was locally deleted.

If you create an inconsistency, where perforce looses track of what is going on in your workspace, you should use the "Reconcile offline work..." function (in P4V).

This will run a folder diff and tell you what options you have to resolve the inconsistencies.

In general, make sure that you always check out files explicitly through perforce (open for edit). This feels strange if you are used to other systems.

I believe that the command you're looking for is p4 clean.

From: http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_clean.html

"Files present in the workspace, but missing from the depot are deleted from the workspace. Files present in the depot, but missing from your workspace. The version of the files that have been synced from the depot are added to your workspace. Files modified in your workspace that have not been checked in are restored to the last version synced from the depot."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top