chiark / gitweb /
migrate_tree.pl: Add a signal handler, so the commit file is updated even on SIGINT.
authorSven Eden <yamakuzure@gmx.net>
Wed, 16 May 2018 06:06:32 +0000 (08:06 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 16 May 2018 06:06:32 +0000 (08:06 +0200)
pwx/last_mutual_commits.csv
pwx/migrate_tree.pl

index 3f33b60b123b7a60cd6783a82e8ba4556d1e890d..5ec52a7e3bff5664d91dda392cfc8b9ada8b1561 100644 (file)
@@ -1,14 +1,14 @@
 # Automatically generated commit information
 # Only edit if you know what these do!
 
-../systemd-upstream    master          265710c20       src-efaa3176a   x          
-../systemd-stable      v229-stable     c7f5a7d89       x               x          
-../systemd-stable      v231-stable     33628598e       x               x          
-../systemd-stable      v232-stable     79a5d862a       x               x          
-../systemd-stable      v233-stable     589fa9087       x               x          
-../systemd-upstream    v234            d6d0473dc       src-782c925f7   x          
-../systemd-stable      v234-stable     782c925f7       x               x          
-../systemd-stable      v235-stable     b3e823e43       x               x          
-../systemd-upstream    v236            83fefc888       src-f78a88bec   x          
-../systemd-stable      v236-stable     b3e823e43       x               x          
-../systemd-upstream    v237            590171d1c       src-6d8c71eb8   x          
+../systemd-stable   v229-stable         c7f5a7d89           x               x
+../systemd-stable   v231-stable         33628598e           x               x
+../systemd-stable   v232-stable         79a5d862a           x               x
+../systemd-stable   v233-stable         589fa9087           x               x
+../systemd-stable   v234-stable         782c925f7           x               x
+../systemd-stable   v235-stable         b3e823e43           x               x
+../systemd-stable   v236-stable         b3e823e43           x               x
+../systemd-upstream master              265710c20           src-efaa3176a   x
+../systemd-upstream v234                d6d0473dc           src-782c925f7   x
+../systemd-upstream v236                83fefc888           src-f78a88bec   x
+../systemd-upstream v237                590171d1c           src-6d8c71eb8   x
index 045a838f4ba23508432018dffa36606f55f369ad..7543f6452c822206c3842f0f40dec3740f164f59 100755 (executable)
@@ -136,6 +136,7 @@ sub check_tree;          # Use check_tree.pl on the given commit and file.
 sub checkout_tree;       # Checkout the given refid on the given path.
 sub generate_file_list;  # Find all relevant files and store them in @wanted_files
 sub get_last_mutual;     # Find or read the last mutual refid between this and the upstream tree.
+sub handle_sig;          # Signal handler so we don't break without writing a new commit file.
 sub parse_args;          # Parse ARGV for the options we support
 sub rework_patch;        # Use check_tree.pl to generate valid diffs on all valid files within the patch.
 sub set_last_mutual;     # Write back %hMutuals to $COMMIT_FILE
@@ -143,6 +144,11 @@ sub shorten_refid;       # Take DIR and REFID and return the shortest possible R
 sub show_prg;            # Helper to show a progress line that is not permanent.
 sub wanted;              # Callback function for File::Find
 
+# set signal-handlers
+$SIG{'INT'}  = \&handle_sig;
+$SIG{'QUIT'} = \&handle_sig;
+$SIG{'TERM'} = \&handle_sig;
+
 # ================================================================
 # ===        ==> --------    Prechecks     -------- <==        ==
 # ================================================================
@@ -660,6 +666,18 @@ sub get_last_mutual {
        return 0;
 } ## end sub get_last_mutual
 
+
+# ---------------------------------------------------------------------------
+# --- Signal handler so we don't break without writing a new commit file. ---
+# ---------------------------------------------------------------------------
+sub handle_sig {
+       my($sig) = @_;
+       print "\nCaught SIG${sig}!\n";
+       set_last_mutual;
+       exit 1;
+}
+
+
 # -----------------------------------------------------------------------
 # --- parse the given list for arguments.                             ---
 # --- returns 1 on success, 0 otherwise.                              ---
@@ -732,7 +750,7 @@ sub parse_args {
                                        $result = 0;
                                        next;
                                }
-                               $upstream_path = abs_path( $args[$i] );
+                               $upstream_path = $args[$i];
                        } ## end else [ if ( length($upstream_path...))]
                } ## end else [ if ( $args[$i] =~ m/^--advance$/)]
        }  ## End looping arguments
@@ -934,7 +952,7 @@ sub set_last_mutual {
        }
        
        # Now we can build the fmt
-       my $out_fmt  = sprintf("%%-%ds\t%%-%ds\t%%-%ds\t%%-%ds\t%%s\n", $ref_len, $ref_len, $ref_len, $ref_len);
+       my $out_fmt  = sprintf("%%-%ds %%-%ds %%-%ds %%-%ds %%s\n", $ref_len, $ref_len, $ref_len, $ref_len);
        
        # Second we build the out text
        # ---------------------------------------------------------------