Fix crash in translation screenshot presubmit

The presubmit code for translation screenshots parses grd and grdp files
modified in the CL. It does this by referring to the old and new
contents of the files passed to it by the presubmit.

grd files can refer to grdp files via <part> tags. This causes the
messages in the grdp file to be included in the grd file. If a modified
grd file's old contents refers to a now renamed or deleted grdp file,
grd reader fails to open the grdp and crashes.

This CL fixes this by ignoring <part> tags while loading grd files.
This should be safe: The presubmit processes grdp files separately, so
all grdp files should still be processed, just not when loading grd
files. Additionally, grdp files cannot contain part files, so
ignoring the tag while loading grdp files should also be safe.

Bug: 1047487
Change-Id: I3d79aa028c4ae360d74a437a019628d0bdab494a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037027
Reviewed-by: anthonyvd <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Commit-Queue: Mustafa Emre Acer <[email protected]>
Cr-Commit-Position: refs/heads/master@{#739040}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 5fc0c3bf..0850652 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -4752,6 +4752,13 @@
     file_path = f.LocalPath()
     old_id_to_msg_map = {}
     new_id_to_msg_map = {}
+    # Note that this code doesn't check if the file has been deleted. This is
+    # OK because it only uses the old and new file contents and doesn't load
+    # the file via its path.
+    # It's also possible that a file's content refers to a renamed or deleted
+    # file via a <part> tag, such as <part file="now-deleted-file.grdp">. This
+    # is OK as well, because grd_helper ignores <part> tags when loading .grd or
+    # .grdp files.
     if file_path.endswith('.grdp'):
       if f.OldContents():
         old_id_to_msg_map = grd_helper.GetGrdpMessagesFromString(