# HG changeset patch # User Marcin Kuzminski # Date 2019-12-06 11:30:54 # Node ID 603689e4487038b7da408118f2f4db5f51a350d9 # Parent 1e7d835f81a110a27ced8960b7a49a52eea1ccc3 pull-requests: handle case when removing existing files from a repository in versioning diff. diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -970,8 +970,13 @@ class PullRequestModel(BaseModel): old_hash = old_files.get(new_filename) if not old_hash: - # file is not present in old diff, means it's added - added_files.append(new_filename) + # file is not present in old diff, we have to figure out from parsed diff + # operation ADD/REMOVE + operations_dict = diff_data['stats']['ops'] + if diffs.DEL_FILENODE in operations_dict: + removed_files.append(new_filename) + else: + added_files.append(new_filename) else: if new_hash != old_hash: modified_files.append(new_filename)