# HG changeset patch # User Marcin Kuzminski # Date 2020-10-15 07:21:49 # Node ID 5d43c7d2d10b6a2d77a0cb0a6032cbc48967cc20 # Parent bf38af4fba0fb68b53e1a81753b2d95e9453fee9 api: fixed SVN raw diff export. The API method was incosistent, and used different logic. Now it shares the same code as raw-diff from web-ui diff --git a/rhodecode/api/utils.py b/rhodecode/api/utils.py --- a/rhodecode/api/utils.py +++ b/rhodecode/api/utils.py @@ -351,7 +351,10 @@ def get_pull_request_or_error(pullreques return pull_request -def build_commit_data(commit, detail_level): +def build_commit_data(rhodecode_vcs_repo, commit, detail_level): + commit2 = commit + commit1 = commit.first_parent + parsed_diff = [] if detail_level == 'extended': for f_path in commit.added_paths: @@ -362,8 +365,11 @@ def build_commit_data(commit, detail_lev parsed_diff.append(_get_commit_dict(filename=f_path, op='D')) elif detail_level == 'full': - from rhodecode.lib.diffs import DiffProcessor - diff_processor = DiffProcessor(commit.diff()) + from rhodecode.lib import diffs + + _diff = rhodecode_vcs_repo.get_diff(commit1, commit2,) + diff_processor = diffs.DiffProcessor(_diff, format='newdiff', show_full_diff=True) + for dp in diff_processor.prepare(): del dp['stats']['ops'] _stats = dp['stats'] diff --git a/rhodecode/api/views/repo_api.py b/rhodecode/api/views/repo_api.py --- a/rhodecode/api/views/repo_api.py +++ b/rhodecode/api/views/repo_api.py @@ -317,17 +317,18 @@ def get_repo_changeset(request, apiuser, 'ret_type must be one of %s' % ( ','.join(_changes_details_types))) + vcs_repo = repo.scm_instance() pre_load = ['author', 'branch', 'date', 'message', 'parents', 'status', '_commit', '_file_paths'] try: - cs = repo.get_commit(commit_id=revision, pre_load=pre_load) + commit = repo.get_commit(commit_id=revision, pre_load=pre_load) except TypeError as e: raise JSONRPCError(safe_str(e)) - _cs_json = cs.__json__() - _cs_json['diff'] = build_commit_data(cs, changes_details) + _cs_json = commit.__json__() + _cs_json['diff'] = build_commit_data(vcs_repo, commit, changes_details) if changes_details == 'full': - _cs_json['refs'] = cs._get_refs() + _cs_json['refs'] = commit._get_refs() return _cs_json @@ -398,7 +399,7 @@ def get_repo_changesets(request, apiuser if cnt >= limit != -1: break _cs_json = commit.__json__() - _cs_json['diff'] = build_commit_data(commit, changes_details) + _cs_json['diff'] = build_commit_data(vcs_repo, commit, changes_details) if changes_details == 'full': _cs_json['refs'] = { 'branches': [commit.branch],