Team Fortress 2 Source Code as on 22/4/2020
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.

78 lines
1.8 KiB

  1. # usage: recentchanges.pl <changelist number> <filespec>
  2. #
  3. # Outputs changelist notes for changelists starting at the changelist number until now
  4. # that involve files in the filespec, grouped by user.
  5. #
  6. # Output file is recentchanges.txt, output to the current working dir.
  7. BEGIN {use File::Basename; push @INC, dirname($0); }
  8. require "valve_perl_helpers.pl";
  9. # take in the revision number we want and the filespec to look at
  10. my $from_changelist = shift;
  11. my $branch = shift;
  12. if ( length($from_changelist) < 1 || length($branch) < 1 )
  13. {
  14. die "usage: recentchanges.pl <'from' changelist number> <filespec>";
  15. }
  16. my $cmd = "p4 changes -l $branch\@$from_changelist,\@now";
  17. my @fstat = &RunCommand( $cmd );
  18. my $lastuser;
  19. my %changes;
  20. foreach $line ( @fstat )
  21. {
  22. #if the line starts with "Change"
  23. #then store the user, all lines after this are changes by this user
  24. if ( $line =~ m/^Change/ )
  25. {
  26. my $data = 'Change (1234) on (date) by (name)@(clientspec)';
  27. my @values = split(' ', $line);
  28. @usersplit = split('@', $values[5]);
  29. $lastuser = $usersplit[0];
  30. }
  31. else
  32. {
  33. #this is a change line, associate it with the user in our %changes hash
  34. chomp($line);
  35. # skip empty and 'merge from main' lines
  36. if ( length($line) > 0 && $line !~ m/Merge from main/ )
  37. {
  38. #strip leading whitespace
  39. $line =~ s/^\s+//;
  40. # if the first char is not '-', add '- ' to the front
  41. if ( $line !~ m/^-/ )
  42. {
  43. $line = "- $line";
  44. }
  45. push @{ $changes{$lastuser} }, $line;
  46. }
  47. }
  48. }
  49. chdir();
  50. open(OUTFILE, ">recentchanges.txt");
  51. foreach $user ( keys %changes )
  52. {
  53. print "$user\n";
  54. print OUTFILE "$user\n";
  55. foreach $i ( 0 .. $#{ $changes{$user} } )
  56. {
  57. print "$changes{$user}[$i]\n";
  58. print OUTFILE "$changes{$user}[$i]\n";
  59. }
  60. print "\n";
  61. print OUTFILE "\n";
  62. }
  63. close(OUTFILE);