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
This commit is contained in:
parent
2195ed33ab
commit
1bfda61f13
2 changed files with 15 additions and 8 deletions
|
|
@ -351,7 +351,10 @@ def get_pull_request_or_error(pullrequestid):
|
||||||
return pull_request
|
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 = []
|
parsed_diff = []
|
||||||
if detail_level == 'extended':
|
if detail_level == 'extended':
|
||||||
for f_path in commit.added_paths:
|
for f_path in commit.added_paths:
|
||||||
|
|
@ -362,8 +365,11 @@ def build_commit_data(commit, detail_level):
|
||||||
parsed_diff.append(_get_commit_dict(filename=f_path, op='D'))
|
parsed_diff.append(_get_commit_dict(filename=f_path, op='D'))
|
||||||
|
|
||||||
elif detail_level == 'full':
|
elif detail_level == 'full':
|
||||||
from rhodecode.lib.diffs import DiffProcessor
|
from rhodecode.lib import diffs
|
||||||
diff_processor = DiffProcessor(commit.diff())
|
|
||||||
|
_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():
|
for dp in diff_processor.prepare():
|
||||||
del dp['stats']['ops']
|
del dp['stats']['ops']
|
||||||
_stats = dp['stats']
|
_stats = dp['stats']
|
||||||
|
|
|
||||||
|
|
@ -317,17 +317,18 @@ def get_repo_changeset(request, apiuser, repoid, revision,
|
||||||
'ret_type must be one of %s' % (
|
'ret_type must be one of %s' % (
|
||||||
','.join(_changes_details_types)))
|
','.join(_changes_details_types)))
|
||||||
|
|
||||||
|
vcs_repo = repo.scm_instance()
|
||||||
pre_load = ['author', 'branch', 'date', 'message', 'parents',
|
pre_load = ['author', 'branch', 'date', 'message', 'parents',
|
||||||
'status', '_commit', '_file_paths']
|
'status', '_commit', '_file_paths']
|
||||||
|
|
||||||
try:
|
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:
|
except TypeError as e:
|
||||||
raise JSONRPCError(safe_str(e))
|
raise JSONRPCError(safe_str(e))
|
||||||
_cs_json = cs.__json__()
|
_cs_json = commit.__json__()
|
||||||
_cs_json['diff'] = build_commit_data(cs, changes_details)
|
_cs_json['diff'] = build_commit_data(vcs_repo, commit, changes_details)
|
||||||
if changes_details == 'full':
|
if changes_details == 'full':
|
||||||
_cs_json['refs'] = cs._get_refs()
|
_cs_json['refs'] = commit._get_refs()
|
||||||
return _cs_json
|
return _cs_json
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -398,7 +399,7 @@ def get_repo_changesets(request, apiuser, repoid, start_rev, limit,
|
||||||
if cnt >= limit != -1:
|
if cnt >= limit != -1:
|
||||||
break
|
break
|
||||||
_cs_json = commit.__json__()
|
_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':
|
if changes_details == 'full':
|
||||||
_cs_json['refs'] = {
|
_cs_json['refs'] = {
|
||||||
'branches': [commit.branch],
|
'branches': [commit.branch],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue