Bug 9322 - Teach svn-create-patch to sort its output
Summary: Teach svn-create-patch to sort its output
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-05 22:14 PDT by David Kilzer (:ddkilzer)
Modified: 2006-06-06 20:09 PDT (History)
0 users

See Also:


Attachments
Patch v1 (7.69 KB, patch)
2006-06-05 22:36 PDT, David Kilzer (:ddkilzer)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2006-06-05 22:14:29 PDT
After Bug 9299 landed, there were still a few improvements to make (see Bug 9299 Comment #5).  This bug handles sorting the output of svn-create-patch so that binary files appear after text file patches, and the patches appear in alphabetical (and deterministic) order.
Comment 1 David Kilzer (:ddkilzer) 2006-06-05 22:36:13 PDT
Created attachment 8725 [details]
Patch v1

I took no prisoners in cleaning up the perl code, but I may have been too aggressive.  (I was tempted to remove 'use' statements, too, but held off.)  Changes (in no particular order):

- Sorted 'use' statements alphabetically.
- Reworded some die() messages.
- Extracted path canonicalization to canonicalizePath() method and switched to using standard Perl modules instead of regular expressions assuming forward slashes.
- Moved non-subroutine code together (or moved all subroutines to the end of the file) and added an 'exit 0;' statement so you know where the main code ends.  Subroutines are alphabetized.
- Moved list-of-path cleanup into the else block of the first if/else statement because it's only needed there.  If no arguments are given, "." is used by default and is the only path needed.  Changed a while() loop to a for() loop since I thought it read better; also replaced another regex with dirname().
- Created new generateFileList() subroutine.  It uses "svn diff" instead of "svn stat" since (a) "svn diff" was roughly 4x faster than "svn stat" in a local test and (b) it's easier to know if a file is binary or not using "svn diff".
- Completely gutted diff() and renamed to generateDiff().  It only has to handle creating a patch for one file at a time now.  I also removed all of the chdir() business since Subversion handles the full paths quite nicely.  That cleaned up a lot of logic in the patch path fix-up as well.  Should I have kept this code?
Comment 2 Darin Adler 2006-06-06 09:42:38 PDT
Comment on attachment 8725 [details]
Patch v1

Looks fine. But I think it would be even better if it used the sort from run-webkit-tests. It's called "pathcmp".

r=me
Comment 3 David Kilzer (:ddkilzer) 2006-06-06 20:09:54 PDT
Committed revision 14758.