Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3EBE210CC1 for ; Fri, 13 Sep 2013 02:19:19 +0000 (UTC) Received: (qmail 80457 invoked by uid 500); 12 Sep 2013 20:53:03 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 78723 invoked by uid 500); 12 Sep 2013 20:52:24 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 78084 invoked by uid 99); 12 Sep 2013 20:51:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 20:51:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7BC651661C; Thu, 12 Sep 2013 20:51:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tvansteenburgh@apache.org To: allura-commits@incubator.apache.org Date: Thu, 12 Sep 2013 20:52:02 -0000 Message-Id: In-Reply-To: <1a519fc425a04cefafad0bdff9ac2877@git.apache.org> References: <1a519fc425a04cefafad0bdff9ac2877@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/29] git commit: [#5775] ticket:404 using diff.renamed now [#5775] ticket:404 using diff.renamed now Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2d81595e Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2d81595e Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2d81595e Branch: refs/heads/tv/6457 Commit: 2d81595ecc43f7f7ec4398cc79e8d6fa74bdc49e Parents: a6dccae Author: Anton Kasyanov Authored: Tue Aug 6 12:40:36 2013 +0300 Committer: Tim Van Steenburgh Committed: Thu Aug 29 19:00:45 2013 +0000 ---------------------------------------------------------------------- ForgeGit/forgegit/model/git_repo.py | 41 +++++++++----------------------- 1 file changed, 11 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2d81595e/ForgeGit/forgegit/model/git_repo.py ---------------------------------------------------------------------- diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py index fc7be67..ade299e 100644 --- a/ForgeGit/forgegit/model/git_repo.py +++ b/ForgeGit/forgegit/model/git_repo.py @@ -301,10 +301,7 @@ class GitImplementation(M.RepositoryImplementation): path = path.strip('/') if path else None if exclude is not None: revs.extend(['^%s' % e for e in exclude]) - args = [revs, '--', path] - if path: - args.append('--follow') - for ci, refs in self._iter_commits_with_refs(*args): + for ci, refs in self._iter_commits_with_refs([revs, '--', path]): if id_only: yield ci.hexsha else: @@ -312,29 +309,17 @@ class GitImplementation(M.RepositoryImplementation): renamed_from = {} if path: # checking for renaming in this commit - # log is called with follow, so there should be all commits - # even before renaming if ci.parents: - diffs_with_parent = ci.diff(ci.parents[0]) - deleted_file_diffs = [] - renamed = False - for diff in diffs_with_parent: - if not diff.b_mode and not diff.b_blob: - #new file was created - if diff.a_blob.name == os.path.basename(path): - renamed = True - if not diff.a_mode and not diff.a_blob: - #file was deleted - deleted_file_diffs.append(diff) - if renamed: - if len(deleted_file_diffs) > 1: - log.info('Couldn\'t find if file was renamed: too many deletions') - elif len(deleted_file_diffs) == 1: - deleted_diff = deleted_file_diffs[0] - renamed_from['path'] = '{}/{}'.format( - os.path.dirname(path), - deleted_diff.b_blob.name, - ) + # without create_path=True, renames are not detected + # see diff() doc from git/diff.py + diff_with_parent = ci.diff( + ci.parents[0], + create_patch=True + )[0] + # since we do diff with previous commit (not next) + # rename_from and rename_to are interchanged + if diff_with_parent.renamed and diff_with_parent.rename_from == path: + renamed_from['path'] = '/' + diff_with_parent.rename_to renamed_from['commit_url'] = self._repo.url_for_commit( ci.hexsha ) @@ -361,10 +346,6 @@ class GitImplementation(M.RepositoryImplementation): 'size': size, 'renamed_from': renamed_from, } - if renamed_from: - # if file was renamed, do not yield commits - # before renaming - break def _iter_commits_with_refs(self, *args, **kwargs): """