Skip to content

Commit

Permalink
Merge branch 'release-1.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidt committed Feb 8, 2019
2 parents 2acc962 + c008624 commit 9170ec4
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 16 deletions.
3 changes: 2 additions & 1 deletion rbtools/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SCMClient(object):
supports_commit_history = False
supports_diff_extra_args = False
supports_diff_exclude_patterns = False
supports_no_renames = False
supports_patch_revert = False

can_amend_commit = False
Expand Down Expand Up @@ -206,7 +207,7 @@ def parse_revision_spec(self, revisions=[]):
}

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff using the given revisions.
This is expected to be overridden by subclasses.
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _get_revno(self, revision_spec=None):
return 'revno:%s:%s' % (result[1], branch)

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff using the given revisions.
If the revision spec is empty, this returns the diff of the current
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/clearcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def _get_label_changeset(self, labels):
return changeset

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff using the given revisions.
Args:
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/cvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def parse_revision_spec(self, revisions=[]):
}

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff using the given revisions.
If no revisions are specified, this will return the diff for the
Expand Down
14 changes: 9 additions & 5 deletions rbtools/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class GitClient(SCMClient):

supports_commit_history = True
supports_diff_exclude_patterns = True
supports_no_renames = True
supports_patch_revert = True

can_amend_commit = True
Expand Down Expand Up @@ -580,7 +581,7 @@ def _rev_list_youngest_remote_ancestor(self, local_branch, remote):
return youngest_remote_commit

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[], with_parent_diff=True):
no_renames=False, extra_args=[], with_parent_diff=True):
"""Perform a diff using the given revisions.
If no revisions are specified, this will do a diff of the contents of
Expand Down Expand Up @@ -643,14 +644,16 @@ def diff(self, revisions, include_files=[], exclude_patterns=[],
revisions['base'],
revisions['tip'],
include_files,
exclude_patterns)
exclude_patterns,
no_renames)

if 'parent_base' in revisions and with_parent_diff:
parent_diff_lines = self.make_diff(merge_base,
revisions['parent_base'],
revisions['base'],
include_files,
exclude_patterns)
exclude_patterns,
no_renames)

base_commit_id = revisions['parent_base']
else:
Expand All @@ -665,7 +668,7 @@ def diff(self, revisions, include_files=[], exclude_patterns=[],
}

def make_diff(self, merge_base, base, tip, include_files,
exclude_patterns):
exclude_patterns, no_renames=False):
"""Perform a diff on a particular branch range.
Args:
Expand Down Expand Up @@ -709,7 +712,8 @@ def make_diff(self, merge_base, base, tip, include_files,
if self._supports_git_config_flag():
git_cmd.extend(['-c', 'diff.noprefix=false'])

if (self.capabilities is not None and
if (not no_renames and
self.capabilities is not None and
self.capabilities.has_capability('diffs', 'moved_files')):
diff_cmd_params.append('-M')
else:
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def get_raw_commit_message(self, revisions):
return b'\n\n'.join([desc.strip() for desc in descs])

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[], with_parent_diff=True):
no_renames=False, extra_args=[], with_parent_diff=True):
"""Perform a diff using the given revisions.
Args:
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/perforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def scan_for_server_counter(self, repository_info):
return None

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff using the given revisions.
This goes through the hard work of generating a diff on Perforce in
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/plastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def parse_revision_spec(self, revisions=[]):
raise TooManyRevisionsError

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff across all modified files in a Plastic workspace.
Parent diffs are not supported (the second value in the tuple).
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def get_raw_commit_message(self, revisions):
return '\n\n'.join(message.text for message in messages)

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Perform a diff in a Subversion repository.
If the given revision spec is empty, this will do a diff of the
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/tfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def parse_revision_spec(self, revisions):
return self.tf_wrapper.parse_revision_spec(revisions)

def diff(self, revisions, include_files=[], exclude_patterns=[],
extra_args=[]):
no_renames=False, extra_args=[]):
"""Return the generated diff.
Args:
Expand Down
8 changes: 8 additions & 0 deletions rbtools/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ class Command(object):
description='Options for choosing what gets included in a diff, '
'and how the diff is generated.',
option_list=[
Option('--no-renames',
dest='no_renames',
action='store_true',
help='Add the --no-renames option to the git when '
'generating diff.'
'\n'
'Supported by: Git',
added_in='0.7.11'),
Option('--revision-range',
dest='revision_range',
metavar='REV1:REV2',
Expand Down
5 changes: 5 additions & 0 deletions rbtools/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ def main(self, *args):
'-X/--exclude commandline options or the EXCLUDE_PATTERNS '
'.reviewboardrc option.' % tool.name)

if self.options.no_renames and not tool.supports_no_renames:
raise CommandError('The %s SCM tool does not support diffs '
'without renames.', tool.type)

diff_info = tool.diff(
revisions=revisions,
include_files=self.options.include_files or [],
exclude_patterns=self.options.exclude_patterns or [],
no_renames=self.options.no_renames,
extra_args=extra_args)

diff = diff_info['diff']
Expand Down
5 changes: 4 additions & 1 deletion rbtools/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import re

import texttable as tt
from backports.shutil_get_terminal_size import get_terminal_size
try:
from backports.shutil_get_terminal_size import get_terminal_size
except ImportError:
from shutil import get_terminal_size

from rbtools.commands import Command, Option
from rbtools.utils.repository import get_repository_id
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
'rbtools_scm_clients': scm_clients,
},
install_requires=[
'backports.shutil_get_terminal_size',
'backports.shutil_get_terminal_size; python_version<"3.0"',
'colorama',
'six>=1.8.0',
'texttable',
Expand Down

0 comments on commit 9170ec4

Please sign in to comment.