bisect-kit: helper script to prepare source trees for ChromeOS bisection

Typical usage:

  Initial setup:
    $ setup_cros_bisect.py init --chromeos
    $ setup_cros_bisect.py init --chrome
    $ setup_cros_bisect.py init --android=pi-arc-dev

  Sync code if necessary:
    $ setup_cros_bisect.py sync

  Create source trees for bisection
    $ setup_cros_bisect.py new --session=12345

  After bisection finished, delete trees
    $ setup_cros_bisect.py delete --session=12345

BUG=None
TEST=run above commands

Change-Id: I6f94b57b9a2967addf6d654dd571a68b2d06e0d7
Reviewed-on: https://chromium-review.googlesource.com/1242666
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
diff --git a/bisect_kit/gclient_util.py b/bisect_kit/gclient_util.py
index ef32613..6a87ffd 100644
--- a/bisect_kit/gclient_util.py
+++ b/bisect_kit/gclient_util.py
@@ -21,7 +21,12 @@
 logger = logging.getLogger(__name__)
 
 
-def config(gclient_dir, url, cache_dir=None, deps_file=None, custom_var=None):
+def config(gclient_dir,
+           url=None,
+           cache_dir=None,
+           deps_file=None,
+           custom_var=None,
+           spec=None):
   """Simply wrapper of `gclient config`.
 
   Args:
@@ -30,6 +35,7 @@
     cache_dir: gclient's git cache folder
     deps_file: override the default DEPS file name
     custom_var: custom variables
+    spec: content of gclient file
   """
   cmd = ['gclient', 'config']
   if deps_file:
@@ -38,7 +44,10 @@
     cmd += ['--cache-dir', cache_dir]
   if custom_var:
     cmd += ['--custom-var', custom_var]
-  cmd.append(url)
+  if spec:
+    cmd += ['--spec', spec]
+  if url:
+    cmd.append(url)
 
   util.check_call(*cmd, cwd=gclient_dir)