Browse Source

new scirpt to fix patch names based on check-in comments

Bill Gianopoulos 3 years ago
parent
commit
c243e574e8
1 changed files with 56 additions and 0 deletions
  1. 56 0
      scripts/fix-patchnames.pl

+ 56 - 0
scripts/fix-patchnames.pl

@@ -0,0 +1,56 @@
+#!/bin/perl
+$VERSION="57a1";
+$DEBUG=true;
+
+$LAST_BUG="";
+
+$PREFIX="# " if $DEBUG;
+
+while (<>) {
+    chomp;
+    $oldname=$_;
+    open(PATCH, "<$oldname")  || die "Couldn't open file $oldname";
+    while (<PATCH>) {
+        if (!/^[#] /) {
+            if (/^[Bb][Uu][Gg] ([0-9]*)/) {
+                $BUG=$1;
+                if ($BUG eq $LAST_BUG) {
+                    $PATCH+=1;
+                }
+                else {
+                    $LAST_BUG=$BUG;
+                    $PATCH=1;
+                }
+                if ($PATCH == 1) {
+                    print "${PREFIX}hg qrename $oldname $BUG-$VERSION.patch\n";
+                }
+                else {
+                    print "${PREFIX}hg qrename $oldname $BUG-$PATCH-$VERSION.patch\n";
+                }
+                close PATCH;
+            }
+            elsif (/^servo: Merge #([0-9]*)/) {
+                $BUG="servo-$1";
+                if ($BUG eq $LAST_BUG) {
+                    $PATCH+=1;
+                }
+                else {
+                    $LAST_BUG=$BUG;
+                    $PATCH=1;
+                }
+                if ($PATCH == 1) {
+                    print "${PREFIX}hg qrename $oldname $BUG-$VERSION.patch\n";
+                }
+                else {
+                    print "${PREFIX}hg qrename $oldname $BUG-$PATCH-$VERSION.patch\n";
+                }
+                close PATCH;
+            }
+            else {
+                print STDERR "cannot determine new filename for $oldname\n";
+                print "# cannot determine new filename for $oldname\n";
+                print $_;
+            }
+        }
+    }
+}