From ce5bb30a917a12d478c052efe92ff5d7810c9efe Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Thu, 17 May 2018 19:30:11 +0200 Subject: [PATCH] migrate_tree.pl: Only write a new commits file, if the old was finished reading or none existed. --- pwx/migrate_tree.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pwx/migrate_tree.pl b/pwx/migrate_tree.pl index c5892c717..4eb358ec0 100755 --- a/pwx/migrate_tree.pl +++ b/pwx/migrate_tree.pl @@ -11,7 +11,8 @@ # 0.1.0 2018-05-14 sed, PrydeWorX Application of the reworked patches added. # 0.2.0 2018-05-15 sed, PrydeWorX First working version. # 0.2.1 Fixed usage of Try::Tiny. -# 0.2.2 2018-05-16 sed, PrydeWorX Made sure that the commit file is always written on exit. +# 0.2.2 2018-05-16 sed, PrydeWorX Made sure that the commit file is always written on exit, +# but only if a potential commits file was finished reading. # # ======================== # === Little TODO list === @@ -79,6 +80,7 @@ Notes: # ================================================================ my $commit_count = 0; # It is easiest to count the relevant commits globally. +my $commits_read = 0; # Set to one once the commit file is completely read. my $do_advance = 0; # If set by --advance, use src- as last commit. my %hSrcCommits = (); # Record here which patch file is which commit. my %hDirectories = (); # Filled when searching relevant files, used to validate new files. @@ -650,6 +652,9 @@ sub get_last_mutual { checkout_tree($upstream_path, $wanted_refid, 0); } ## end if ( -f $COMMIT_FILE ) + # Note down that reading of any file is done. + $commits_read = 1; + # If this is already set, we are fine. if ( length($mutual_commit) ) { $hMutuals{$upstream_path}{$wanted_refid}{mutual} = shorten_refid($upstream_path, $mutual_commit); @@ -936,6 +941,10 @@ sub rework_patch { # --- Write back %hMutuals to $COMMIT_FILE --- # -------------------------------------------- sub set_last_mutual { + + # Don't do anything if we haven't finished reading the commit file: + $commits_read or return 1; + my $out_text = "# Automatically generated commit information\n" . "# Only edit if you know what these do!\n\n"; my ($pLen, $rLen, $mLen, $sLen) = (0, 0, 0, 0); # Length for the fmt -- 2.30.2