Fix the patch application sorting.

It relied on a behavior that doesn't hold on python 2.7 anymore w.r.t. tuple
comparison to non-tuple objects.

Now be explicit about having source files to be first.

R=rogerta@chromium.org
BUG=


Review URL: https://chromiumcodereview.appspot.com/10915240

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@156355 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/patch.py b/patch.py
index e7bf566..44282dd 100644
--- a/patch.py
+++ b/patch.py
@@ -503,11 +503,13 @@
       File move are first.
       Deletes are last.
       """
-      if p.source_filename:
-        return (p.is_delete, p.source_filename_utf8, p.filename_utf8)
-      else:
-        # tuple are always greater than string, abuse that fact.
-        return (p.is_delete, (p.filename_utf8,), p.filename_utf8)
+      # The bool is necessary because None < 'string' but the reverse is needed.
+      return (
+          p.is_delete,
+          # False is before True, so files *with* a source file will be first.
+          not bool(p.source_filename),
+          p.source_filename_utf8,
+          p.filename_utf8)
 
     self.patches = sorted(patches, key=key)