RESOLVED FIXED52261
Make webkit-patch support subdirectories for SVN checkouts
https://bugs.webkit.org/show_bug.cgi?id=52261
Summary Make webkit-patch support subdirectories for SVN checkouts
Maciej Stachowiak
Reported 2011-01-11 16:03:02 PST
Make webkit-patch support subdirectories for SVN checkouts
Attachments
Patch (5.36 KB, patch)
2011-01-11 16:03 PST, Maciej Stachowiak
no flags
Patch (6.69 KB, patch)
2011-01-11 16:32 PST, Maciej Stachowiak
no flags
Patch (6.85 KB, patch)
2011-01-11 16:47 PST, Maciej Stachowiak
no flags
Patch (6.89 KB, patch)
2011-01-11 16:49 PST, Maciej Stachowiak
no flags
Patch (1.60 KB, patch)
2011-01-12 02:41 PST, Adam Barth
no flags
proposed fix (1.84 KB, patch)
2011-01-13 13:02 PST, Peter Gal
no flags
Patch (8.25 KB, patch)
2011-01-14 02:59 PST, Eric Seidel (no email)
no flags
Maciej Stachowiak
Comment 1 2011-01-11 16:03:28 PST
Maciej Stachowiak
Comment 2 2011-01-11 16:11:04 PST
This is my first Python patch so I don't really know if this was the best way to do it.
Adam Barth
Comment 3 2011-01-11 16:25:19 PST
Comment on attachment 78613 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=78613&action=review Thanks for the patch. This looks like a good approach. > Tools/Scripts/webkitpy/common/checkout/scm.py:330 > + if len(patch_directories) > 0: > + self.patch_directories = patch_directories Private member variables in python are prefixed by _ (by convention). We're not perfect about this in webkitpy because we learned about it after we started, but we're trying to enforce that for new code. > Tools/Scripts/webkitpy/common/checkout/scm.py:332 > + self.patch_directories = [os.path.relpath(cwd, self.checkout_root)] Generally, using None is better than [] for default behavior, especially default behavior that changes the empty set into the universal set. > Tools/Scripts/webkitpy/common/checkout/scm.py:439 > - return self.run_status_and_extract_filenames(self.status_command(), self._status_regexp("ACDMR")) > + status_command = ["svn", "status"] > + status_command.extend(self.patch_directories) We don't want to do this for all clients of run_status_and_extract_filenames and/or status_command ? It seems strange to do this only here. > Tools/Scripts/webkitpy/tool/main.py:88 > - self._scm = default_scm() > + self._scm = default_scm(self._options) options is a tool-layer concept (i.e., specific to webkit-patch). We shouldn't be passing the options collection to the "common" layer because different scripts (e.g., new-run-webkit-tests) might have a different set of options. Usually what we do in this case is read the value out of the options collection and pass it in a named argument explicitly.
Maciej Stachowiak
Comment 4 2011-01-11 16:32:57 PST
Adam Barth
Comment 5 2011-01-11 16:36:29 PST
Comment on attachment 78619 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=78619&action=review > Tools/Scripts/webkitpy/style_references.py:74 > def create_patch(self, git_commit, changed_files=None): > # FIXME: SCM.create_patch should understand how to handle None. > - return self._scm.create_patch(git_commit, changed_files=changed_files or []) > + return self._scm.create_patch(git_commit, changed_files=changed_files) We really should just get rid of this whole references thing. It hasn't really bought us much. (This comment isn't really about your patch, just my reaction to seeing this change.)
Maciej Stachowiak
Comment 6 2011-01-11 16:47:51 PST
Maciej Stachowiak
Comment 7 2011-01-11 16:49:12 PST
Adam Barth
Comment 8 2011-01-11 16:55:00 PST
Comment on attachment 78626 [details] Patch Thanks. Looks good modulo renaming the parameter to default_scm.
Maciej Stachowiak
Comment 9 2011-01-11 16:57:03 PST
Alexey Proskuryakov
Comment 10 2011-01-11 19:37:49 PST
*** Bug 52260 has been marked as a duplicate of this bug. ***
Csaba Osztrogonác
Comment 11 2011-01-12 02:32:29 PST
It doesn't work with python 2.5, because os.path.relpath() introduced in 2.6 File "/home/webkitbuildbot/slaves/release32bit/buildslave/qt-linux-release/build/Tools/Scripts/webkitpy/common/checkout/scm.py", line 331, in __init__ self._patch_directories = [os.path.relpath(cwd, self.checkout_root)] AttributeError: 'module' object has no attribute 'relpath'
Adam Barth
Comment 12 2011-01-12 02:35:36 PST
> It doesn't work with python 2.5, because os.path.relpath() introduced in 2.6 My mistake. We should be calling this version: http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/system/ospath.py#L35
Adam Barth
Comment 13 2011-01-12 02:41:45 PST
WebKit Commit Bot
Comment 14 2011-01-12 04:29:50 PST
Comment on attachment 78668 [details] Patch Clearing flags on attachment: 78668 Committed r75600: <http://trac.webkit.org/changeset/75600>
WebKit Commit Bot
Comment 15 2011-01-12 04:29:56 PST
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 16 2011-01-13 08:54:01 PST
(In reply to comment #5) > > Tools/Scripts/webkitpy/style_references.py:74 > > def create_patch(self, git_commit, changed_files=None): > > # FIXME: SCM.create_patch should understand how to handle None. > > - return self._scm.create_patch(git_commit, changed_files=changed_files or []) > > + return self._scm.create_patch(git_commit, changed_files=changed_files) After this change, check-webkit-style doesn't work for me. $ Tools/Scripts/check-webkit-style Traceback (most recent call last): File "Tools/Scripts/check-webkit-style", line 134, in <module> main() File "Tools/Scripts/check-webkit-style", line 119, in main patch = checkout.create_patch(options.git_commit, changed_files=changed_files) File "/home/oszi/WebKit/Tools/Scripts/webkitpy/style_references.py", line 73, in create_patch return self._scm.create_patch(git_commit, changed_files=changed_files) File "/home/oszi/WebKit/Tools/Scripts/webkitpy/common/checkout/scm.py", line 748, in create_patch return self.run(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit), "--"] + changed_files, decode_output=False, cwd=self.checkout_root) TypeError: can only concatenate list (not "NoneType") to list
Eric Seidel (no email)
Comment 17 2011-01-13 12:31:24 PST
I suspect that Git.create_patch is lame and doens't understand None as a default argument.
Peter Gal
Comment 18 2011-01-13 13:02:19 PST
Created attachment 78847 [details] proposed fix I wasn't able to test it (don't have a git repo at hand), but with this it should work.
Eric Seidel (no email)
Comment 19 2011-01-13 13:31:40 PST
Comment on attachment 78847 [details] proposed fix Testing should be easy. I can help if necessary.
Peter Gal
Comment 20 2011-01-13 15:00:04 PST
(In reply to comment #19) > (From update of attachment 78847 [details]) > Testing should be easy. I can help if necessary. Well I've checked out a git repo and with my patch it works fine. Also after running Tools/Scripts/test-webkitpy webkitpy.common.checkout.scm_unittest.GitSVNTest there was only one failed test, but it was present before the patch.
Eric Seidel (no email)
Comment 21 2011-01-13 15:03:11 PST
Yes, it's likely that scm_unittest.py already has failures because it's only run when --all is passed to test-webkitpy. In this case, you are only really expected to add a new test for this case which woudl be part of scm_unittest.py but would not use a real svn or git repo (like some of the other tests do) and instead pass a MockExecutive to Git() and validate that the right commands are made (using OutputCapture). Again, I'm happy to help. You stumbled on a rather archaic piece of our testing infrastructure sadly.
Eric Seidel (no email)
Comment 22 2011-01-14 02:59:01 PST
Adam Barth
Comment 23 2011-01-14 03:19:48 PST
Comment on attachment 78921 [details] Patch THEY SAID IT COULDN'T BE DONE.
Adam Barth
Comment 24 2011-01-14 03:20:23 PST
Someday we might have SCM tests that aren't amazingly slow. :)
Peter Gal
Comment 25 2011-01-14 04:13:04 PST
(In reply to comment #22) > Created an attachment (id=78921) [details] > Patch Cool. Thanks for adding the testcase.
WebKit Commit Bot
Comment 26 2011-01-14 04:33:43 PST
Comment on attachment 78921 [details] Patch Clearing flags on attachment: 78921 Committed r75787: <http://trac.webkit.org/changeset/75787>
WebKit Commit Bot
Comment 27 2011-01-14 04:33:50 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.