You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/08/20 18:57:56 UTC

[8/9] allura git commit: [#7963] Add copy detection option for commit view

[#7963] Add copy detection option for commit view


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/55ab72b7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/55ab72b7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/55ab72b7

Branch: refs/heads/hs/7963
Commit: 55ab72b740d369e5dfcb79525a015a2e385ebd43
Parents: 1cb99fa
Author: Heith Seewald <hs...@hsmb.local>
Authored: Tue Aug 18 12:41:59 2015 -0400
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Thu Aug 20 12:56:27 2015 -0400

----------------------------------------------------------------------
 Allura/development.ini              |  4 ++++
 ForgeGit/forgegit/model/git_repo.py | 26 +++++++++++++-------------
 2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/55ab72b7/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 934ea67..af7b5f6 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -313,6 +313,10 @@ scm.import.retry_sleep_secs = 5
 ; Set to 0 to cache all references. Remove entirely to cache nothing.
 repo_refs_cache_threshold = .01
 
+; Enabling copy detection will display copies and renames in the commit views
+; at the expense of much longer response times.
+scm.commits.detect_copies = false
+
 ; One-click merge is enabled by default, but can be turned off on for each type of repo
 scm.merge.git.disabled = false
 scm.merge.hg.disabled = false

http://git-wip-us.apache.org/repos/asf/allura/blob/55ab72b7/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8229b7e..14374a6 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -647,18 +647,18 @@ class GitImplementation(M.RepositoryImplementation):
 
     def paged_diffs(self, commit_id, start=0, end=None):
         result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': []}
-
-        cmd_output = self._git.git.diff_tree(
-            '--no-commit-id',
-            '-M',  # detect renames
-            '-C',  # detect copies
-            '--name-status',
-            '--no-abbrev',
-            '--root',
-            # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
-            '-t',
-            '-z',  # don't escape filenames and use \x00 as fields delimiter
-            commit_id).split('\x00')[:-1]
+        cmd_args = ['--no-commit-id',
+                    '--name-status',
+                    '--no-abbrev',
+                    '--root',
+                    # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
+                    '-t',
+                    '-z'  # don't escape filenames and use \x00 as fields delimiter
+                    ]
+        if asbool(tg.config.get('scm.commits.detect_copies', False)):
+            cmd_args += ['-M', '-C']
+
+        cmd_output = self._git.git.diff_tree(commit_id, *cmd_args).split('\x00')[:-1]  # don't escape filenames and use \x00 as fields delimiter
 
         ''' cmd_output will be like:
         [
@@ -668,7 +668,7 @@ class GitImplementation(M.RepositoryImplementation):
         'another filename',
         'M',
         'po',
-        'R100',
+        'R100',  # <-- These next three lines would only show up with 'detect_copies' enabled
         'po/sr.po',
         'po/sr_Latn.po',
         ]