Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
5.8 KiB

  1. @echo off
  2. rem --------------------------------------------
  3. rem Forced source depot sync utility v1.0 (fsds)
  4. rem
  5. rem Created by: karolk
  6. rem Last modified: 1/8/03
  7. rem Componenets: fsds.cmd (this file)
  8. rem --------------------------------------------
  9. echo Forced source depot sync utility v1.0
  10. echo.
  11. rem +=+=+=+=+=+=+=+=+=+=
  12. rem Start of main script
  13. rem +=+=+=+=+=+=+=+=+=+=
  14. rem -----------
  15. rem Preparation
  16. rem -----------
  17. pushd
  18. setlocal
  19. SETLOCAL ENABLEDELAYEDEXPANSION
  20. set suberror=
  21. rem ---------------------------------
  22. rem Processing command line arguments
  23. rem ---------------------------------
  24. :CmdArgs
  25. if "%1"=="" goto :ArgsDone
  26. if "%1"=="/h" goto :DisplayUsage
  27. if "%1"=="-h" goto :DisplayUsage
  28. if "%1"=="/?" goto :DisplayUsage
  29. if "%1"=="-?" goto :DisplayUsage
  30. call :ProcessArg %1
  31. if /i "%suberror%"=="true" goto :exit
  32. set suberror=
  33. shift
  34. goto :CmdArgs
  35. :ArgsDone
  36. rem --------------
  37. rem Error checking
  38. rem --------------
  39. if not exist %SDXROOT%\sd.map goto :nosdmap
  40. rem ----------------------------------------
  41. rem Get the list of depots into ListedDepots
  42. rem ----------------------------------------
  43. set ListedDepots=
  44. set isDepot=false
  45. for /f "tokens=1,2 delims== " %%i in (%SDXROOT%\sd.map) do (
  46. if /i "!isDepot!"=="true" (
  47. if /i "%%i"=="#" set isDepot=false
  48. )
  49. if /i "!isDepot!"=="true" set ListedDepots=!ListedDepots! %%j
  50. if /i "!isDepot!"=="false" (
  51. if /i "%%j"=="-------------------" set isDepot=true
  52. )
  53. )
  54. echo Depots enlisted on this machine:
  55. echo --------------------------------
  56. for %%i in (%ListedDepots%) do echo * %%i
  57. echo.
  58. rem --------------------------------------------
  59. rem Nothing specified, everything will be synced
  60. rem --------------------------------------------
  61. set SyncedDepots=%ListedDepots%
  62. rem -----------------------
  63. rem Single depot specified?
  64. rem -----------------------
  65. if NOT "%SingleDepot%"=="" (
  66. set SyncedDepots=
  67. call :CheckDepot %SingleDepot%
  68. if /i "%suberror%"=="true" goto :exit
  69. set suberror=
  70. set SyncedDepots=%SingleDepot%
  71. )
  72. rem ------------------
  73. rem Restart specified?
  74. rem ------------------
  75. if NOT "%RestartDepot%"=="" (
  76. set SyncedDepots=
  77. call :CheckDepot %RestartDepot%
  78. if /i "%suberror%"=="true" goto :exit
  79. set suberror=
  80. set foundinlist=
  81. for %%i in (%SyncedDepots%) do (
  82. if /i "%%i"=="%RestartDepot%" set foundinlist=true
  83. if /i "!foundinlist!"=="true" set SyncedDepots=!SyncedDepots! %%i
  84. )
  85. )
  86. echo Depots to be syncronized on this machine:
  87. echo -----------------------------------------
  88. for %%i in (%SyncedDepots%) do echo * %%i
  89. echo.
  90. rem ------------------------
  91. rem Full syncing the machine
  92. rem ------------------------
  93. echo Full syncing this machine...
  94. echo.
  95. start /wait /min cmd /c %RazzleToolPath%\postbuildscripts\fullsync.cmd
  96. rem ------------------------------------
  97. rem Reverting open files on this machine
  98. rem ------------------------------------
  99. echo Reverting open files on this machine...
  100. start /wait /min cmd /c %RazzleToolPath%\sdx.cmd revert ...
  101. echo.
  102. rem ---------------------
  103. rem Processing each depot
  104. rem ---------------------
  105. echo Syncing out-of-date files in ...
  106. for %%i in (%SyncedDepots%) do (
  107. if exist %SDXROOT%\%%i (
  108. cd /d %SDXROOT%\%%i
  109. echo ... %SDXROOT%\%%i:
  110. sd diff -sE | sd -x - sync -f
  111. ) else (
  112. echo Could not find %SDXROOT%\%%i - skipped
  113. )
  114. )
  115. goto :exit
  116. :exit
  117. rem -------
  118. rem clenaup
  119. rem -------
  120. popd
  121. endlocal
  122. goto :EOF
  123. rem +=+=+=+=+=+=+=+=+=
  124. rem End of main script
  125. rem +=+=+=+=+=+=+=+=+=
  126. rem +=+=+=+=+=+
  127. rem Subroutines
  128. rem +=+=+=+=+=+
  129. rem --------------------------------
  130. rem Processing one cmd line argument
  131. rem --------------------------------
  132. :ProcessArg
  133. set suberror=
  134. for /f "tokens=1,2 delims=:" %%i in ("%1") do (
  135. if "%%i"=="-s" (
  136. if "%%j"=="" goto :MissingParam %%i
  137. if not "%RestartDepot%"=="" goto :BothSpecified
  138. set SingleDepot=%%j
  139. goto :EOF
  140. )
  141. if "%%i"=="/s" (
  142. if "%%j"=="" goto :MissingParam %%i
  143. if not "%RestartDepot%"=="" goto :BothSpecified
  144. set SingleDepot=%%j
  145. goto :EOF
  146. )
  147. if "%%i"=="-r" (
  148. if "%%j"=="" goto :MissingParam %%i
  149. if not "%SingleDepot%"=="" goto :BothSpecified
  150. set RestartDepot=%%j
  151. goto :EOF
  152. )
  153. if "%%i"=="/r" (
  154. if "%%j"=="" goto :MissingParam %%i
  155. if not "%SingleDepot%"=="" goto :BothSpecified
  156. set RestartDepot=%%j
  157. goto :EOF
  158. )
  159. goto :IncorrectSwitch %%i
  160. )
  161. goto :EOF
  162. rem -------------------------
  163. rem Check depot in depot list
  164. rem -------------------------
  165. :CheckDepot
  166. set ValidDepot=
  167. for %%i in (%ListedDepots%) do if /i "%1"=="%%i" goto :EOF
  168. goto :InvalidDepot %1
  169. goto :EOF
  170. :DisplayUsage
  171. echo Diffs and forced syncs all enlited or the secified depot(s) on this machine
  172. echo.
  173. echo fsds.cmd [-s:depotname ^| -b:depotname]
  174. echo.
  175. echo -s:depotname Runs only for the specified (single) depot.
  176. echo The 'depotname' depot must be enlisted on this machine.
  177. echo -r:depotname Run restarts at the specified depot. Use this command to
  178. echo resume the execution if the command previously was stopped.
  179. echo The 'depotname' depot must be enlisted on this machine.
  180. echo.
  181. echo Running the command without parameters will force sync all enlisted depots.
  182. echo.
  183. goto :exit
  184. rem +=+=+=+=+=+=+=
  185. rem Error Handlers
  186. rem +=+=+=+=+=+=+=
  187. :nosdmap
  188. echo Could not find sd.map exiting
  189. goto :exit
  190. :MissingParam
  191. echo Missing paramater for the '%1' switch
  192. set suberror=true
  193. goto :EOF
  194. :IncorrectSwitch
  195. echo Incorrect switch: '%1'
  196. set suberror=true
  197. goto :EOF
  198. :BothSpecified
  199. echo Both '-s' and '-r' switches are specified. Please specify only one of them
  200. set suberror=true
  201. goto :EOF
  202. :InvalidDepot
  203. echo The specified depot '%1' is not listed in SD.MAP
  204. set suberror=true
  205. goto :EOF