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.

121 lines
3.4 KiB

  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. for /f %%a in ('echo %0') do set SCRIPT_NAME=%%~na
  4. set LOGFILE=%tmp%\%SCRIPT_NAME%.log
  5. REM first, parse command line
  6. set DoNothing=
  7. set LabName=
  8. set TimeStamp=
  9. set DoResolve=
  10. :SwitchLoop
  11. for %%a in (./ .- .) do if ".%1." == "%%a?." goto :Usage
  12. if "%1" == "" goto :EndSwitchLoop
  13. for /f "tokens=1* delims=:" %%a in ('echo %1') do (
  14. set Switch=%%a
  15. set Arg=%%b
  16. for %%c in (./ .-) do (
  17. if ".!Switch!." == "%%cn." (set DoNothing=TRUE&&goto :ShiftArg)
  18. if ".!Switch!." == "%%cb." (set BranchName=!Arg!&&goto :ShiftArg)
  19. if ".!Switch!." == "%%ct." (set TimeStamp=!Arg!&&goto :ShiftArg)
  20. if ".!Switch!." == "%%ca." (set DoResolve=TRUE&&goto :ShiftArg)
  21. )
  22. REM if we're here, we didn't encounter any switches and thus we have
  23. REM an unrecognized argument
  24. goto :Usage
  25. )
  26. :ShiftArg
  27. shift
  28. goto :SwitchLoop
  29. :EndSwitchLoop
  30. if not defined BranchName (
  31. call errmsg.cmd "Must supply a branch name."
  32. goto :Usage
  33. )
  34. call logmsg.cmd "Starting ..."
  35. set /a ExitCode=0
  36. REM
  37. REM first, read depots from sd.map
  38. REM
  39. REM generate the project list from sd.map
  40. set ReadFlag=FALSE
  41. set ProjectList=
  42. for /f "tokens=1,2 delims==" %%a in (%SDXROOT%\sd.map) do (
  43. set TokenOne=%%a
  44. set TokenTwo=%%b
  45. set TokenOne=!TokenOne: =!
  46. set TokenTwo=!TokenTwo: =!
  47. if /i "!TokenOne!" == "DEPOTS" set ReadFlag=FALSE
  48. if "!TokenOne:~0,1!" NEQ "#" (
  49. if "!TokenTwo!" NEQ "" (
  50. if "!ReadFlag!" == "TRUE" (
  51. if defined ProjectList (
  52. set ProjectList=!ProjectList! !TokenOne!-!TokenTwo!
  53. ) else (
  54. set ProjectList=!TokenOne!-!TokenTwo!
  55. )
  56. )
  57. )
  58. )
  59. if /i "!TokenOne!" == "CLIENT" set ReadFlag=TRUE
  60. if /i "%%a" == "# depots" set ReadFlag=FALSE
  61. )
  62. REM
  63. REM now, ProjectList contains all depots we need to work on
  64. REM
  65. set SDCommand=sd integrate
  66. set SDCommand=%SDCommand% -t -b %BranchName%
  67. if /i "%BranchName%" NEQ "%_BuildBranch%" (
  68. call logmsg.cmd "Branch name is not current branch, assuming -r integration ..."
  69. set SDCommand=%SDCommand% -r ...
  70. )
  71. if defined TimeStamp set SDCommand=%SDCommand% %TimeStamp%
  72. if defined DoResolve (
  73. set SDCommand=%SDCommand% ^&^& sd resolve -at ... ^&^& sd resolve -n ...
  74. )
  75. echo The SDCommand is "%SDCommand%"
  76. echo.
  77. for %%a in (%ProjectList%) do (
  78. for /f "tokens=1,2 delims=-" %%b in ('echo %%a') do (
  79. if defined DoNothing (
  80. echo pushd %SDXROOT%\%%c
  81. echo !SDCommand!
  82. echo.
  83. ) else (
  84. start "%%b Integrating" cmd /k "pushd %SDXROOT%\%%c && %SDCommand%"
  85. )
  86. )
  87. )
  88. :End
  89. call logmsg.cmd "Finished."
  90. if !ExitCode! GTR 0 call logmsg.cmd "See %LOGFILE% for details."
  91. endlocal
  92. goto :EOF
  93. :Usage
  94. echo %0 ^<-b:branch^> [-t:timestamp] [-a] [-n]
  95. echo.
  96. echo -b:branch perform integration for given branch
  97. echo -t:timestamp integrate to given timestamp
  98. echo -a automatically resolve using -at
  99. echo -n do nothing, only show what would be done
  100. echo.
  101. echo This will perform a parallel integration of the given lab name
  102. echo which must be of the form Lab01_n. The timestamp, if given
  103. echo must be of the form @2000/07/12:22:00:00.
  104. echo.
  105. echo Using the -a flag will additionally perform a resolve -at and
  106. echo then a resolve -n.
  107. echo.
  108. goto :End