LLVM tools: Maintain up-to-date LLVM repo in 'llvm_tools'

Keeps an up-to-date LLVM source tree in 'llvm_tools' directory.
Previously, the LLVM repo would be cloned once and then be forgotten.

BUG=None
TEST=Ran the 'llvm_bisection.py' script on a previously created JSON
file (the script created it before). Successfully created tryjobs that
were not in the 'jobs' list. Also, successfully kept the LLVM repo
up-to-date in 'llvm_tools'.

Change-Id: If9038da788eb0fe0fe258274c1942f1d687868b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1769483
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Tested-by: Salud Lemus <saludlemus@google.com>
diff --git a/llvm_tools/llvm_bisection.py b/llvm_tools/llvm_bisection.py
index 9cf2f44..b4705d4 100755
--- a/llvm_tools/llvm_bisection.py
+++ b/llvm_tools/llvm_bisection.py
@@ -15,6 +15,7 @@
 import os
 
 from assert_not_in_chroot import VerifyOutsideChroot
+from get_llvm_hash import CreateTempLLVMRepo
 from get_llvm_hash import LLVMHash
 from modify_a_tryjob import AddTryjob
 from patch_manager import _ConvertToASCII
@@ -272,17 +273,17 @@
   new_llvm = LLVMHash()
 
   with new_llvm.CreateTempDirectory() as temp_dir:
-    if not src_path:
-      new_llvm.CloneLLVMRepo(temp_dir)
-      src_path = temp_dir
+    with CreateTempLLVMRepo(temp_dir) as new_repo:
+      if not src_path:
+        src_path = new_repo
 
-    # Get a list of revisions between start and end.
-    revisions = GetRevisionsBetweenBisection(start, end, parallel, src_path,
-                                             pending_revisions)
+      # Get a list of revisions between start and end.
+      revisions = GetRevisionsBetweenBisection(start, end, parallel, src_path,
+                                               pending_revisions)
 
-    git_hashes = [
-        new_llvm.GetGitHashForVersion(src_path, rev) for rev in revisions
-    ]
+      git_hashes = [
+          new_llvm.GetGitHashForVersion(src_path, rev) for rev in revisions
+      ]
 
   assert revisions, ('No revisions between start %d and end %d to create '
                      'tryjobs.' % (start, end))