Source code of Windows XP (NT5)
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.

150 lines
3.5 KiB

  1. # __________________________________________________________________________________
  2. #
  3. # Purpose:
  4. # PERL Script to emulate SLM's 'in' command
  5. #
  6. # Parameters:
  7. # See Usage below
  8. #
  9. # Output:
  10. # Perforce output or the appropriate error message or usage statement
  11. #
  12. # __________________________________________________________________________________
  13. #
  14. # Load common SLM wrapper subroutine module
  15. #
  16. use SlmSubs;
  17. #
  18. # Parse command line arguments
  19. #
  20. SlmSubs::ParseArgs(@ARGV);
  21. #
  22. # Call usage and exit if ParseArgs has set the Usage or InvalidFlag flags or there
  23. # were no arguments given
  24. #
  25. if ($Usage or $InvalidFlag or $NoArgumentsGiven)
  26. {
  27. print $ErrorMessage;
  28. &Usage;
  29. exit 1;
  30. }
  31. #
  32. # Need to either have a file list or use -o for all out of date files
  33. #
  34. if ((!@FileList) and (!@DirList) and (!$OutOfDateFiles))
  35. {
  36. print "\n";
  37. print "Error: no files specified\n";
  38. print "\n";
  39. &Usage;
  40. exit 1;
  41. }
  42. #
  43. # If -i switch used, invoke $SourceControlClient revert otherwise use $SourceControlClient submit
  44. #
  45. if ($Ignore)
  46. {
  47. if ($OutOfDateFiles)
  48. {
  49. system "$SourceControlClient revert $AllFilesSymbol";
  50. }
  51. else
  52. {
  53. system "$SourceControlClient revert @FileList @DirList";
  54. }
  55. }
  56. else
  57. {
  58. #
  59. # Initialize lists
  60. #
  61. @OutFilesList = ();
  62. #
  63. # Revert files that haven't changed
  64. #
  65. if ($OutOfDateFiles)
  66. {
  67. system ("$SourceControlClient diff -sr $AllFilesSymbol | $SourceControlClient -x - revert");
  68. }
  69. else
  70. {
  71. system ("$SourceControlClient diff -sr @FileList @DirList | $SourceControlClient -x - revert");
  72. }
  73. #
  74. # Get descriptions for all the changes in @CurrentChangeNumberList
  75. #
  76. if ($OutOfDateFiles)
  77. {
  78. open(OPENEDOUTPUT, "$SourceControlClient opened $AllFilesSymbol 2>nul|");
  79. }
  80. else
  81. {
  82. open(OPENEDOUTPUT, "$SourceControlClient opened @FileList @DirList 2>nul|");
  83. }
  84. #
  85. # Initialize variables
  86. #
  87. $OpenedFile = "";
  88. %OpenedListHash = ();
  89. OpenedLoop: while ( $OpenedLine = <OPENEDOUTPUT>)
  90. {
  91. $OpenedLine =~ /^(.*)#\d+ - .*$/;
  92. $OpenedFile = $1;
  93. #
  94. # Check if there is already a record for this OpenedFile
  95. #
  96. if ($OpenedListHash{$OpenedFile})
  97. {
  98. next OpenedLoop
  99. }
  100. push @OutFilesList, "\t$OpenedFile # edit\n";
  101. $OpenedListHash{$DiffFile}++;
  102. }
  103. close(OPENEDOUTPUT);
  104. if (@OutFilesList)
  105. {
  106. @SubmitOutput = SlmSubs::PerforceRequest("submit", \@OutFilesList);
  107. print "@SubmitOutput";
  108. }
  109. }
  110. sub Usage
  111. # __________________________________________________________________________________
  112. #
  113. # Prints out a usage statement for this script. In this case usurped from SLM's
  114. # 'in' usage statement
  115. #
  116. # Parameters:
  117. # None
  118. #
  119. # Output:
  120. # The usage statement
  121. #
  122. # __________________________________________________________________________________
  123. {
  124. print q/in - checks in project file(s)
  125. Usage: in [-?fhrio] [-c comment] [file1] [file2... ]
  126. Arguments:
  127. -h prints out this message.
  128. -r (recursive) checks in all files in a given directory and in every
  129. subdirectory beneath it. If a pattern is given, matches the pattern.
  130. -i (ignore) ignores all changes to the file when checking it in, discards
  131. the local version, and reverts to the version that was checked out.
  132. -o checks in ALL files currently checked out in the specified directories.
  133. -c supplies the same comment for all files (otherwise, you are prompted
  134. for one).
  135. /;
  136. }