Skip to content

Commit

Permalink
Merge branch 'release-2.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
chipx86 committed Nov 21, 2020
2 parents 94290a1 + 44e698a commit bbf8ffb
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 12 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Contributors:
* Damian
* Dana Lacoste
* Daniel Cestari
* Daniel Fox
* Daniel LaMotte
* Dan Savilonis
* Dave Druska
Expand Down
13 changes: 13 additions & 0 deletions docs/releasenotes/2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ self-signed certificates. This is done by specifying the :option:`--ca-certs`,
Patch by Alessandro.


rbt diff
--------

* Fixed outputting diffs that contained non-UTF-8 content on Python 3.

Patch by Daniel Fox.


rbt land
--------

Expand All @@ -70,6 +78,10 @@ rbt patch

Patch by André Klitzing.

* Fixed outputting diffs that contained non-UTF-8 content on Python 3.

Patch by Daniel Fox.


rbt status
----------
Expand Down Expand Up @@ -193,6 +205,7 @@ Contributors
* Boris Krasnovskiy
* Cecilia Wei
* Christian Hammond
* Daniel Fox
* David Trowbridge
* Joshua Olson
* Katherine Patenio
Expand Down
7 changes: 5 additions & 2 deletions rbtools/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,11 @@ def apply_patch(self, patch_file, base_path=None, base_dir=None, p=None,

cmd.append(patch_file)

rc, data = self._execute(cmd, ignore_errors=True, with_errors=True,
return_error_code=True)
rc, data = self._execute(cmd,
ignore_errors=True,
with_errors=True,
return_error_code=True,
results_unicode=False)

if rc == 0:
return PatchResult(applied=True, patch_output=data)
Expand Down
7 changes: 4 additions & 3 deletions rbtools/clients/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ def _handle_empty_files(self, diff_content, diff_cmd, revisions):

if not revisions['base'] and not revisions['tip']:
tip = '(working copy)'
info = self.svn_info(filename, ignore_errors=True)
info = self.svn_info(filename.decode('utf-8'),
ignore_errors=True)

if info and 'Revision' in info:
base = '(revision %s)' % info['Revision']
Expand All @@ -789,9 +790,9 @@ def _handle_empty_files(self, diff_content, diff_cmd, revisions):
tip = revisions['tip']

result.append(b'%s\n' % self.INDEX_SEP)
result.append(b'--- %s\t%s\n' % (filename.encode(_fs_encoding),
result.append(b'--- %s\t%s\n' % (filename,
base.encode('utf-8')))
result.append(b'+++ %s\t%s\n' % (filename.encode(_fs_encoding),
result.append(b'+++ %s\t%s\n' % (filename,
tip.encode('utf-8')))

# Skip the next line (the index separator) since we've already
Expand Down
6 changes: 5 additions & 1 deletion rbtools/commands/diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import print_function, unicode_literals

import sys

from rbtools.clients.errors import InvalidRevisionSpecError
from rbtools.commands import Command, CommandError

Expand Down Expand Up @@ -92,4 +94,6 @@ def main(self, *args):
if six.PY2:
print(diff)
else:
print(diff.decode('utf-8'))
# Write the non-decoded binary diff to standard out
sys.stdout.buffer.write(diff)
print()
22 changes: 19 additions & 3 deletions rbtools/commands/land.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,20 @@ class Land(Command):
Command.branch_options,
]

def patch(self, review_request_id):
"""Patch a single review request's diff using rbt patch."""
def patch(self, review_request_id, squash=False):
"""Patch a single review request's diff using rbt patch.
Args:
review_request_id (int):
The ID of the review request to patch.
squash (bool, optional):
Whether to squash multiple commits into a single commit.
Raises:
rbtools.commands.CommandError:
There was an error applying the patch.
"""
patch_command = [RB_MAIN, 'patch']
patch_command.extend(build_rbtools_cmd_argv(self.options))

Expand All @@ -129,6 +141,9 @@ def patch(self, review_request_id):
else:
patch_command.append('-C')

if squash:
patch_command.append('--squash')

patch_command.append(six.text_type(review_request_id))

rc, output = execute(patch_command, ignore_errors=True,
Expand Down Expand Up @@ -230,7 +245,8 @@ def land(self, destination_branch, review_request, source_branch=None,
print('Applying patch from review request %s.' % review_request.id)

if not dry_run:
self.patch(review_request.id)
self.patch(review_request.id,
squash=squash)

print('Review request %s has landed on "%s".' %
(review_request.id, self.options.destination_branch))
Expand Down
19 changes: 16 additions & 3 deletions rbtools/commands/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import os
import re
import sys
from gettext import gettext as _, ngettext

import six
Expand Down Expand Up @@ -340,7 +341,15 @@ def apply_patch(self, diff_file_path, base_dir, patch_num, total_patches,

if result.patch_output:
print()
print(result.patch_output.strip())

patch_output = result.patch_output.strip()

if six.PY2:
print(patch_output)
else:
sys.stdout.buffer.write(patch_output)
print()

print()

if not result.applied:
Expand Down Expand Up @@ -483,9 +492,13 @@ def _output_patches(self, patches):
diff_body = patch_data['diff']

if isinstance(diff_body, bytes):
logger.info(diff_body.decode('utf-8'))
if six.PY3:
sys.stdout.buffer.write(diff_body)
print()
else:
print(diff_body.decode('utf-8'))
else:
logger.info(diff_body)
print(diff_body)

def _apply_patches(self, patches):
"""Apply a list of patches to the tree.
Expand Down

0 comments on commit bbf8ffb

Please sign in to comment.