Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: build/android/pylib/android_commands.py

Issue 219363006: Make GetFilesChanged work with copied files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/android_commands_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index f000682b70641709bfe193dc6e13ebded47424c8..a27e04d54c642852cbb3cc10a45270c49075f565 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -951,16 +951,6 @@ class AndroidCommands(object):
host_hash_tuples, device_hash_tuples = self._RunMd5Sum(
real_host_path, real_device_path)
- # Ignore extra files on the device.
- if not ignore_filenames:
- host_files = [os.path.relpath(os.path.normpath(p.path),
- real_host_path) for p in host_hash_tuples]
-
- def HostHas(fname):
- return any(path in fname for path in host_files)
-
- device_hash_tuples = [h for h in device_hash_tuples if HostHas(h.path)]
-
if len(host_hash_tuples) > len(device_hash_tuples):
logging.info('%s files do not exist on the device' %
(len(host_hash_tuples) - len(device_hash_tuples)))
@@ -972,10 +962,29 @@ class AndroidCommands(object):
return os.path.join(device_path, os.path.relpath(host_file_path,
real_host_path))
- device_hashes = [h.hash for h in device_hash_tuples]
- return [(t.path, HostToDevicePath(t.path) if
- os.path.isdir(real_host_path) else real_device_path)
- for t in host_hash_tuples if t.hash not in device_hashes]
+ if ignore_filenames:
+ # If we are ignoring file names, then just return all files on the host
+ # that have an MD5 sum that doesn't match one on the device.
+ device_hashes = set([h.hash for h in device_hash_tuples])
+ return [(t.path, HostToDevicePath(t.path)
+ if os.path.isdir(real_host_path) else real_device_path)
+ for t in host_hash_tuples if t.hash not in device_hashes]
+ else:
+ # Otherwise, we return all files on the host for which a file with an
+ # equivalent MD5 sum does not exist at the same relative path on the
+ # device.
+ host_rel = [(os.path.relpath(os.path.normpath(t.path), real_host_path),
+ t.hash)
+ for t in host_hash_tuples]
+ device_rel = dict([(os.path.relpath(os.path.normpath(t.path),
+ real_device_path),
+ t.hash)
+ for t in device_hash_tuples])
+ def RelToRealPaths(rel_path):
craigdh 2014/04/01 15:24:32 putting a blank line on either side of inline func
+ return (os.path.join(real_host_path, rel_path),
+ os.path.join(real_device_path, rel_path))
+ return [RelToRealPaths(path) for path, host_hash in host_rel
+ if path not in device_rel or host_hash != device_rel[path]]
def PushIfNeeded(self, host_path, device_path):
"""Pushes |host_path| to |device_path|.
« no previous file with comments | « no previous file | build/android/pylib/android_commands_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698