fix-patchnames.pl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/perl
  2. $VERSION="57a1";
  3. $DEBUG=true;
  4. $LAST_BUG="";
  5. $PREFIX="# " if $DEBUG;
  6. while (<>) {
  7. chomp;
  8. $oldname=$_;
  9. open(PATCH, "<$oldname") || die "Couldn't open file $oldname";
  10. while (<PATCH>) {
  11. if (!/^[#] /) {
  12. if (/^[Bb][Uu][Gg] ([0-9]*)/) {
  13. $BUG=$1;
  14. if ($BUG eq $LAST_BUG) {
  15. $PATCH+=1;
  16. }
  17. else {
  18. $LAST_BUG=$BUG;
  19. $PATCH=1;
  20. }
  21. if ($PATCH == 1) {
  22. print "${PREFIX}hg qrename $oldname $BUG-$VERSION.patch\n";
  23. }
  24. else {
  25. print "${PREFIX}hg qrename $oldname $BUG-$PATCH-$VERSION.patch\n";
  26. }
  27. close PATCH;
  28. }
  29. elsif (/^servo: Merge #([0-9]*)/) {
  30. $BUG="servo-$1";
  31. if ($BUG eq $LAST_BUG) {
  32. $PATCH+=1;
  33. }
  34. else {
  35. $LAST_BUG=$BUG;
  36. $PATCH=1;
  37. }
  38. if ($PATCH == 1) {
  39. print "${PREFIX}hg qrename $oldname $BUG-$VERSION.patch\n";
  40. }
  41. else {
  42. print "${PREFIX}hg qrename $oldname $BUG-$PATCH-$VERSION.patch\n";
  43. }
  44. close PATCH;
  45. }
  46. else {
  47. print STDERR "cannot determine new filename for $oldname\n";
  48. print "# cannot determine new filename for $oldname\n";
  49. close PATCH;
  50. }
  51. }
  52. }
  53. }