Commit de800ff7 authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent 07d44398
...@@ -143,6 +143,7 @@ class RawCheckout(CheckoutBase): ...@@ -143,6 +143,7 @@ class RawCheckout(CheckoutBase):
"""Ignores svn properties.""" """Ignores svn properties."""
post_processors = post_processors or self.post_processors or [] post_processors = post_processors or self.post_processors or []
for p in patches: for p in patches:
logging.debug('Applying %s' % p.filename)
try: try:
stdout = '' stdout = ''
filename = os.path.join(self.project_path, p.filename) filename = os.path.join(self.project_path, p.filename)
...@@ -301,6 +302,7 @@ class SvnCheckout(CheckoutBase, SvnMixIn): ...@@ -301,6 +302,7 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
def apply_patch(self, patches, post_processors=None): def apply_patch(self, patches, post_processors=None):
post_processors = post_processors or self.post_processors or [] post_processors = post_processors or self.post_processors or []
for p in patches: for p in patches:
logging.debug('Applying %s' % p.filename)
try: try:
# It is important to use credentials=False otherwise credentials could # It is important to use credentials=False otherwise credentials could
# leak in the error message. Credentials are not necessary here for the # leak in the error message. Credentials are not necessary here for the
...@@ -507,6 +509,7 @@ class GitCheckoutBase(CheckoutBase): ...@@ -507,6 +509,7 @@ class GitCheckoutBase(CheckoutBase):
['checkout', '-b', self.working_branch, ['checkout', '-b', self.working_branch,
'%s/%s' % (self.remote, self.remote_branch), '--quiet']) '%s/%s' % (self.remote, self.remote_branch), '--quiet'])
for index, p in enumerate(patches): for index, p in enumerate(patches):
logging.debug('Applying %s' % p.filename)
try: try:
stdout = '' stdout = ''
if p.is_delete: if p.is_delete:
......
...@@ -503,11 +503,13 @@ class PatchSet(object): ...@@ -503,11 +503,13 @@ class PatchSet(object):
File move are first. File move are first.
Deletes are last. Deletes are last.
""" """
if p.source_filename: # The bool is necessary because None < 'string' but the reverse is needed.
return (p.is_delete, p.source_filename_utf8, p.filename_utf8) return (
else: p.is_delete,
# tuple are always greater than string, abuse that fact. # False is before True, so files *with* a source file will be first.
return (p.is_delete, (p.filename_utf8,), p.filename_utf8) not bool(p.source_filename),
p.source_filename_utf8,
p.filename_utf8)
self.patches = sorted(patches, key=key) self.patches = sorted(patches, key=key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment