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.

142 lines
2.8 KiB

  1. # __________________________________________________________________________________
  2. #
  3. # Purpose:
  4. # PERL Script to rename a file in the Perforce database
  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
  23. #
  24. if ($Usage or $InvalidFlag)
  25. {
  26. print $ErrorMessage;
  27. &Usage;
  28. exit 1;
  29. }
  30. #
  31. # Recursive flag not supported
  32. #
  33. if ($Recursive)
  34. {
  35. print "\n";
  36. print "Error: This command does not work recursively\n";
  37. print "\n";
  38. &Usage;
  39. exit 1;
  40. }
  41. #
  42. # Need to have a file list
  43. #
  44. if (!@FileList)
  45. {
  46. print "\n";
  47. print "Error: No files specified\n";
  48. print "\n";
  49. &Usage;
  50. exit 1;
  51. }
  52. #
  53. # Need to have exactly two files in @FileList
  54. #
  55. if (@FileList != 2)
  56. {
  57. print "\n";
  58. print "Error: Must have two files specified on command line\n";
  59. print "\n";
  60. &Usage;
  61. exit 1;
  62. }
  63. #
  64. # Wildcards and subdirectories are not supported
  65. #
  66. if ((grep { /\*/ } @FileList) or (grep { /\?/ } @FileList))
  67. {
  68. print "\n";
  69. print "Error: Wildcards are not supported\n";
  70. print "\n";
  71. &Usage;
  72. exit 1;
  73. }
  74. if (grep { /\\/ } @FileList)
  75. {
  76. print "\n";
  77. print "Error: Subdirectories are not supported\n";
  78. print "\n";
  79. &Usage;
  80. exit 1;
  81. }
  82. #
  83. # Need to make sure first file exists
  84. #
  85. open EXISTINGFILE, "< $FileList[0]";
  86. if (! EXISTINGFILE)
  87. {
  88. print "\n";
  89. print "Error: Cannot find file $FileList[0]\n";
  90. print "\n";
  91. &Usage;
  92. exit 1;
  93. }
  94. else
  95. {
  96. close EXISTINGFILE;
  97. }
  98. #
  99. # Initialize lists
  100. #
  101. @SubmitList = ();
  102. system "$SourceControlClient integrate $FileList[0] $FileList[1]";
  103. system "$SourceControlClient delete $FileList[0]";
  104. SlmSubs::CreateSubmitList("branch", \@SubmitList);
  105. SlmSubs::CreateSubmitList("delete", \@SubmitList);
  106. @SubmitOutput = SlmSubs::PerforceRequest("submit", \@SubmitList);
  107. print "@SubmitOutput";
  108. sub Usage
  109. # __________________________________________________________________________________
  110. #
  111. # Prints out a usage statement for this script. In this case an amalgamation of
  112. # basic SLM command usage
  113. #
  114. # Parameters:
  115. # None
  116. #
  117. # Output:
  118. # The usage statement
  119. #
  120. # __________________________________________________________________________________
  121. {
  122. print q/redub - renames a file in the source database
  123. Usage: redub [-?fh] file1 file2
  124. Arguments:
  125. -h prints out this message.
  126. file1 Name of file to be renamed.
  127. file2 New name for renamed file.
  128. /;
  129. }