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.

77 lines
1.5 KiB

  1. @echo off
  2. setlocal
  3. if "%1" == "" goto usage
  4. rem -- detect whether 4Dos/NT or CMD is the shell
  5. if %@eval[2+2] == 4 goto altshell
  6. rem -- iterate thru specified files, with CMD
  7. for /f "tokens=1,2 delims=-" %%i in ("x%1") do (set back=%%j&set beg=%%i)
  8. if not "%beg%" == "x" goto usage
  9. if "%back%" == "" goto usage
  10. set /a bogus=back
  11. if not "%bogus%" == "%back%" goto usage
  12. shift
  13. if not "%2" == "" goto usage
  14. for /f "tokens=1,2 delims=#" %%i in ('sd files %1') do call :doit %1 %%j
  15. goto :eof
  16. :doit
  17. @echo off
  18. rem -- subroutine: do appropriate diffs
  19. for /f "tokens=1,2" %%i in ("%2") do set head=%%i
  20. set /a beg=head - back
  21. :loopbeg
  22. set /a rev=beg
  23. set /a beg=beg + 1
  24. sd diff2 %1#%rev% %1#%beg%
  25. if not %beg% == %2 goto loopbeg
  26. goto :eof
  27. :altshell
  28. rem -- iterate thru specified files, with 4Dos/NT
  29. iff %@left[1,%1] == - then
  30. set back=%@eval[0-(0%1)]
  31. if %back == 0 goto usage
  32. shift
  33. else
  34. goto usage
  35. endiff
  36. if not "%2" == "" goto usage
  37. set SDCOMPTMPFILE=%temp%\~sdcomp.tmp
  38. sd files %1 > %SDCOMPTMPFILE%
  39. for /f "tokens=1,2 delims=#" %%i in ( %SDCOMPTMPFILE% ) do gosub perfile
  40. *del /q %SDCOMPTMPFILE%
  41. goto :eof
  42. :perfile
  43. @echo off
  44. rem -- subroutine: do appropriate diffs
  45. set head=%@word[0,%j]
  46. set beg=%@eval[%head - %back + 1]
  47. do rev = %beg to %head
  48. sd diff2 %1#%@dec[%rev] %1#%rev
  49. enddo
  50. return
  51. :usage
  52. echo SDCOMP - emulate subset of scomp for use with Source Depot.
  53. echo Syntax: SDCOMP -n filespec
  54. echo Works backward, getting the last n diffs to filespec.