Syncing missing/modified files to a specific version in Perforce
I think this is the 5th time I've had to figure this out in the past few years, so this time I'm going to preserve it here for posterity :)The problem is usually one or more of:
set LABEL=@SOME_LABEL
set BASE_DIR=//depot/path/...del p4sync.txtecho Setting 'have' to %LABEL% for %BASE_DIR%
REM do a nop sync that sets our 'have' version to the label we want
p4 sync -k %BASE_DIR%%LABEL%echo Finding modified files..
p4 diff -se %BASE_DIR%%LABEL% > p4diff.txtecho Finding missing files..
p4 diff -sd %BASE_DIR%%LABEL% >> p4diff.txtecho Building sync commands
REM Append #have to each filename and put them all in a list of files to sync
for /f %%i in (p4diff.txt) Do echo %%i#have>> p4sync.txt REM Now sync everything
if exist p4sync.txt (
echo Syncing..
p4 -x p4sync.txt sync -f
)else (
echo It seems no files need updated!
)Voila!
- You have files missing from your workspace that need replaced.
- You have locally modified (i.e. not opened for edit) files that need replaced.
- These files are large in either size or number, and on a slow or remote server, so a complete force-sync is not an appealing option.
set LABEL=@SOME_LABEL
set BASE_DIR=//depot/path/...del p4sync.txtecho Setting 'have' to %LABEL% for %BASE_DIR%
REM do a nop sync that sets our 'have' version to the label we want
p4 sync -k %BASE_DIR%%LABEL%echo Finding modified files..
p4 diff -se %BASE_DIR%%LABEL% > p4diff.txtecho Finding missing files..
p4 diff -sd %BASE_DIR%%LABEL% >> p4diff.txtecho Building sync commands
REM Append #have to each filename and put them all in a list of files to sync
for /f %%i in (p4diff.txt) Do echo %%i#have>> p4sync.txt REM Now sync everything
if exist p4sync.txt (
echo Syncing..
p4 -x p4sync.txt sync -f
)else (
echo It seems no files need updated!
)Voila!



