findmissing: Clone stable release candidate repository when running locally

We need the stable release candidate repository to be able to check
if a patch is queued there for a future stable release. This is only
needed if local commands are executed, so add 'local' argument to
synchronize_repositories() and only synchronize the release candidate
repository when running an explicit command (ie not as part of the scripts
running on GCE).

BUG=None
TEST=Run getopen command

Change-Id: I1ca4e4b13b61da3484c67badea50b3b5c8fcf235
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2200285
Commit-Queue: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
diff --git a/contrib/findmissing/common.py b/contrib/findmissing/common.py
index ddd9765..cddf1bb 100755
--- a/contrib/findmissing/common.py
+++ b/contrib/findmissing/common.py
@@ -24,6 +24,7 @@
 KERNEL_SITE = 'https://git.kernel.org/'
 UPSTREAM_REPO = KERNEL_SITE + 'pub/scm/linux/kernel/git/torvalds/linux'
 STABLE_REPO = KERNEL_SITE + 'pub/scm/linux/kernel/git/stable/linux-stable'
+STABLE_RC_REPO = KERNEL_SITE + 'pub/scm/linux/kernel/git/stable/linux-stable-rc'
 
 CHROMIUM_SITE = 'https://chromium.googlesource.com/'
 CHROMEOS_KERNEL_DIR = 'chromiumos/third_party/kernel'
@@ -38,6 +39,7 @@
 
 CHROMEOS_PATH = 'linux_chrome'
 STABLE_PATH = 'linux_stable'
+STABLE_RC_PATH = 'linux_stable_rc'
 UPSTREAM_PATH = 'linux_upstream'
 
 WORKDIR = os.getcwd()
@@ -57,8 +59,9 @@
 class Kernel(Enum):
     """Enum representing which Kernel we are representing."""
     linux_stable = 1
-    linux_chrome = 2
-    linux_upstream = 3
+    linux_stable_rc = 2
+    linux_chrome = 3
+    linux_upstream = 4
 
 
 class KernelMetadata(object):
@@ -179,6 +182,8 @@
     """Returns KernelMetadata for each Kernel Enum"""
     stable_kernel_metadata = KernelMetadata(STABLE_PATH, STABLE_REPO, 'stable_fixes',
             STABLE_BRANCHES, 'v%s', stable_branch, initdb_stable.update_stable_table)
+    stable_rc_kernel_metadata = KernelMetadata(STABLE_RC_PATH, STABLE_RC_REPO, 'stable_fixes',
+            STABLE_BRANCHES, 'v%s', stable_branch, initdb_stable.update_stable_table)
     chrome_kernel_metadata = KernelMetadata(CHROMEOS_PATH, CHROMEOS_REPO, 'chrome_fixes',
             CHROMEOS_BRANCHES, 'v%s', chromeos_branch, initdb_chromeos.update_chrome_table)
     upstream_kernel_metadata = KernelMetadata(UPSTREAM_PATH, UPSTREAM_REPO, 'upstream_fixes',
@@ -187,6 +192,7 @@
 
     kernel_metadata_lookup = {
             Kernel.linux_stable: stable_kernel_metadata,
+            Kernel.linux_stable_rc: stable_rc_kernel_metadata,
             Kernel.linux_chrome: chrome_kernel_metadata,
             Kernel.linux_upstream: upstream_kernel_metadata
     }
diff --git a/contrib/findmissing/synchronize.py b/contrib/findmissing/synchronize.py
index ca161a4..b125deb 100755
--- a/contrib/findmissing/synchronize.py
+++ b/contrib/findmissing/synchronize.py
@@ -21,6 +21,7 @@
 
 UPSTREAM_KERNEL_METADATA = common.get_kernel_metadata(common.Kernel.linux_upstream)
 STABLE_KERNEL_METADATA = common.get_kernel_metadata(common.Kernel.linux_stable)
+STABLE_RC_KERNEL_METADATA = common.get_kernel_metadata(common.Kernel.linux_stable_rc)
 CHROME_KERNEL_METADATA = common.get_kernel_metadata(common.Kernel.linux_chrome)
 
 def synchronize_upstream(upstream_kernel_metadata):
@@ -88,11 +89,13 @@
     os.chdir(common.WORKDIR)
 
 
-def synchronize_repositories():
+def synchronize_repositories(local=False):
     """Deep clones linux_upstream, linux_stable, and linux_chromeos repositories"""
     synchronize_upstream(UPSTREAM_KERNEL_METADATA)
     synchronize_custom(STABLE_KERNEL_METADATA)
     synchronize_custom(CHROME_KERNEL_METADATA)
+    if local:
+        synchronize_custom(STABLE_RC_KERNEL_METADATA)
 
 
 def synchronize_databases():