[ARVADOS] updated: ab7c97818a088e7205d4d01db1e8a0c0709b9aa0

git at public.curoverse.com git at public.curoverse.com
Wed Sep 17 17:35:10 EDT 2014


Summary of changes:
 sdk/python/arvados/commands/copy.py | 44 ++++++++++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 13 deletions(-)

       via  ab7c97818a088e7205d4d01db1e8a0c0709b9aa0 (commit)
      from  8c5f7a869e1d7a7c8f6338d1836987567c32f626 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ab7c97818a088e7205d4d01db1e8a0c0709b9aa0
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Sep 17 17:34:22 2014 -0400

    3699: misc improvements
    
    * added -v/--verbose flag to enable debug output
    * skip copying a src repository if it has already been copied this
      session
    * clean up tmp directories when done

diff --git a/sdk/python/arvados/commands/copy.py b/sdk/python/arvados/commands/copy.py
index e857cf2..770c361 100755
--- a/sdk/python/arvados/commands/copy.py
+++ b/sdk/python/arvados/commands/copy.py
@@ -20,7 +20,7 @@ import argparse
 import getpass
 import os
 import re
-import sets
+import shutil
 import sys
 import logging
 import tempfile
@@ -44,6 +44,9 @@ def main():
         description='Copy a pipeline instance from one Arvados instance to another.')
 
     parser.add_argument(
+        '-v', '--verbose', dest='verbose', action='store_true',
+        help='Verbose output.')
+    parser.add_argument(
         '--src', dest='source_arvados', required=True,
         help='The name of the source Arvados instance (required). May be either a pathname to a config file, or the basename of a file in $HOME/.config/arvados/instance_name.conf.')
     parser.add_argument(
@@ -68,6 +71,11 @@ def main():
 
     args = parser.parse_args()
 
+    if args.verbose:
+        logger.setLevel(logging.DEBUG)
+    else:
+        logger.setLevel(logging.INFO)
+
     # Create API clients for the source and destination instances
     src_arv = api_for_instance(args.source_arvados)
     dst_arv = api_for_instance(args.destination_arvados)
@@ -90,6 +98,10 @@ def main():
     else:
         abort("cannot copy object {} of type {}".format(args.object_uuid, t))
 
+    # Clean up any outstanding temp git repositories.
+    for d in local_repo_dir.values():
+        shutil.rmtree(d, ignore_errors=True)
+
     # If no exception was thrown and the response does not have an
     # error_token field, presume success
     if 'error_token' in result or 'uuid' not in result:
@@ -329,7 +341,7 @@ def copy_collection(obj_uuid, src, dst):
     manifest = c['manifest_text']
 
     # Enumerate the block locators found in the manifest.
-    collection_blocks = sets.Set()
+    collection_blocks = set()
     src_keep = arvados.keep.KeepClient(src)
     for line in manifest.splitlines():
         try:
@@ -391,18 +403,24 @@ def copy_git_repo(src_git_repo, src, dst, dst_git_repo):
     dst_git_push_url  = r['items'][0]['push_url']
     logger.debug('dst_git_push_url: {}'.format(dst_git_push_url))
 
-    tmprepo = tempfile.mkdtemp()
-
     dst_branch = re.sub(r'\W+', '_', src_git_url)
-    arvados.util.run_command(
-        ["git", "clone", src_git_url, tmprepo],
-        cwd=os.path.dirname(tmprepo))
-    arvados.util.run_command(
-        ["git", "checkout", "-b", dst_branch],
-        cwd=tmprepo)
-    arvados.util.run_command(["git", "remote", "add", "dst", dst_git_push_url], cwd=tmprepo)
-    arvados.util.run_command(["git", "push", "dst", dst_branch], cwd=tmprepo)
-    local_repo_dir[src_git_repo] = tmprepo
+
+    # Copy git commits from src repo to dst repo (but only if
+    # we have not already copied this repo in this session).
+    #
+    if src_git_repo in local_repo_dir:
+        logger.debug('already copied src repo %s, skipping', src_git_repo)
+    else:
+        tmprepo = tempfile.mkdtemp()
+        local_repo_dir[src_git_repo] = tmprepo
+        arvados.util.run_command(
+            ["git", "clone", src_git_url, tmprepo],
+            cwd=os.path.dirname(tmprepo))
+        arvados.util.run_command(
+            ["git", "checkout", "-b", dst_branch],
+            cwd=tmprepo)
+        arvados.util.run_command(["git", "remote", "add", "dst", dst_git_push_url], cwd=tmprepo)
+        arvados.util.run_command(["git", "push", "dst", dst_branch], cwd=tmprepo)
 
 # git_rev_parse(rev, repo)
 #

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list