From ada332df78b4e4831d02a23f63594533801cbd97 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 25 Jan 2014 12:57:45 +0100 Subject: [PATCH] Warn about missing authors in map Warn (once) for each RCS username that has no corresponding map entry. The warning can be disabled. Inspired by a Thomas Dickey patch. --- rcs-fast-export.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/rcs-fast-export.rb b/rcs-fast-export.rb index 4fe0401..5fac0fd 100755 --- a/rcs-fast-export.rb +++ b/rcs-fast-export.rb @@ -108,6 +108,8 @@ Options: --rcs-commit-fuzz fuzziness in RCS commits to be considered a single one when importing multiple files (in seconds, defaults to 300, i.e. 5 minutes) + --[no-]warn-missing-authors + [do not] warn about usernames missing from the map file --[no-]symbol-check [do not] check symbols when coalescing commits --[no-]tag-each-rev [do not] create a lightweight tag for each RCS revision when importing a single file @@ -124,6 +126,7 @@ Config options: rcs.tagEachRev for --tag-each-rev rcs.logFilename for --log-filename rcs.commitFuzz for --rcs-commit-fuzz + rcs.warnMissingAuthors for --warn-missing-authors rcs.symbolCheck for --rcs-symbol-check rcs.tagFuzz for --rcs-tag-fuzz @@ -158,6 +161,18 @@ def load_authors_file(fn) return hash end +def username_to_author(name, opts) + map = opts[:authors] + raise "no authors map defined" unless map and Hash === map + + # if name is not found in map, provide a default one, optionally giving a warning (once) + unless map.key? name + warning "no author found for #{name}" if opts[:warn_missing_authors] + map[name] = "#{name} " + end + return map[name] +end + # display a message about a (recoverable) error def alert(msg, action) STDERR.puts "ERROR:\t#{msg}" @@ -265,7 +280,7 @@ module RCS end branch = rev.branch || 'master' - author = opts[:authors][rev.author] || "#{rev.author} " + author = username_to_author(rev.author, opts) date = "#{rev.date.tv_sec} +0000" log = String.new if opts[:log_filename] @@ -683,7 +698,7 @@ module RCS def export(opts={}) xbranch = self.branch || 'master' - xauthor = opts[:authors][self.author] || "#{self.author} " + xauthor = username_to_author(self.author, opts) xlog = self.log.join numdate = self.date.tv_sec xdate = "#{numdate} +0000" @@ -725,6 +740,9 @@ opts = GetoptLong.new( ['--ignore', GetoptLong::REQUIRED_ARGUMENT], # Date fuzziness for commits to be considered the same (in seconds) ['--rcs-commit-fuzz', GetoptLong::REQUIRED_ARGUMENT], + # warn about usernames missing in authors file map? + ['--warn-missing-authors', GetoptLong::NO_ARGUMENT], + ['--no-warn-missing-authors', GetoptLong::NO_ARGUMENT], # check symbols when coalescing? ['--symbol-check', GetoptLong::NO_ARGUMENT], ['--no-symbol-check', GetoptLong::NO_ARGUMENT], @@ -778,6 +796,10 @@ parse_options[:symbol_check] = ( `git config --bool rcs.symbolcheck`.chomp == 'false' ) ? false : true +parse_options[:warn_missing_authors] = ( + `git config --bool rcs.warnmissingauthors`.chomp == 'false' +) ? false : true + opts.each do |opt, arg| case opt when '--authors-file' -- 2.32.0.93.g670b81a890