Title: [92609] trunk/Tools
Revision
92609
Author
[email protected]
Date
2011-08-08 11:02:59 -0700 (Mon, 08 Aug 2011)

Log Message

webkit-patch doesn't get along with renamed files
https://bugs.webkit.org/show_bug.cgi?id=48075

Possibly a bit heavy handed - I removed all instances of -C and
changed every instance of -M with '--no-renames' in git.py. This
forces git to not try to tell us about renames at all, which is
ultimately the behaviour we want. The old file is shown deleted,
then the new file is shown added, followed by any changes that
occurred. Also gets rid of the problem where deleting one file
and adding another file which has similar content would
unexpectedly show up as a rename, and fall out of a diff.

Based on a patch by Wyatt Carss.

Reviewed by Eric Seidel.

* Scripts/webkitpy/common/checkout/scm/git.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (92608 => 92609)


--- trunk/Tools/ChangeLog	2011-08-08 18:00:04 UTC (rev 92608)
+++ trunk/Tools/ChangeLog	2011-08-08 18:02:59 UTC (rev 92609)
@@ -1,3 +1,23 @@
+2011-08-08  Jochen Eisinger  <[email protected]>
+
+        webkit-patch doesn't get along with renamed files
+        https://bugs.webkit.org/show_bug.cgi?id=48075
+
+        Possibly a bit heavy handed - I removed all instances of -C and
+        changed every instance of -M with '--no-renames' in git.py. This
+        forces git to not try to tell us about renames at all, which is
+        ultimately the behaviour we want. The old file is shown deleted,
+        then the new file is shown added, followed by any changes that
+        occurred. Also gets rid of the problem where deleting one file
+        and adding another file which has similar content would
+        unexpectedly show up as a rename, and fall out of a diff.
+
+        Based on a patch by Wyatt Carss.
+
+        Reviewed by Eric Seidel.
+
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+
 2011-08-07  Sam White  <[email protected]>
 
         Add the ability to search the AccessibilityObject cache

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py (92608 => 92609)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2011-08-08 18:00:04 UTC (rev 92608)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2011-08-08 18:02:59 UTC (rev 92609)
@@ -144,7 +144,7 @@
         return self._filesystem.exists(self.absolute_path(self._filesystem.join('.git', 'rebase-apply')))
 
     def working_directory_is_clean(self):
-        return self.run(['git', 'diff', 'HEAD', '--name-only'], cwd=self.checkout_root) == ""
+        return self.run(['git', 'diff', 'HEAD', '--no-renames', '--name-only'], cwd=self.checkout_root) == ""
 
     def clean_working_directory(self):
         # FIXME: These should probably use cwd=self.checkout_root.
@@ -157,7 +157,7 @@
     def status_command(self):
         # git status returns non-zero when there are changes, so we use git diff name --name-status HEAD instead.
         # No file contents printed, thus utf-8 autodecoding in self.run is fine.
-        return ["git", "diff", "--name-status", "HEAD"]
+        return ["git", "diff", "--name-status", "--no-renames", "HEAD"]
 
     def _status_regexp(self, expected_types):
         return '^(?P<status>[%s])\t(?P<filename>.+)$' % expected_types
@@ -186,7 +186,7 @@
 
     def changed_files(self, git_commit=None):
         # FIXME: --diff-filter could be used to avoid the "extract_filenames" step.
-        status_command = ['git', 'diff', '-r', '--name-status', '-C', '-M', "--no-ext-diff", "--full-index", self.merge_base(git_commit)]
+        status_command = ['git', 'diff', '-r', '--name-status', "--no-renames", "--no-ext-diff", "--full-index", self.merge_base(git_commit)]
         # FIXME: I'm not sure we're returning the same set of files that SVN.changed_files is.
         # Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
         return self.run_status_and_extract_filenames(status_command, self._status_regexp("ADM"))
@@ -209,7 +209,7 @@
     def conflicted_files(self):
         # We do not need to pass decode_output for this diff command
         # as we're passing --name-status which does not output any data.
-        status_command = ['git', 'diff', '--name-status', '-C', '-M', '--diff-filter=U']
+        status_command = ['git', 'diff', '--name-status', '--no-renames', '--diff-filter=U']
         return self.run_status_and_extract_filenames(status_command, self._status_regexp("U"))
 
     def added_files(self):
@@ -244,7 +244,7 @@
         """Returns a byte array (str()) representing the patch file.
         Patch files are effectively binary since they may contain
         files of multiple different encodings."""
-        command = ['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit), "--"]
+        command = ['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "--no-renames", self.merge_base(git_commit), "--"]
         if changed_files:
             command += changed_files
         return self.prepend_svn_revision(self.run(command, decode_output=False, cwd=self.checkout_root))
@@ -282,7 +282,7 @@
         return self.create_patch(git_commit)
 
     def diff_for_file(self, path, log=None):
-        return self.run(['git', 'diff', 'HEAD', '--', path], cwd=self.checkout_root)
+        return self.run(['git', 'diff', 'HEAD', '--no-renames', '--', path], cwd=self.checkout_root)
 
     def show_head(self, path):
         return self.run(['git', 'show', 'HEAD:' + self.to_object_name(path)], decode_output=False)
@@ -462,4 +462,4 @@
         return CommitMessage(commit_lines[first_line_after_headers:])
 
     def files_changed_summary_for_commit(self, commit_id):
-        return self.run(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
+        return self.run(['git', 'diff-tree', '--shortstat', '--no-renames', '--no-commit-id', commit_id])

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (92608 => 92609)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-08-08 18:00:04 UTC (rev 92608)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-08-08 18:02:59 UTC (rev 92609)
@@ -962,6 +962,17 @@
         # self._shared_test_head_svn_revision().
         self.assertEqual(scm.head_svn_revision(), '')
 
+    def test_rename_files(self):
+        scm = self.tracking_scm
+
+        run_command(['git', 'mv', 'foo_file', 'bar_file'])
+        scm.commit_locally_with_message('message')
+
+        patch = scm.create_patch()
+        self.assertFalse(re.search(r'rename from ', patch))
+        self.assertFalse(re.search(r'rename to ', patch))
+
+
 class GitSVNTest(SCMTest):
 
     def _setup_git_checkout(self):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to