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.

195 lines
4.1 KiB

  1. # __________________________________________________________________________________
  2. #
  3. # Purpose:
  4. # PERL Script to emulate windiff's SLM interaction
  5. #
  6. # Parameters:
  7. # Standard windiff parameters
  8. #
  9. # Output:
  10. # Windiff output
  11. #
  12. # __________________________________________________________________________________
  13. #
  14. # Load common SLM wrapper subroutine module
  15. #
  16. use SlmSubs;
  17. #
  18. # Set callee because windiff has some overlapping syntax with SLM
  19. #
  20. $Callee = "windiff.pl";
  21. #
  22. # Parse command line arguments
  23. #
  24. SlmSubs::ParseArgs(@ARGV);
  25. #
  26. # If -L switch isn't used or there are no version references call windiff without re-interpreting
  27. #
  28. if ((! ($Library or $FileVersion)) or $Usage)
  29. {
  30. system "windiff @ARGV";
  31. exit 1;
  32. }
  33. #
  34. # Recursion is not supported
  35. #
  36. if ($WindiffRecursive)
  37. {
  38. print "\n";
  39. print "Error: sudirectory option not supported\n";
  40. print "\n";
  41. exit 1;
  42. }
  43. #
  44. # Initialize Variables
  45. #
  46. $FileNameOne = "";
  47. $FileNameTwo = "";
  48. $WindiffSyntax = "";
  49. if ($OutlineView)
  50. {
  51. $WindiffSyntax .= " -O";
  52. }
  53. if ($PerverseComparison)
  54. {
  55. $WindiffSyntax .= " -P";
  56. }
  57. if ($NetSend)
  58. {
  59. $WindiffSyntax .= " -N $NetSendTarget";
  60. }
  61. if ($SaveList)
  62. {
  63. $WindiffSyntax .= " -s";
  64. if ($SaveListDifferent)
  65. {
  66. $WindiffSyntax .= "d";
  67. }
  68. if ($SaveListExit)
  69. {
  70. $WindiffSyntax .= "x";
  71. }
  72. if ($SaveListLeft)
  73. {
  74. $WindiffSyntax .= "l";
  75. }
  76. if ($SaveListRight)
  77. {
  78. $WindiffSyntax .= "r";
  79. }
  80. if ($SaveListSame)
  81. {
  82. $WindiffSyntax .= "s";
  83. }
  84. $WindiffSyntax .= " $SaveListName";
  85. }
  86. #
  87. # Create space to pull down files for compare
  88. #
  89. system "md $ENV{tmp}\\$SourceControlClient > nul 2>&1";
  90. system "del $ENV{tmp}\\$SourceControlClient\\**";
  91. if (@FileList)
  92. {
  93. #
  94. # @FileList should only have one element if using -L, if not launch windiff -?
  95. # if so set $FileName equal to first element.
  96. #
  97. if ($Library and (@FileList > 1))
  98. {
  99. system "windiff -?";
  100. exit 1;
  101. }
  102. #
  103. # @FileList should only have two elements if file versions, if not launch windiff -?
  104. # if so set $FileNameOne equal to first element and $FileNameTwo to the second.
  105. #
  106. if ($FileVersion and ((@FileList > 2) or (@FileList < 2)))
  107. {
  108. system "windiff -?";
  109. exit 1;
  110. }
  111. $FileNameOne = $FileList[0];
  112. if ($Library or ($FileVersion and ($FileNameOne =~ /#\d+/)))
  113. {
  114. system qq/$SourceControlClient print -q $FileNameOne > "$ENV{tmp}\\$SourceControlClient\\$FileNameOne"/;
  115. $FirstArg = "$ENV{tmp}\\$SourceControlClient\\$FileNameOne";
  116. }
  117. else
  118. {
  119. $FirstArg = $FileNameOne
  120. }
  121. if (!$Library and $FileVersion)
  122. {
  123. $FileNameTwo = $FileList[1];
  124. if ($FileNameTwo =~ /#\d+/)
  125. {
  126. system qq/$SourceControlClient print -q $FileNameTwo > "$ENV{tmp}\\$SourceControlClient\\$FileNameTwo"/;
  127. $SecondArg = "$ENV{tmp}\\$SourceControlClient\\$FileNameTwo";
  128. }
  129. else
  130. {
  131. $SecondArg = $FileNameTwo;
  132. }
  133. }
  134. else
  135. {
  136. $SecondArg = $FileNameTwo;
  137. }
  138. }
  139. else
  140. {
  141. open (P4Files, "$SourceControlClient files $AllFilesSymbol 2>&1|");
  142. @P4FilesList = <P4Files>;
  143. close (P4Files);
  144. #
  145. # Cycle through @P4Files list and copy them to %tmp%\$SourceControlClient
  146. #
  147. foreach $P4FilesLine (@P4FilesList)
  148. {
  149. #
  150. # Grep current directory information out of output
  151. #
  152. if ( $P4FilesLine =~ /(.*\Q$DepotMap\E)([^#]*)#[0-9]* - (\S*).*/i )
  153. {
  154. if ($3 ne "delete")
  155. {
  156. system qq/$SourceControlClient print -q "$1$2" > "$ENV{tmp}\\$SourceControlClient\\$2"/;
  157. }
  158. }
  159. }
  160. $FirstArg = ".";
  161. $SecondArg = "$ENV{tmp}\\$SourceControlClient";
  162. }
  163. if ( $Reverse)
  164. {
  165. system "windiff -D $WindiffSyntax $SecondArg $FirstArg";
  166. }
  167. else
  168. {
  169. system "windiff -D $WindiffSyntax $FirstArg $SecondArg";
  170. }