Add scripts/repo_sync_manifest
This script will sync a repo checkout to the given manifest file. The
repo checkout can optionally be bootstrapped by copying from an existing
repo checkout.
BUG=chromium:864816
TEST=lib/repo_util_unittest; scripts/repo_sync_manifest_unittest
Change-Id: Id5c5ca85d3f4da3eed0b3b019e2bfa3b833ed790
Reviewed-on: https://chromium-review.googlesource.com/1185889
Commit-Ready: Lann Martin <lannm@chromium.org>
Tested-by: Lann Martin <lannm@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/repo_sync_manifest.py b/scripts/repo_sync_manifest.py
new file mode 100644
index 0000000..f19e938
--- /dev/null
+++ b/scripts/repo_sync_manifest.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Sync a repo checkout to the given manifest file."""
+
+from __future__ import print_function
+
+import os
+
+from chromite.lib import commandline
+from chromite.lib import repo_util
+
+
+def GetParser():
+ """Creates the argparse parser."""
+ parser = commandline.ArgumentParser(description=__doc__)
+ parser.add_argument('manifest', type='path',
+ help='The manifest file to sync to.')
+ parser.add_argument('--repo-root', type='path', default='.',
+ help='Path to the repo root to sync.')
+ parser.add_argument('--copy-repo', type='path',
+ help='Path to an existing repo root; the .repo dir '
+ 'there will be copied to the target repo root, '
+ 'which must not be within an existing root.')
+ return parser
+
+
+def main(argv):
+ parser = GetParser()
+ options = parser.parse_args(argv)
+ options.Freeze()
+
+ # Assert manifest exists.
+ os.stat(options.manifest)
+
+ if options.copy_repo:
+ copy_repo = repo_util.Repository(options.copy_repo)
+ copy_repo.Copy(options.repo_root)
+
+ repo = repo_util.Repository(options.repo_root)
+
+ repo.Sync(manifest_path=options.manifest)