Mercurial > kallithea
changeset 3718:b2575bdb847c beta
diffs: drop diffs.differ
This function did not really add any value, it was yet another layer that was
hiding the bug that we use ref[1] without ref[0], and it had this strange
undefined behaviour for diffing across repos.
Inlining the call to .get_diff do not make the code more complex but makes it
more obvious what is going on so it can be cleaned up later.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 05 Apr 2013 00:40:58 +0200 |
parents | 6ff98871247a |
children | 3534e75b2d5b |
files | rhodecode/controllers/compare.py rhodecode/controllers/pullrequests.py rhodecode/lib/diffs.py |
diffstat | 3 files changed, 9 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/compare.py Fri Apr 05 02:51:37 2013 +0200 +++ b/rhodecode/controllers/compare.py Fri Apr 05 00:40:58 2013 +0200 @@ -161,7 +161,10 @@ diff_limit = self.cut_off_limit if not c.fulldiff else None - _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) + log.debug('running diff between %s@%s and %s@%s' + % (org_repo.scm_instance.path, org_ref, + other_repo.scm_instance.path, other_ref)) + _diff = org_repo.scm_instance.get_diff(rev1=safe_str(org_ref[1]), rev2=safe_str(other_ref[1])) diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', diff_limit=diff_limit)
--- a/rhodecode/controllers/pullrequests.py Fri Apr 05 02:51:37 2013 +0200 +++ b/rhodecode/controllers/pullrequests.py Fri Apr 05 00:40:58 2013 +0200 @@ -42,6 +42,7 @@ from rhodecode.lib import helpers as h from rhodecode.lib import diffs from rhodecode.lib.utils import action_logger, jsonify +from rhodecode.lib.vcs.utils import safe_str from rhodecode.lib.vcs.exceptions import EmptyRepositoryError from rhodecode.lib.vcs.backends.base import EmptyChangeset from rhodecode.lib.diffs import LimitedDiffContainer @@ -328,7 +329,10 @@ diff_limit = self.cut_off_limit if not fulldiff else None #we swap org/other ref since we run a simple diff on one repo - _diff = diffs.differ(org_repo, other_ref, other_repo, org_ref) + log.debug('running diff between %s@%s and %s@%s' + % (org_repo.scm_instance.path, org_ref, + other_repo.scm_instance.path, other_ref)) + _diff = org_repo.scm_instance.get_diff(rev1=safe_str(org_ref[1]), rev2=safe_str(other_ref[1])) diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', diff_limit=diff_limit)
--- a/rhodecode/lib/diffs.py Fri Apr 05 02:51:37 2013 +0200 +++ b/rhodecode/lib/diffs.py Fri Apr 05 00:40:58 2013 +0200 @@ -682,36 +682,3 @@ Returns tuple of added, and removed lines for this instance """ return self.adds, self.removes - - -def differ(org_repo, org_ref, other_repo, other_ref, - context=3, ignore_whitespace=False): - """ - General differ between branches, bookmarks, revisions of two remote or - local but related repositories - - :param org_repo: - :param org_ref: - :param other_repo: - :type other_repo: - :type other_ref: - """ - - org_repo_scm = org_repo.scm_instance - other_repo_scm = other_repo.scm_instance - - org_repo = org_repo_scm._repo - other_repo = other_repo_scm._repo - - org_ref = safe_str(org_ref[1]) - other_ref = safe_str(other_ref[1]) - - if org_repo_scm == other_repo_scm: - log.debug('running diff between %s@%s and %s@%s' - % (org_repo.path, org_ref, - other_repo.path, other_ref)) - _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref, - ignore_whitespace=ignore_whitespace, context=context) - return _diff - - return '' # FIXME: when is it ever relevant to return nothing?