Merge "Revert "Enable incremental builder to find files that moved, and try to process them via patch + rename, instead of delete + add."" into klp-dev
diff --git a/core/Makefile b/core/Makefile
index f118cea..298eef1 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1262,7 +1262,6 @@
 endif
 	$(hide) echo "mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)" >> $(zip_root)/META/misc_info.txt
 	$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
 	$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
 	@# Zip everything up, preserving symlinks
 	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 189672c..2c3b9e7 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -184,11 +184,6 @@
     cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
     self.script.append(self._WordWrap(cmd))
 
-  def RenameFile(self, srcfile, tgtfile):
-    """Moves a file from one location to another."""
-    if self.info.get("update_rename_support", False):
-      self.script.append('rename("%s", "%s");' % (srcfile, tgtfile))
-
   def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
     """Apply binary patches (in *patchpairs) to the given srcfile to
     produce tgtfile (which may be "-" to indicate overwriting the
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 2ef896f..a6b9b69 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -108,31 +108,6 @@
   symlink."""
   return (info.external_attr >> 28) == 010
 
-def ClosestFileMatch(src, tgtfiles, existing):
-  """Returns the closest file match between a source file and list
-     of potential matches.  The exact filename match is preferred,
-     then the sha1 is searched for, and finally a file with the same
-     basename is evaluated.  Rename support in the updater-binary is
-     required for the latter checks to be used."""
-
-  result = tgtfiles.get("path:" + src.name)
-  if result is not None:
-    return result
-
-  if not OPTIONS.target_info_dict.get("update_rename_support", False):
-    return None
-
-  if src.size < 1000:
-    return None
-
-  result = tgtfiles.get("sha1:" + src.sha1)
-  if result is not None and existing.get(result.name) is None:
-    return result
-  result = tgtfiles.get("file:" + src.name.split("/")[-1])
-  if result is not None and existing.get(result.name) is None:
-    return result
-  return None
-
 class Item:
   """Items represent the metadata (user, group, mode) of files and
   directories in the system image."""
@@ -539,27 +514,11 @@
   verbatim_targets = []
   patch_list = []
   diffs = []
-  renames = {}
   largest_source_size = 0
-
-  matching_file_cache = {}
-  for fn in source_data.keys():
-    sf = source_data[fn]
-    assert fn == sf.name
-    matching_file_cache["path:" + fn] = sf
-    # Only allow eligability for filename/sha matching
-    # if there isn't a perfect path match.
-    if target_data.get(sf.name) is None:
-      matching_file_cache["file:" + fn.split("/")[-1]] = sf
-      matching_file_cache["sha:" + sf.sha1] = sf
-
   for fn in sorted(target_data.keys()):
     tf = target_data[fn]
     assert fn == tf.name
-    sf = ClosestFileMatch(tf, matching_file_cache, renames)
-    if sf is not None and sf.name != tf.name:
-      print "File has moved from " + sf.name + " to " + tf.name
-      renames[sf.name] = tf
+    sf = source_data.get(fn, None)
 
     if sf is None or fn in OPTIONS.require_verbatim:
       # This file should be included verbatim
@@ -572,7 +531,7 @@
       # File is different; consider sending as a patch
       diffs.append(common.Difference(tf, sf))
     else:
-      # Target file data identical to source (may still be renamed)
+      # Target file identical to source.
       pass
 
   common.ComputeDifferences(diffs)
@@ -584,8 +543,8 @@
       tf.AddToZip(output_zip)
       verbatim_targets.append((tf.name, tf.size))
     else:
-      common.ZipWriteStr(output_zip, "patch/" + sf.name + ".p", d)
-      patch_list.append((sf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
+      common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
+      patch_list.append((tf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
       largest_source_size = max(largest_source_size, sf.size)
 
   source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
@@ -667,8 +626,7 @@
   script.Print("Removing unneeded files...")
   script.DeleteFiles(["/"+i[0] for i in verbatim_targets] +
                      ["/"+i for i in sorted(source_data)
-                            if i not in target_data and
-                            i not in renames] +
+                            if i not in target_data] +
                      ["/system/recovery.img"])
 
   script.ShowProgress(0.8, 0)
@@ -755,13 +713,6 @@
     script.Print("Unpacking new recovery...")
     script.UnpackPackageDir("recovery", "/system")
 
-  if len(renames) > 0:
-    script.Print("Renaming files...")
-
-  for src in renames:
-    print "Renaming " + src + " to " + renames[src].name
-    script.RenameFile(src, renames[src].name)
-
   script.Print("Symlinks and permissions...")
 
   # Create all the symlinks that don't already exist, or point to