Bug 1353537 - Update adb.py push() to always copy directories when pushing a directory; r=bc
authorGeoff Brown <gbrown@mozilla.com>
Tue, 04 Apr 2017 18:48:12 -0600
changeset 351290 141975d40a7c
parent 351289 87c7bb132ac6
child 351291 1f5e8370f845
push id31604
push usercbook@mozilla.com
push dateWed, 05 Apr 2017 12:33:50 +0000
treeherdermozilla-central@3854bcf837a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbc
bugs1353537
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1353537 - Update adb.py push() to always copy directories when pushing a directory; r=bc
testing/mozbase/mozdevice/mozdevice/adb.py
--- a/testing/mozbase/mozdevice/mozdevice/adb.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb.py
@@ -1723,41 +1723,32 @@ class ADBDevice(ADBCommand):
         :type timeout: integer or None
         :raises: * ADBTimeoutError
                  * ADBError
         """
         # remove trailing /
         local = os.path.normpath(local)
         remote = os.path.normpath(remote)
         copy_required = False
-        if self._adb_version >= '1.0.36' and \
-           os.path.isdir(local) and self.is_dir(remote):
+        if os.path.isdir(local):
+            copy_required = True
+            temp_parent = tempfile.mkdtemp()
+            remote_name = os.path.basename(remote)
+            new_local = os.path.join(temp_parent, remote_name)
+            dir_util.copy_tree(local, new_local)
+            local = new_local
             # See do_sync_push in
             # https://android.googlesource.com/platform/system/core/+/master/adb/file_sync_client.cpp
             # Work around change in behavior in adb 1.0.36 where if
             # the remote destination directory exists, adb push will
             # copy the source directory *into* the destination
             # directory otherwise it will copy the source directory
             # *onto* the destination directory.
-            #
-            # If the destination directory does exist, push to its
-            # parent directory.  If the source and destination leaf
-            # directory names are different, copy the source directory
-            # to a temporary directory with the same leaf name as the
-            # destination so that when we push to the parent, the
-            # source is copied onto the destination directory.
-            local_name = os.path.basename(local)
-            remote_name = os.path.basename(remote)
-            if local_name != remote_name:
-                copy_required = True
-                temp_parent = tempfile.mkdtemp()
-                new_local = os.path.join(temp_parent, remote_name)
-                dir_util.copy_tree(local, new_local)
-                local = new_local
-            remote = '/'.join(remote.rstrip('/').split('/')[:-1])
+            if self._adb_version >= '1.0.36':
+                remote = '/'.join(remote.rstrip('/').split('/')[:-1])
         try:
             self.command_output(["push", local, remote], timeout=timeout)
         except:
             raise
         finally:
             if copy_required:
                 shutil.rmtree(temp_parent)