findmissing: initdb_stable: Don't attempt to add entries with no upstream SHA to database

A commit into a stable release will not always have an associated upstream SHA.
Such commits don't add value, so don't try to add them to the stable database.

While add it, add space in log between error number and error text
after database errors to improve log readability.

BUG=None
TEST=Run on GCE

Change-Id: I2f1cce9c676bbbd5580eab8b1cb6b77e41a8ffe8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2207396
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
Commit-Queue: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
diff --git a/contrib/findmissing/initdb_stable.py b/contrib/findmissing/initdb_stable.py
index bf78694..c0a3ad0 100755
--- a/contrib/findmissing/initdb_stable.py
+++ b/contrib/findmissing/initdb_stable.py
@@ -54,6 +54,12 @@
             last = sha
             usha = common.search_upstream_sha(sha)
 
+            # The upstream SHA will not always exist, for example for commits
+            # changing the Linux version number. Attempts to insert such commits
+            # into linux_stable will fail, so ignore them.
+            if usha is None:
+                continue
+
             try:
                 q = """INSERT INTO linux_stable
                         (sha, branch, upstream_sha, patch_id, description)
@@ -63,7 +69,7 @@
                              sha, branch, usha, patch_id, description)
             except MySQLdb.Error as e: # pylint: disable=no-member
                 logging.error(
-                    'Error inserting into linux_stable with values %s %s %s %s %s: error %d(%s)',
+                    'Error inserting into linux_stable with values %s %s %s %s %s: error %d (%s)',
                     sha, branch, usha, patch_id, description, e.args[0], e.args[1])
             except UnicodeDecodeError as e:
                 logging.error(