How to sync perforce client to reduced p4 client specs?

160 views Asked by At

I have a large perforce client already synced. I realized that I'll only be working on a sub directory of the larger root folder I synced to.

Old p4 client specs

//Depot/largeFolder/... //Clinet/largeFolder/...

New p4 client

//Depot/largeFolder/samllSubDir/... //Clinet/largeFolder/smallSubDir/...

Now when I perform a p4 sync perforce doesn't remove the other folders which I don't want in my client. I'm hesitant to do a p4 sync -f since I have files edited in the /largeFolder/smallSubDir/. I don't want them to get reset.

What is the right way to sync my client so that the other folders which are not in the new mapping are removed?

Note: My real mapping is complicated and deleting folders by hand is not realistic.

1

There are 1 answers

2
Samwise On BEST ANSWER

In the typical case, re-syncing a narrowed client will indeed remove the unmapped files. You don't say what happens when you try to do a sync (are there error messages?), so I can't say for certain what's going on, but these are the two first possibilities that come to mind:

  • Opened files will not be touched by a sync, ever. You need to revert them -- use the -k flag if you want to revert the files but keep your local copies, and then use the -k flag on sync as well so that it will continue to not touch them (while marking them as having been synced, or in this case un-synced).
  • Writable files will by default be left alone by a sync, and produce "can't clobber" warnings. Doing sync -k should suffice here if you want to keep the local files. Doing sync -f will blow away the local files even if they were modified (but only if they're not also open for edit -- see above).

Useful commands to run if you're trying to debug (pick any file that's not getting [un]synced that you think should be):

  • p4 sync <file> -- do you get an error message that tells you why the file isn't being removed?
  • p4 where <file> -- is the client mapping for that file not what you think it is?
  • p4 opened <file> -- is the file opened?
  • p4 have <file> -- did you even sync this file in the first place?
  • p4 files <file> -- does this file even exist in the depot?

Note that the fact that opened files will not be touched by a p4 sync means that your edited files will be safe from a sync -f, provided that you actually opened them for edit. If you didn't, run a p4 reconcile and then p4 sync -f is perfectly safe -- but if you don't get to the root cause first (i.e. are the unwanted files also opened for edit?), it might not be helpful either.