summaryrefslogtreecommitdiff
path: root/pwx
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-05-16 08:06:32 +0200
committerSven Eden <yamakuzure@gmx.net>2018-05-16 08:06:32 +0200
commitf61424c1f64a9d7ea518a7a5bbda1990c5974d52 (patch)
tree065f12b4f2366c81c49a49a4a5efd9b0a0d2bf0b /pwx
parentfaf2b3bc6745322d5079f13de002f6bcbc116a41 (diff)
migrate_tree.pl: Add a signal handler, so the commit file is updated even on SIGINT.
Diffstat (limited to 'pwx')
-rw-r--r--pwx/last_mutual_commits.csv22
-rwxr-xr-xpwx/migrate_tree.pl22
2 files changed, 31 insertions, 13 deletions
diff --git a/pwx/last_mutual_commits.csv b/pwx/last_mutual_commits.csv
index 3f33b60b1..5ec52a7e3 100644
--- a/pwx/last_mutual_commits.csv
+++ b/pwx/last_mutual_commits.csv
@@ -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
diff --git a/pwx/migrate_tree.pl b/pwx/migrate_tree.pl
index 045a838f4..7543f6452 100755
--- a/pwx/migrate_tree.pl
+++ b/pwx/migrate_tree.pl
@@ -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
# ---------------------------------------------------------------