tags:

views:

38

answers:

2

I want a fast solution that does not require force sync that will put a specified directory to its original repository state.

  • same files may be removed from disk
  • same files may be added from disk
  • some files may be modified on disk
  • some files may be marked for removal, addition or modification in perforce

All I want is to be sure that after if run the command I will have none of these.

p4 -f sync is not an option, I need a faster solution that does minimize networks usage.

Just in case someone asks, perforce proxy is out of discussion.

I do know that a partial solution is:

p4 diff -sd -se //clientspec/dir/... | p4 -x - revert

The problem is that this does not remove files added to the paths above that are not in perforce - files that I want to be removed from disk.

Also, I need a multi or cross platform solution - it has to work on Windows, OS X and Linux.

A: 

If you have Unix/Linux this may work.

In Perforce you can "Reconcile Offline Work" through p4v, as seen here or through the command line as seen here. You already do the latter as covered in your question, as you revert the edited and deleted files. Added files are trickier. The second link would have you do the following.

find . -type f -print | p4 -x - add
find . -type l -print | p4 -x - add

to add files and symlinks in Unix

The tricky part is physically removing the files you've added. This isn't pretty, but I think it would work. p4 opened | grep add | cut -f1 -d"#" | p4 -x- where | cut -f3 -d" "

Then you need to do a

p4 revert directory/...

or do something similar to that above when removing files.

Chance
A: 

I needed this for a build server with svn. What I did in the end was:

  • Update the workspace
  • Delete the old “build folder” if there is one
  • Xcopy the workspace to the “build folder”
  • Do the build in the “build folder”

That way I knew there was nothing for an old build hanging about.

Ian Ringrose