Migrating quick catalog synchronization to pure state

I want a quick solution that does not require power synchronization, which will put the specified directory in the initial state of the repository.

  • the same files can be deleted from disk
  • the same files can be added from disk
  • some files may be modified on disk
  • some files may be marked for deletion, addition or alteration in perforce

All I want to do is make sure that after executing the command I will not have any of this.

p4 -f sync not an option, I need a faster solution that minimizes network usage.

Just in case someone asks, the proxy server is not discussed.

I know the partial solution is:

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

The problem is that this does not delete files added to the above tracks that are not in the perforce files that I want to delete from disk.

In addition, I need a multi-board or cross-platform solution - it should work on Windows, OS X and Linux.

+7
perforce
source share
4 answers

Perforce added the new β€œp4 clean” command in 2014.1, which does exactly what you are looking for by resetting your workspace to #have state:

  • New files not included in Perforce will be deleted.
  • Files modified outside of Perforce control will be reset
  • Files deleted outside Perforce control will be recovered.

The command is an alias for "p4 reconcile -w" and uses a hash file to determine its state in your workspace.

+5
source share

Another Unix / Linux snippet that should delete all files that were never tracked by perforce:

find . -type f | p4 -x- files 2>&1 | sed -n -e 's/ - no such file(s).//p' | xargs -d '\n' rm

+2
source share

If you have Unix / Linux, this might work.

In Perforce, you can "Reconcile Offline Work" via p4v, as shown here or through the command line, as shown here. You already do the latter, as described in your question, when you return the edited and deleted files. Added files are more complicated. The second link will force you to do the following.

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

add files and symbolic links to Unix

The hard part is the physical deletion of the files you added. This is ugly, but I think it will work. p4 open | grep add | cut -f1 -d "#" | p4 -x- where | cut -f3 -d ""

Then you need to do

 p4 revert directory/... 

or do something similar to what was higher when deleting files.

0
source share

I need this for a build server with svn. In the end, I did the following:

  • Update workspace
  • Delete the old "build" folder, if any
  • Xcopy workspace to the "build" folder
  • Build in the "build" folder

Thus, I knew that nothing exists for an old building that hangs.

0
source share

All Articles