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/10 15:39:25 UTC

[01/18] allura git commit: [#7925] Update tests to work with new diff processing

Repository: allura
Updated Branches:
  refs/heads/master 032c2ed88 -> d8e7ade5d


[#7925] Update tests to work with new diff processing


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

Branch: refs/heads/master
Commit: 04b87c6612c2c1ae4b1dd933e7a7f3734d251228
Parents: 7f738bd
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Jul 27 16:08:05 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:35 2015 -0400

----------------------------------------------------------------------
 Allura/allura/tests/model/test_repo.py          |  2 +
 .../forgegit/tests/model/test_repository.py     | 10 ++++
 .../forgesvn/tests/model/test_repository.py     | 59 +++++++++++++-------
 3 files changed, 52 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/04b87c66/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index 1f6ec3c..c0a6bc8 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -143,6 +143,8 @@ class TestLastCommit(unittest.TestCase):
         self.repo.paged_diffs.return_value = {
             'added': [],
             'removed': [],
+            'copied': [],
+            'renamed': [],
             'changed': [],
             'total': 0,
         }

http://git-wip-us.apache.org/repos/asf/allura/blob/04b87c66/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 9f007e6..948f228 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -670,6 +670,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             'added': [u'with space.txt', u'привіт.txt'],
             'removed': [],
             'changed': [],
+            'copied': [],
+            'renamed': [],
             'total': 2,
         }
         assert_equals(diffs, expected)
@@ -678,6 +680,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         expected = {
             'added': [],
             'removed': [],
+            'copied': [],
+            'renamed': [],
             'changed': [u'привіт.txt'],
             'total': 1,
         }
@@ -689,6 +693,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             'added': [u'README.md'],
             'removed': [],
             'changed': [],
+            'copied': [],
+            'renamed': [],
             'total': 1,
         }
         assert_equals(diffs, expected)
@@ -698,6 +704,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         expected = {
             'added': [u'with space.txt'],
             'removed': [],
+            'copied': [],
+            'renamed': [],
             'changed': [],
             'total': 2,
         }
@@ -706,6 +714,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         expected = {
             'added': [u'привіт.txt'],
             'removed': [],
+            'copied': [],
+            'renamed': [],
             'changed': [],
             'total': 2,
         }

http://git-wip-us.apache.org/repos/asf/allura/blob/04b87c66/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 79beb52..9889a60 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -363,7 +363,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         self.assertEqual(entry.diffs, entry.paged_diffs(start=0))
         added_expected = entry.diffs.added[1:3]
         expected = dict(
-            copied=[], changed=[], removed=[],
+            copied=[], changed=[], removed=[], renamed=[],
             added=added_expected, total=4)
         actual = entry.paged_diffs(start=1, end=3)
         self.assertEqual(expected, actual)
@@ -376,7 +376,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         entry = self.repo.commit(self.repo.log(1, id_only=True).next())
         self.assertEqual(
             entry.diffs, dict(
-                copied=[], changed=[],
+                copied=[], changed=[], renamed=[],
                 removed=[], added=['/README'], total=1))
 
     def test_diff_create_path(self):
@@ -385,7 +385,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         actual.added = sorted(actual.added)
         self.assertEqual(
             entry.diffs, dict(
-                copied=[], changed=[], removed=[],
+                copied=[], changed=[], removed=[], renamed=[],
                 added=sorted([
                     '/a', '/a/b', '/a/b/c',
                     '/a/b/c/hello.txt']), total=4))
@@ -394,20 +394,20 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         entry = self.repo.commit(self.repo.log(3, id_only=True).next())
         self.assertEqual(
             entry.diffs, dict(
-                copied=[], changed=['/README'],
+                copied=[], changed=['/README'], renamed=[],
                 removed=[], added=[], total=1))
 
     def test_diff_delete(self):
         entry = self.repo.commit(self.repo.log(4, id_only=True).next())
         self.assertEqual(
             entry.diffs, dict(
-                copied=[], changed=[],
+                copied=[], changed=[], renamed=[],
                 removed=['/a/b/c/hello.txt'], added=[], total=1))
 
     def test_diff_copy(self):
         entry = self.repo.commit(self.repo.log(5, id_only=True).next())
         assert_equals(dict(entry.diffs), dict(
-                copied=[{'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1}],
+                copied=[{'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1}],  renamed=[],
                 changed=[], removed=[], added=[], total=1))
 
     def test_commit(self):
@@ -1002,6 +1002,8 @@ class TestCommit(_TestWithRepo):
         self.repo._impl.paged_diffs.return_value = {
             'added': ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'],
             'changed': [],
+            'copied': [],
+            'renamed': [],
             'removed': [],
             'total': 5,
         }
@@ -1024,6 +1026,8 @@ class TestCommit(_TestWithRepo):
         self._make_log(ci)
         self.repo._impl.paged_diffs.return_value = {
             'added': ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'],
+            'renamed': [],
+            'copied': [],
             'changed': [],
             'removed': ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'],
             'total': 10,
@@ -1044,25 +1048,38 @@ class TestCommit(_TestWithRepo):
         ci.parent_ids = ['bar']
         self._make_log(ci)
         self.repo._impl.paged_diffs.return_value = {
-            'added': ['b/c', 'b/a/z'],
+            'added': [u'b/c', u'b/a/z'],
+            'removed': [u'/b/a/b', u'b/b'],
             'changed': [],
-            'removed': ['b/a/b', 'b/b', 'b/a/a'],
-            'total': 10,
+            'copied': [
+                {
+                    'new': u'b/c',
+                    'old': u'b/a/b',
+                    'ratio': 1,
+                    'diff': '',
+                },
+                {
+                    'new': u'b/a/z',
+                    'old': u'b/b',
+                    'ratio': 1,
+                    'diff': '',
+                },
+            ],
+            'renamed': [],
+            'total': 2
         }
         M.repo_refresh.refresh_commit_trees(ci, {})
-        assert_equal(ci.diffs.added, [])
+        assert_equal(ci.diffs.added, [u'b/a/z', u'b/c'])
         assert_equal(ci.diffs.changed, [])
-        assert_equal(ci.diffs.removed, ['b/a/a'])
+        assert_equal(ci.diffs.removed, [u'/b/a/b', u'b/b'])
         # see mock for open_blob
         assert_equal(len(ci.diffs.copied), 2)
-        assert_equal(ci.diffs.copied[0]['old'], 'b/a/b')
-        assert_equal(ci.diffs.copied[0]['new'], 'b/c')
-        assert_equal(ci.diffs.copied[0]['ratio'], 1)
-        assert_equal(ci.diffs.copied[0]['diff'], '')
-        assert_equal(ci.diffs.copied[1]['old'], 'b/b')
-        assert_equal(ci.diffs.copied[1]['new'], 'b/a/z')
-        assert ci.diffs.copied[1]['ratio'] < 1, ci.diffs.copied[1]['ratio']
-        assert '+++' in ci.diffs.copied[1]['diff'], ci.diffs.copied[1]['diff']
+        assert_equal(ci.diffs.copied[1]['old'], 'b/a/b')
+        assert_equal(ci.diffs.copied[1]['new'], 'b/c')
+        assert_equal(ci.diffs.copied[1]['ratio'], 1)
+        assert_equal(ci.diffs.copied[1]['diff'], '')
+        assert_equal(ci.diffs.copied[0]['old'], 'b/b')
+        assert_equal(ci.diffs.copied[0]['new'], 'b/a/z')
 
     def test_context(self):
         self.ci.context()
@@ -1132,6 +1149,7 @@ class TestDirectRepoAccess(object):
             'removed': [],
             'changed': [],
             'copied': [],
+            'renamed': [],
             'total': 1,
         }
         assert_equals(diffs, expected)
@@ -1142,6 +1160,7 @@ class TestDirectRepoAccess(object):
             'added': [u'/a', u'/a/b', u'/a/b/c', u'/a/b/c/hello.txt'],
             'removed': [],
             'changed': [],
+            'renamed': [],
             'copied': [],
             'total': 4,
         }
@@ -1152,6 +1171,7 @@ class TestDirectRepoAccess(object):
         expected = {
             'added': [],
             'removed': [],
+            'renamed': [],
             'changed': [u'/README'],
             'copied': [],
             'total': 1,
@@ -1164,6 +1184,7 @@ class TestDirectRepoAccess(object):
             'added': [],
             'removed': ['/a/b/c/hello.txt'],
             'changed': [],
+            'renamed': [],
             'copied': [],
             'total': 1,
         }


[08/18] allura git commit: [#7925] remove --find-copies-harder due to false-positives

Posted by he...@apache.org.
[#7925] remove --find-copies-harder due to false-positives


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

Branch: refs/heads/master
Commit: 155e0b0fcdecedee1df4bb3fdcf394952c6f580d
Parents: 73385a8
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 16:09:59 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:36 2015 -0400

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/155e0b0f/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 9a8549a..ece0d6c 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -651,7 +651,6 @@ class GitImplementation(M.RepositoryImplementation):
             '--name-status',
             '--no-abbrev',
             '--root',
-            '--find-copies-harder',
             # 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


[04/18] allura git commit: [#7925] Speed up diff processing on commit browser page

Posted by he...@apache.org.
[#7925] Speed up diff processing on commit browser page


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

Branch: refs/heads/master
Commit: e252f5e1bf907e8fa886bb8fdffb0f05bc291df0
Parents: 032c2ed
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Jul 16 15:02:55 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:35 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py  |  3 ++-
 Allura/allura/model/repository.py        |  6 ++++++
 Allura/allura/templates/repo/commit.html | 14 ++++++++------
 3 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e252f5e1/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 2b9ae89..5d03f64 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -564,7 +564,8 @@ class CommitBrowser(BaseController):
                                              default=self.DEFAULT_PAGE_LIMIT)
         diffs = self._commit.paged_diffs(start=start, end=start + limit)
         result['artifacts'] = [
-            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree')
+            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree',
+            tree.get_blob_by_path(f) and tree.get_blob_by_path(f).is_text)
             for t in ('added', 'removed', 'changed', 'copied')
             for f in diffs[t]]
         count = diffs['total']

http://git-wip-us.apache.org/repos/asf/allura/blob/e252f5e1/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index b3c60b7..7bc36c1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1520,6 +1520,12 @@ class Blob(object):
         return self._content_type_encoding[0]
 
     @LazyProperty
+    def is_text(self):
+        """Return true if this blob is text."""
+
+        return self.content_type.startswith("text")
+
+    @LazyProperty
     def content_encoding(self):
         return self._content_type_encoding[1]
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e252f5e1/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 4870332..f029f52 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -113,7 +113,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
 {{c.page_list.display(page=page, limit=limit, count=count)}}
 <table>
   <tbody>
-    {% for type, file, _ in artifacts %}
+    {% for type, file, _, _ in artifacts %}
     <tr>
         <td>{{ type }}</td>
         <td><a href="#diff-{{loop.index}}">
@@ -128,9 +128,10 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
   </tbody>
 </table>
 
-{% for type, file, obj_type in artifacts %}
-        <div class="inline-diff">
-            <h6>
+    {% for type, file, obj_type, is_text in artifacts %}
+        {% if is_text %}
+            <div class="inline-diff">
+                <h6>
             {% if type in ('added', 'changed') %}
                 {% if obj_type == 'tree' %}
                     <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
@@ -169,6 +170,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                 {% endif %}
             </div>
         </div>
-{% endfor %}
-{{c.page_list.display(page=page, limit=limit, count=count)}}
+        {% endif %}
+    {% endfor %}
+    {{ c.page_list.display(page=page, limit=limit, count=count) }}
 {% endblock %}


[09/18] allura git commit: [#7925] simplify and de-bug git output processing by using a new var, no in-place updates to 'files'

Posted by he...@apache.org.
[#7925] simplify and de-bug git output processing by using a new var, no in-place updates to 'files'


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

Branch: refs/heads/master
Commit: 5adbb2858dd0f5ac189bc10dc85530e481380cba
Parents: 787ee90
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 16:12:23 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:36 2015 -0400

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 74 ++++++++++++++++++--------------
 1 file changed, 42 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5adbb285/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index ece0d6c..9462087 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -642,9 +642,9 @@ class GitImplementation(M.RepositoryImplementation):
             max_count=1).splitlines()[1:]
 
     def paged_diffs(self, commit_id, start=0, end=None):
-        result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': [], 'total': 0}
+        result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': []}
 
-        files = self._git.git.diff_tree(
+        cmd_output = self._git.git.diff_tree(
             '--no-commit-id',
             '--find-renames',
             '--find-copies',
@@ -656,39 +656,49 @@ class GitImplementation(M.RepositoryImplementation):
             '-z',  # don't escape filenames and use \x00 as fields delimiter
             commit_id).split('\x00')[:-1]
 
-        result['total'] = len(files) / 2
-        x = 0
-        while x < len(files):
-            try:
-                if files[x].startswith("R") or files[x].startswith("C"):
-                    change_list = result['renamed'] if files[x].startswith("R") else result['copied']
-                    ratio = float(files[x][1:4]) / 100.0
-                    change_list.append({
-                        'new': h.really_unicode(files[x + 2]),
-                        'old': h.really_unicode(files[x + 1]),
-                        'ratio': ratio,
-                        'diff': '',
-                    })
-                    del files[x:x+3]
-                    x += 3
-                    result['total'] -= 1
-                else:
-                    x += 2
-            except IndexError:
-                break
+        ''' cmd_output will be like:
+        [
+        'A',
+        'filename',
+        'D',
+        'another filename',
+        'M',
+        'po',
+        'R100',
+        'po/sr.po',
+        'po/sr_Latn.po',
+        ]
+        '''
 
-        files = [(files[i], h.really_unicode(files[i + 1]))
-                 for i in xrange(0, result['total'] + 1, 2)]
+        x = 0
+        files = []
+        while x < len(cmd_output):
+            status = cmd_output[x][0]
+            if status in ('R', 'C'):
+                # TODO: make sure we have a test for this
+                ratio = float(cmd_output[x][1:4]) / 100.0
+                files.append((status, {
+                    'new': h.really_unicode(cmd_output[x + 2]),
+                    'old': h.really_unicode(cmd_output[x + 1]),
+                    'ratio': ratio,
+                    'diff': '',
+                }))
+                x += 3
+            else:
+                files.append((status, h.really_unicode(cmd_output[x+1])))
+                x += 2
 
-        # files = [('A', u'filename'), ('D', u'another filename'), ...]
         for status, name in files[start:end]:
-            if status == 'A':
-                result['added'].append(name)
-            elif status == 'D':
-                result['removed'].append(name)
-            elif status == 'M':
-                result['changed'].append(name)
-
+            change_list = {
+                'R': result['renamed'],
+                'C': result['copied'],
+                'A': result['added'],
+                'D': result['removed'],
+                'M': result['changed']
+            }[status]
+            change_list.append(name)
+
+        result['total'] = len(files)
         return result
 
     @contextmanager


[06/18] allura git commit: [#7925] fix looping/delete bug

Posted by he...@apache.org.
[#7925] fix looping/delete bug


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

Branch: refs/heads/master
Commit: 787ee906ab185dcee0193bd412b5cc4bab252cbd
Parents: 155e0b0
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 16:10:38 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:36 2015 -0400

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/787ee906/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index f43f536..b9d986e 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -817,8 +817,8 @@ class SVNImplementation(M.RepositoryImplementation):
                 # svn commit -m "Replace aaa.txt"
                 result['changed'].append(h.really_unicode(p.path))
 
-        for r in result['copied']:
-            if r['old'] in result['removed'][:]:
+        for r in result['copied'][:]:
+            if r['old'] in result['removed']:
                 result['removed'].remove(r['old'])
                 result['copied'].remove(r)
                 result['renamed'].append(r)


[11/18] allura git commit: [#7925] show diffs of renames & copies (if they had changes)

Posted by he...@apache.org.
[#7925] show diffs of renames & copies (if they had changes)


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

Branch: refs/heads/master
Commit: b950a1fd6eeff1e3c7e0d7dc58b3387af70f70d3
Parents: 95f5648
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 22:32:35 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py          | 17 ++++++++++++-----
 Allura/allura/templates/repo/commit.html         | 12 +++++++++++-
 ForgeGit/forgegit/model/git_repo.py              |  1 -
 ForgeSVN/forgesvn/model/svn.py                   |  1 -
 ForgeSVN/forgesvn/tests/model/test_repository.py |  4 ++--
 5 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b950a1fd/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index c17f06a..699931b 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -724,11 +724,11 @@ class FileBrowser(BaseController):
         elif 'diff' in kw:
             tg.decorators.override_template(
                 self.index, 'jinja:allura:templates/repo/diff.html')
-            return self.diff(kw['diff'], kw.pop('diformat', None))
+            return self.diff(kw['diff'], kw.pop('diformat', None), kw.pop('prev_file', None))
         elif 'barediff' in kw:
             tg.decorators.override_template(
                 self.index, 'jinja:allura:templates/repo/barediff.html')
-            return self.diff(kw['barediff'], kw.pop('diformat', None))
+            return self.diff(kw['barediff'], kw.pop('diformat', None), kw.pop('prev_file', None))
         else:
             force_display = 'force' in kw
             stats = utils.generate_code_stats(self._blob)
@@ -753,13 +753,20 @@ class FileBrowser(BaseController):
             'attachment;filename="%s"' % filename)
         return iter(self._blob)
 
-    def diff(self, commit, fmt=None, **kw):
+    def diff(self, prev_commit, fmt=None, prev_file=None, **kw):
+        '''
+        :param prev_commit: previous commit to compare against
+        :param fmt: "sidebyside", or anything else for "unified"
+        :param prev_file: previous filename, if different
+        :return:
+        '''
         try:
             path, filename = os.path.split(self._blob.path())
-            a_ci = c.app.repo.commit(commit)
-            a = a_ci.get_path(self._blob.path())
+            a_ci = c.app.repo.commit(prev_commit)
+            a = a_ci.get_path(prev_file or self._blob.path())
             apath = a.path()
         except:
+            # prev commit doesn't have the file
             a = []
             apath = ''
         b = self._blob

http://git-wip-us.apache.org/repos/asf/allura/blob/b950a1fd/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index b0adabc..06da620 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -148,6 +148,10 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
                 to
                 <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file.new))}}">{{h.really_unicode(file.new)}}</a>
+                {% if file.ratio != 1 %}
+                    <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?diff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}">Diff</a>
+                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?barediff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                {% endif %}
             {% endif %}
             </h6>
             <div id="diff-{{loop.index}}" class="inline-diff-body">
@@ -157,7 +161,13 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                   {% if file.ratio == 1 %}
                     <span class="empty-diff">File was {{ type }}.</span>
                   {% else %}
-                    {{g.highlight(file.diff, lexer='diff')}}
+                    <img src="{{g.forge_static('images/spinner.gif')}}" class="loading_icon" alt="Loading..."/>
+                    <script type="text/javascript">
+                      diff_queue.push({
+                        selector: '#diff-{{loop.index}}',
+                        url: '{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?barediff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}'
+                      });
+                    </script>
                   {% endif %}
                 {% elif obj_type == 'tree' %}
                     <span class="empty-diff">Directory.</span>

http://git-wip-us.apache.org/repos/asf/allura/blob/b950a1fd/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 9462087..8849a40 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -681,7 +681,6 @@ class GitImplementation(M.RepositoryImplementation):
                     'new': h.really_unicode(cmd_output[x + 2]),
                     'old': h.really_unicode(cmd_output[x + 1]),
                     'ratio': ratio,
-                    'diff': '',
                 }))
                 x += 3
             else:

http://git-wip-us.apache.org/repos/asf/allura/blob/b950a1fd/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index b9d986e..8db0943 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -803,7 +803,6 @@ class SVNImplementation(M.RepositoryImplementation):
                     'new': h.really_unicode(p.path),
                     'old': h.really_unicode(p.copyfrom_path),
                     'ratio': 1,
-                    'diff': '',
                 })
             elif p['action'] == 'A':
                 result['added'].append(h.really_unicode(p.path))

http://git-wip-us.apache.org/repos/asf/allura/blob/b950a1fd/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 1c997b7..f5ce1df 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -407,7 +407,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
     def test_diff_copy(self):
         entry = self.repo.commit(self.repo.log(5, id_only=True).next())
         assert_equals(dict(entry.diffs), dict(
-                copied=[{'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1}],  renamed=[],
+                copied=[{'new': u'/b', 'old': u'/a', 'ratio': 1}],  renamed=[],
                 changed=[], removed=[], added=[], total=1))
 
     def test_commit(self):
@@ -612,7 +612,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
                 'removed': [],
                 'modified': [],
                 'copied': [
-                    {'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1},
+                    {'new': u'/b', 'old': u'/a', 'ratio': 1},
                 ],
                 'renamed': [],
             }],


[05/18] allura git commit: [#7925] fix template display: specify copy/rename, say file was binary instead of skip entirely, etc

Posted by he...@apache.org.
[#7925] fix template display: specify copy/rename, say file was binary instead of skip entirely, etc


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

Branch: refs/heads/master
Commit: 3a8037c16afa1fb00f58f6e4aa307c505e5e1c61
Parents: 5adbb28
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 19:14:26 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:36 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py  | 16 +++++++++++-----
 Allura/allura/templates/repo/commit.html | 16 +++++++---------
 2 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3a8037c1/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 0524589..c17f06a 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -563,11 +563,17 @@ class CommitBrowser(BaseController):
         limit, page, start = g.handle_paging(limit, page,
                                              default=self.DEFAULT_PAGE_LIMIT)
         diffs = self._commit.paged_diffs(start=start, end=start + limit)
-        result['artifacts'] = [
-            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree',
-            tree.get_blob_by_path(f) and tree.get_blob_by_path(f).has_html_view)
-            for t in ('added', 'removed', 'changed', 'copied', 'renamed')
-            for f in diffs[t]]
+        result['artifacts'] = []
+        for t in ('added', 'removed', 'changed', 'copied', 'renamed'):
+            for f in diffs[t]:
+                if t in ('copied', 'renamed'):
+                    filepath = f['new']
+                else:
+                    filepath = f
+                is_text = filepath and tree.get_blob_by_path(filepath) and tree.get_blob_by_path(filepath).has_html_view
+                result['artifacts'].append(
+                    (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree', is_text)
+                )
         count = diffs['total']
         result.update(dict(page=page, limit=limit, count=count))
         return result

http://git-wip-us.apache.org/repos/asf/allura/blob/3a8037c1/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index f7206d4..b0adabc 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -132,9 +132,8 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
 </table>
 
     {% for type, file, obj_type, is_text in artifacts %}
-        {% if is_text %}
-            <div class="inline-diff">
-                <h6>
+        <div class="inline-diff">
+            <h6>
             {% if type in ('added', 'changed') %}
                 {% if obj_type == 'tree' %}
                     <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
@@ -145,9 +144,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                 {% endif %}
             {% elif type == 'removed' %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
-            {% elif type == 'renamed' %}
-                <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
-            {% elif type == 'copied' %}
+            {% elif type in ('copied', 'renamed') %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
                 to
                 <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file.new))}}">{{h.really_unicode(file.new)}}</a>
@@ -156,14 +153,16 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
             <div id="diff-{{loop.index}}" class="inline-diff-body">
                 {% if type == 'removed' %}
                   <span class="empty-diff">File was removed.</span>
-                {% elif type == 'copied' %}
+                {% elif type in ('copied', 'renamed') %}
                   {% if file.ratio == 1 %}
-                    <span class="empty-diff">File was copied or renamed.</span>
+                    <span class="empty-diff">File was {{ type }}.</span>
                   {% else %}
                     {{g.highlight(file.diff, lexer='diff')}}
                   {% endif %}
                 {% elif obj_type == 'tree' %}
                     <span class="empty-diff">Directory.</span>
+                {% elif not is_text %}
+                    <span class="empty-diff">Binary file was {{ type }}.</span>
                 {% else %}
                     <img src="{{g.forge_static('images/spinner.gif')}}" class="loading_icon" alt="Loading..."/>
                     <script type="text/javascript">
@@ -175,7 +174,6 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                 {% endif %}
             </div>
         </div>
-        {% endif %}
     {% endfor %}
     {{ c.page_list.display(page=page, limit=limit, count=count) }}
 {% endblock %}


[07/18] allura git commit: [#7925] Update commit web view to show copied and renamed changes

Posted by he...@apache.org.
[#7925] Update commit web view to show copied and renamed changes


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

Branch: refs/heads/master
Commit: 73385a88dd6bc36adc4e1f8716b1fb3a621662bc
Parents: 04b87c6
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Jul 27 16:11:50 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:36 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py  | 4 ++--
 Allura/allura/templates/repo/commit.html | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/73385a88/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 5d03f64..0524589 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -565,8 +565,8 @@ class CommitBrowser(BaseController):
         diffs = self._commit.paged_diffs(start=start, end=start + limit)
         result['artifacts'] = [
             (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree',
-            tree.get_blob_by_path(f) and tree.get_blob_by_path(f).is_text)
-            for t in ('added', 'removed', 'changed', 'copied')
+            tree.get_blob_by_path(f) and tree.get_blob_by_path(f).has_html_view)
+            for t in ('added', 'removed', 'changed', 'copied', 'renamed')
             for f in diffs[t]]
         count = diffs['total']
         result.update(dict(page=page, limit=limit, count=count))

http://git-wip-us.apache.org/repos/asf/allura/blob/73385a88/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index f029f52..f7206d4 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -1,3 +1,4 @@
+
 {#-
        Licensed to the Apache Software Foundation (ASF) under one
        or more contributor license agreements.  See the NOTICE file
@@ -119,6 +120,8 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
         <td><a href="#diff-{{loop.index}}">
             {% if type == 'copied' %}
               {{ '%s -> %s' % (h.really_unicode(file.old), h.really_unicode(file.new)) }}
+            {% elif type == 'renamed' %}
+              {{ '%s -> %s' % (h.really_unicode(file.old), h.really_unicode(file.new)) }}
             {% else %}
               {{h.really_unicode(file)}}
             {% endif %}
@@ -142,6 +145,8 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                 {% endif %}
             {% elif type == 'removed' %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
+            {% elif type == 'renamed' %}
+                <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
             {% elif type == 'copied' %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
                 to


[18/18] allura git commit: [#7925] add test for commit view of a rename

Posted by he...@apache.org.
[#7925] add test for commit view of a rename


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

Branch: refs/heads/master
Commit: 46baba14d7286953d72ac10cfa3385746a7b5444
Parents: 5ac9651
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Aug 5 15:30:11 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:38 2015 -0400

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py             |  1 -
 .../tests/functional/test_controllers.py        | 29 ++++++++++++++------
 2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/46baba14/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8849a40..318f81f 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -675,7 +675,6 @@ class GitImplementation(M.RepositoryImplementation):
         while x < len(cmd_output):
             status = cmd_output[x][0]
             if status in ('R', 'C'):
-                # TODO: make sure we have a test for this
                 ratio = float(cmd_output[x][1:4]) / 100.0
                 files.append((status, {
                     'new': h.really_unicode(cmd_output[x + 2]),

http://git-wip-us.apache.org/repos/asf/allura/blob/46baba14/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 48969fc..4c363d2 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -820,8 +820,7 @@ class TestGitRename(TestController):
     @with_git
     def setup_with_tools(self):
         h.set_context('test', 'src-git', neighborhood='Projects')
-        repo_dir = pkg_resources.resource_filename(
-            'forgegit', 'tests/data')
+        repo_dir = pkg_resources.resource_filename('forgegit', 'tests/data')
         c.app.repo.fs_path = repo_dir
         c.app.repo.status = 'ready'
         c.app.repo.name = 'testrename.git'
@@ -831,22 +830,36 @@ class TestGitRename(TestController):
         ThreadLocalORMSession.flush_all()
 
     def test_log(self):
-        resp = self.app.get(
-            '/src-git/ci/259c77dd6ee0e6091d11e429b56c44ccbf1e64a3/log/?path=/f2.txt')
+        # commit after the rename
+        resp = self.app.get('/src-git/ci/259c77dd6ee0e6091d11e429b56c44ccbf1e64a3/log/?path=/f2.txt')
         assert '<b>renamed from</b>' in resp
         assert '/f.txt' in resp
         assert '(27 Bytes)' in resp
         assert '(19 Bytes)' in resp
 
-        resp = self.app.get(
-            '/src-git/ci/fbb0644603bb6ecee3ebb62efe8c86efc9b84ee6/log/?path=/f.txt')
+        # commit before the rename
+        resp = self.app.get('/src-git/ci/fbb0644603bb6ecee3ebb62efe8c86efc9b84ee6/log/?path=/f.txt')
         assert '(19 Bytes)' in resp
         assert '(10 Bytes)' in resp
 
-        resp = self.app.get(
-            '/src-git/ci/7c09182e61af959e4f1fb0e354bab49f14ef810d/tree/f.txt')
+        # first commit, adding the file
+        resp = self.app.get('/src-git/ci/7c09182e61af959e4f1fb0e354bab49f14ef810d/tree/f.txt')
         assert "2 lines (1 with data), 10 Bytes" in resp
 
+    def test_commit(self):
+        # get the rename commit itself
+        resp = self.app.get('/src-git/ci/b120505a61225e6c14bee3e5b5862db81628c35c/')
+
+        # the top portion of the output
+        assert "<td>renamed" in resp
+        assert "f.txt -&gt; f2.txt" in resp
+
+        # the diff portion of the output
+        resp_no_ws = re.sub(r'\s+', '', str(resp))
+        assert '<a href="/p/test/src-git/ci/fbb0644603bb6ecee3ebb62efe8c86efc9b84ee6/tree/f.txt">f.txt</a>to<a href="/p/test/src-git/ci/b120505a61225e6c14bee3e5b5862db81628c35c/tree/f2.txt">f2.txt</a>'.replace(' ','') \
+               in resp_no_ws
+        assert '<span class="empty-diff">File was renamed.</span>' in resp
+
 
 class TestGitBranch(TestController):
     def setUp(self):


[13/18] allura git commit: [#7925] use some variables to clean up some repetition in the commit template

Posted by he...@apache.org.
[#7925] use some variables to clean up some repetition in the commit template


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

Branch: refs/heads/master
Commit: 1919ec0959c6883d6239d060bf19d44e02b4df04
Parents: b950a1f
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 22:42:54 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/templates/repo/commit.html | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1919ec09/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 06da620..adf57b2 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -135,22 +135,25 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
         <div class="inline-diff">
             <h6>
             {% if type in ('added', 'changed') %}
-                {% if obj_type == 'tree' %}
-                    <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
-                {% else %}
-                    <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
-                    <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?diff={{prev[0]._id if prev else ''}}">Diff</a>
-                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                {% set file_url = commit.url() + 'tree/' + h.urlquote(h.really_unicode(file)) %}
+                <a href="{{ file_url }}">{{h.really_unicode(file)}}</a>
+                {% if obj_type != 'tree' %}
+                    {% set diff_url = file_url + '?barediff=' + (prev[0]._id if prev else '') %}
+                    <a class="commit-diff-link" href="{{ diff_url.replace('?barediff=', '?diff=') }}">Diff</a>
+                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{ diff_url }}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
                 {% endif %}
             {% elif type == 'removed' %}
-                <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
+                {% set file_url = prev[0].url() + 'tree/' + h.urlquote(h.really_unicode(file)) %}
+                <a href="{{ file_url }}">{{h.really_unicode(file)}}</a>
             {% elif type in ('copied', 'renamed') %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
                 to
-                <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file.new))}}">{{h.really_unicode(file.new)}}</a>
+                {% set new_file_url = commit.url() + 'tree/' + h.urlquote(h.really_unicode(file.new)) %}
+                <a href="{{ new_file_url }}">{{h.really_unicode(file.new)}}</a>
                 {% if file.ratio != 1 %}
-                    <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?diff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}">Diff</a>
-                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?barediff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                    {% set diff_url = new_file_url + '?barediff=' + (prev[0]._id if prev else '') + '&prev_file=' + h.urlquote(h.really_unicode(file['old'])) %}
+                    <a class="commit-diff-link" href="{{ diff_url.replace('?barediff=', '?diff=') }}">Diff</a>
+                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{diff_url}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
                 {% endif %}
             {% endif %}
             </h6>
@@ -165,7 +168,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                     <script type="text/javascript">
                       diff_queue.push({
                         selector: '#diff-{{loop.index}}',
-                        url: '{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file['new']))}}?barediff={{prev[0]._id if prev else ''}}&prev_file={{h.urlquote(h.really_unicode(file['old']))}}'
+                        url: '{{diff_url}}'
                       });
                     </script>
                   {% endif %}
@@ -178,7 +181,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                     <script type="text/javascript">
                       diff_queue.push({
                         selector: '#diff-{{loop.index}}',
-                        url: '{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}'
+                        url: '{{diff_url}}'
                       });
                     </script>
                 {% endif %}


[02/18] allura git commit: [#7925] Refactor and improve the diff processing

Posted by he...@apache.org.
[#7925] Refactor and improve the diff processing


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

Branch: refs/heads/master
Commit: 7f738bdfbb93e78d8d557f8b60fb1965ce9e67ce
Parents: 7eeb0dd
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Jul 27 16:06:28 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:35 2015 -0400

----------------------------------------------------------------------
 Allura/allura/lib/custom_middleware.py |  4 --
 Allura/allura/model/repository.py      | 67 +----------------------------
 ForgeGit/forgegit/model/git_repo.py    | 51 +++++++++++++++-------
 ForgeSVN/forgesvn/model/svn.py         | 17 +++++---
 4 files changed, 47 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7f738bdf/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index e56a530..1938e51 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -322,10 +322,6 @@ class AlluraTimerMiddleware(TimerMiddleware):
             Timer('urlopen', urllib2, 'urlopen'),
             Timer('base_repo_tool.{method_name}',
                   allura.model.repository.RepositoryImplementation, 'last_commit_ids'),
-            Timer('_diffs_copied', allura.model.repository.Commit, '_diffs_copied'),
-            Timer(
-                'sequencematcher.{method_name}', allura.model.repository.SequenceMatcher,
-                'ratio', 'quick_ratio', 'real_quick_ratio'),
             Timer('unified_diff', allura.model.repository, 'unified_diff'),
         ] + [Timer('sidebar', ep.load(), 'sidebar_menu') for ep in tool_entry_points]
 

http://git-wip-us.apache.org/repos/asf/allura/blob/7f738bdf/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 5fe2ba9..636d10c 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1168,78 +1168,15 @@ class Commit(RepoObject, ActivityObject):
 
     def paged_diffs(self, start=0, end=None):
         diffs = self.repo.paged_diffs(self._id, start, end)
-        if not diffs.get('copied'):
-            diffs['copied'] = []
-        copied = self._diffs_copied(diffs['added'], diffs['removed'])
-        diffs['copied'].extend(copied)
+
         return Object(
             added=sorted(diffs['added']),
             removed=sorted(diffs['removed']),
             changed=sorted(diffs['changed']),
             copied=sorted(diffs['copied']),
+            renamed=sorted(diffs['renamed']),
             total=diffs['total'])
 
-    def _diffs_copied(self, added, removed):
-        '''Return list with file renames diffs.
-
-        Will change `added` and `removed` lists also.
-        '''
-        def _blobs_similarity(removed_blob, added):
-            best = dict(ratio=0, name='', blob=None)
-            for added_name in added:
-                added_blob = self.tree.get_obj_by_path(added_name)
-                if not isinstance(added_blob, Blob):
-                    continue
-                diff = SequenceMatcher(None, removed_blob.text,
-                                       added_blob.text)
-                ratio = diff.quick_ratio()
-                if ratio > best['ratio']:
-                    best['ratio'] = ratio
-                    best['name'] = added_name
-                    best['blob'] = added_blob
-
-                if ratio == 1:
-                    break  # we'll won't find better similarity than 100% :)
-
-            if best['ratio'] > DIFF_SIMILARITY_THRESHOLD:
-                diff = ''
-                if best['ratio'] < 1:
-                    added_blob = best['blob']
-                    rpath = ('a' + removed_blob.path()).encode('utf-8')
-                    apath = ('b' + added_blob.path()).encode('utf-8')
-                    diff = ''.join(unified_diff(list(removed_blob),
-                                                list(added_blob),
-                                                rpath, apath))
-                return dict(new=best['name'],
-                            ratio=best['ratio'], diff=diff)
-
-        def _trees_similarity(removed_tree, added):
-            for added_name in added:
-                added_tree = self.tree.get_obj_by_path(added_name)
-                if not isinstance(added_tree, Tree):
-                    continue
-                if removed_tree._id == added_tree._id:
-                    return dict(new=added_name,
-                                ratio=1, diff='')
-
-        if not removed:
-            return []
-        copied = []
-        prev_commit = self.get_parent()
-        for removed_name in removed[:]:
-            removed_blob = prev_commit.tree.get_obj_by_path(removed_name)
-            rename_info = None
-            if isinstance(removed_blob, Blob):
-                rename_info = _blobs_similarity(removed_blob, added)
-            elif isinstance(removed_blob, Tree):
-                rename_info = _trees_similarity(removed_blob, added)
-            if rename_info is not None:
-                rename_info['old'] = removed_name
-                copied.append(rename_info)
-                removed.remove(rename_info['old'])
-                added.remove(rename_info['new'])
-        return copied
-
     def get_path(self, path, create=True):
         path = path.lstrip('/')
         parts = path.split('/')

http://git-wip-us.apache.org/repos/asf/allura/blob/7f738bdf/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 9549fa6..9a8549a 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -642,36 +642,55 @@ class GitImplementation(M.RepositoryImplementation):
             max_count=1).splitlines()[1:]
 
     def paged_diffs(self, commit_id, start=0, end=None):
-        added, removed, changed = [], [], []
+        result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': [], 'total': 0}
+
         files = self._git.git.diff_tree(
             '--no-commit-id',
+            '--find-renames',
+            '--find-copies',
             '--name-status',
-            '--no-renames',
+            '--no-abbrev',
             '--root',
-            # show tree entry itself as well as subtrees (Commit.added_paths
-            # relies on this)
+            '--find-copies-harder',
+            # 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]
 
-        total = len(files) / 2
-        files = [(files[i], h.really_unicode(files[i+1]))
-                 for i in xrange(0, len(files), 2)]
+        result['total'] = len(files) / 2
+        x = 0
+        while x < len(files):
+            try:
+                if files[x].startswith("R") or files[x].startswith("C"):
+                    change_list = result['renamed'] if files[x].startswith("R") else result['copied']
+                    ratio = float(files[x][1:4]) / 100.0
+                    change_list.append({
+                        'new': h.really_unicode(files[x + 2]),
+                        'old': h.really_unicode(files[x + 1]),
+                        'ratio': ratio,
+                        'diff': '',
+                    })
+                    del files[x:x+3]
+                    x += 3
+                    result['total'] -= 1
+                else:
+                    x += 2
+            except IndexError:
+                break
+
+        files = [(files[i], h.really_unicode(files[i + 1]))
+                 for i in xrange(0, result['total'] + 1, 2)]
 
         # files = [('A', u'filename'), ('D', u'another filename'), ...]
         for status, name in files[start:end]:
             if status == 'A':
-                added.append(name)
+                result['added'].append(name)
             elif status == 'D':
-                removed.append(name)
+                result['removed'].append(name)
             elif status == 'M':
-                changed.append(name)
-        return {
-            'added': added,
-            'removed': removed,
-            'changed': changed,
-            'total': total,
-        }
+                result['changed'].append(name)
+
+        return result
 
     @contextmanager
     def _shared_clone(self, from_path):

http://git-wip-us.apache.org/repos/asf/allura/blob/7f738bdf/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index cd410e3..f43f536 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -781,13 +781,7 @@ class SVNImplementation(M.RepositoryImplementation):
         return []
 
     def paged_diffs(self, commit_id, start=0, end=None):
-        result = {
-            'added': [],
-            'removed': [],
-            'changed': [],
-            'copied': [],
-            'total': 0,
-        }
+        result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': [], 'total': 0}
         rev = self._revision(commit_id)
         try:
             log_info = self._svn.log(
@@ -822,6 +816,15 @@ class SVNImplementation(M.RepositoryImplementation):
                 # svn add aaa.txt
                 # svn commit -m "Replace aaa.txt"
                 result['changed'].append(h.really_unicode(p.path))
+
+        for r in result['copied']:
+            if r['old'] in result['removed'][:]:
+                result['removed'].remove(r['old'])
+                result['copied'].remove(r)
+                result['renamed'].append(r)
+            if r['new'] in result['added']:
+                result['added'].remove(r['new'])
+
         return result
 
 Mapper.compile_all()


[10/18] allura git commit: [#7925] include renames in webhook payload

Posted by he...@apache.org.
[#7925] include renames in webhook payload


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

Branch: refs/heads/master
Commit: 95f56486ae75a01864d50ada7b6c49a166025e63
Parents: 7133cb1
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 20:49:01 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/model/repository.py                | 1 +
 ForgeGit/forgegit/tests/model/test_repository.py | 8 +++++---
 ForgeSVN/forgesvn/tests/model/test_repository.py | 6 ++++--
 3 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/95f56486/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 3db43a8..acbc3d1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1275,6 +1275,7 @@ class Commit(RepoObject, ActivityObject):
             'removed': self.diffs.removed,
             'modified': self.diffs.changed,
             'copied': self.diffs.copied,
+            'renamed': self.diffs.renamed,
         }
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/95f56486/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 948f228..25daa62 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -121,7 +121,7 @@ class TestNewGit(unittest.TestCase):
         assert_equal(
             sorted(rev.webhook_info.keys()),
             sorted(['id', 'url', 'timestamp', 'message', 'author',
-                    'committer', 'added', 'removed', 'modified', 'copied']))
+                    'committer', 'added', 'removed', 'renamed', 'modified', 'copied']))
 
 
 class TestGitRepo(unittest.TestCase, RepoImplTestBase):
@@ -568,7 +568,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
                 'added': [u'bad'],
                 'removed': [],
                 'modified': [],
-                'copied': []
+                'copied': [],
+                'renamed': [],
             }, {
                 'id': u'1e146e67985dcd71c74de79613719bef7bddca4a',
                 'url': u'http://localhost/p/test/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/',
@@ -583,7 +584,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
                 'added': [],
                 'removed': [],
                 'modified': [u'README'],
-                'copied': []
+                'copied': [],
+                'renamed': [],
             }],
             'repository': {
                 'name': u'Git',

http://git-wip-us.apache.org/repos/asf/allura/blob/95f56486/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 9889a60..1c997b7 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -102,7 +102,7 @@ class TestNewRepo(unittest.TestCase):
         assert_equal(
             sorted(self.rev.webhook_info.keys()),
             sorted(['id', 'url', 'timestamp', 'message', 'author',
-                    'committer', 'added', 'removed', 'modified', 'copied']))
+                    'committer', 'added', 'removed', 'renamed', 'modified', 'copied']))
 
 
 class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
@@ -595,7 +595,8 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
                 'added': [u'/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
                 'removed': [],
                 'modified': [],
-                'copied': []
+                'copied': [],
+                'renamed': [],
             }, {
                 'id': u'r5',
                 'url': u'http://localhost/p/test/src/5/',
@@ -613,6 +614,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
                 'copied': [
                     {'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1},
                 ],
+                'renamed': [],
             }],
             'repository': {
                 'name': u'SVN',


[03/18] allura git commit: [#7925] Improve binary file detection

Posted by he...@apache.org.
[#7925] Improve binary file detection


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

Branch: refs/heads/master
Commit: 7eeb0dd06ec8f0aca4a890efe0fae4c9524c4972
Parents: e252f5e
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Jul 27 15:58:59 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:35 2015 -0400

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7eeb0dd0/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 7bc36c1..5fe2ba9 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -77,11 +77,21 @@ SObjType = S.OneOf('blob', 'tree', 'submodule')
 
 # Used for when we're going to batch queries using $in
 QSIZE = 100
-README_RE = re.compile('^README(\.[^.]*)?$', re.IGNORECASE)
-VIEWABLE_EXTENSIONS = [
-    '.php', '.py', '.js', '.java', '.html', '.htm', '.yaml', '.sh',
-    '.rb', '.phtml', '.txt', '.bat', '.ps1', '.xhtml', '.css', '.cfm', '.jsp', '.jspx',
-    '.pl', '.php4', '.php3', '.rhtml', '.svg', '.markdown', '.json', '.ini', '.tcl', '.vbs', '.xsl']
+BINARY_EXTENSIONS = [
+    "3ds", "3g2", "3gp", "7z", "a", "aac", "adp", "ai", "aif", "apk", "ar", "asf", "au", "avi",
+    "bak", "bin", "bk", "bmp", "btif", "bz2", "cab", "caf", "cgm", "cmx", "cpio", "cr2", "dat", "deb", "djvu", "dll",
+    "dmg", "dng", "doc", "docx", "dra", "DS_Store", "dsk", "dts", "dtshd", "dvb", "dwg", "dxf", "ecelp4800",
+    "ecelp7470", "ecelp9600", "egg", "eol", "eot", "epub", "exe", "f4v", "fbs", "fh", "fla", "flac", "fli", "flv",
+    "fpx", "fst", "fvt", "g3", "gif", "gz", "h261", "h263", "h264", "ico", "ief", "img", "ipa", "iso", "jar", "jpeg",
+    "jpg", "jpgv", "jpm", "jxr", "ktx", "lvp", "lz", "lzma", "lzo", "m3u", "m4a", "m4v", "mar", "mdi", "mid", "mj2",
+    "mka", "mkv", "mmr", "mng", "mov", "movie", "mp3", "mp4", "mp4a", "mpeg", "mpg", "mpga", "mxu", "nef", "npx", "o",
+    "oga", "ogg", "ogv", "otf", "pbm", "pcx", "pdf", "pea", "pgm", "pic", "png", "pnm", "ppm", "psd", "pya", "pyc",
+    "pyo", "pyv", "qt", "rar", "ras", "raw", "rgb", "rip", "rlc", "rz", "s3m", "s7z", "scpt", "sgi", "shar", "sil",
+    "smv", "so", "sub", "swf", "tar", "tbz2", "tga", "tgz", "tif", "tiff", "tlz", "ts", "ttf", "uvh", "uvi", "uvm",
+    "uvp", "uvs", "uvu", "viv", "vob", "war", "wav", "wax", "wbmp", "wdp", "weba", "webm", "webp", "whl", "wm", "wma",
+    "wmv", "wmx", "woff", "woff2", "wvx", "xbm", "xif", "xm", "xpi", "xpm", "xwd", "xz", "z", "zip", "zipx"
+]
+
 PYPELINE_EXTENSIONS = utils.MARKDOWN_EXTENSIONS + ['.rst']
 
 DIFF_SIMILARITY_THRESHOLD = .5  # used for determining file renames
@@ -1520,12 +1530,6 @@ class Blob(object):
         return self._content_type_encoding[0]
 
     @LazyProperty
-    def is_text(self):
-        """Return true if this blob is text."""
-
-        return self.content_type.startswith("text")
-
-    @LazyProperty
     def content_encoding(self):
         return self._content_type_encoding[1]
 
@@ -1535,8 +1539,10 @@ class Blob(object):
             return True
         return False
 
-    @property
+    @LazyProperty
     def has_html_view(self):
+        if self.extension in BINARY_EXTENSIONS:
+            return False
         if (self.content_type.startswith('text/') or
                 self.extension in VIEWABLE_EXTENSIONS or
                 self.extension in PYPELINE_EXTENSIONS or


[15/18] allura git commit: [#7925] add renamed files to template used by "Browse Commits" page

Posted by he...@apache.org.
[#7925] add renamed files to template used by "Browse Commits" page


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

Branch: refs/heads/master
Commit: 9835504d7f5e0fd68195b92ba5f66e65f844c02f
Parents: 3a8037c
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 20:36:07 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/templates/repo/commit_basic.html | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9835504d/Allura/allura/templates/repo/commit_basic.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit_basic.html b/Allura/allura/templates/repo/commit_basic.html
index f1625ca..e4ec126 100644
--- a/Allura/allura/templates/repo/commit_basic.html
+++ b/Allura/allura/templates/repo/commit_basic.html
@@ -46,6 +46,15 @@
         <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}">{{h.really_unicode(diff.new)}}</a>
       </td>
     </tr>
+    {% endfor %}{% for diff in commit.diffs.renamed %}
+    <tr>
+      <td>rename</td>
+      <td>
+        <a href="{{prev[0].url()}}tree/{{h.really_unicode(diff.old)}}">{{h.really_unicode(diff.old)}}</a>
+        <br/>to<br/>
+        <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}">{{h.really_unicode(diff.new)}}</a>
+      </td>
+    </tr>
     {% endfor %}
   </tbody>
 </table>


[14/18] allura git commit: [#7925] tests, fix, and docstring for has_html_view

Posted by he...@apache.org.
[#7925] tests, fix, and docstring for has_html_view


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

Branch: refs/heads/master
Commit: 7133cb19b3b770f45159ceacc968e85464599af4
Parents: 9835504
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jul 31 20:25:09 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/model/repository.py     | 28 +++++++++++++++-----------
 Allura/allura/tests/unit/test_repo.py | 32 +++++++++++++++++++++++++-----
 2 files changed, 43 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7133cb19/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 636d10c..3db43a8 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -78,18 +78,18 @@ SObjType = S.OneOf('blob', 'tree', 'submodule')
 # Used for when we're going to batch queries using $in
 QSIZE = 100
 BINARY_EXTENSIONS = [
-    "3ds", "3g2", "3gp", "7z", "a", "aac", "adp", "ai", "aif", "apk", "ar", "asf", "au", "avi",
-    "bak", "bin", "bk", "bmp", "btif", "bz2", "cab", "caf", "cgm", "cmx", "cpio", "cr2", "dat", "deb", "djvu", "dll",
-    "dmg", "dng", "doc", "docx", "dra", "DS_Store", "dsk", "dts", "dtshd", "dvb", "dwg", "dxf", "ecelp4800",
-    "ecelp7470", "ecelp9600", "egg", "eol", "eot", "epub", "exe", "f4v", "fbs", "fh", "fla", "flac", "fli", "flv",
-    "fpx", "fst", "fvt", "g3", "gif", "gz", "h261", "h263", "h264", "ico", "ief", "img", "ipa", "iso", "jar", "jpeg",
-    "jpg", "jpgv", "jpm", "jxr", "ktx", "lvp", "lz", "lzma", "lzo", "m3u", "m4a", "m4v", "mar", "mdi", "mid", "mj2",
-    "mka", "mkv", "mmr", "mng", "mov", "movie", "mp3", "mp4", "mp4a", "mpeg", "mpg", "mpga", "mxu", "nef", "npx", "o",
-    "oga", "ogg", "ogv", "otf", "pbm", "pcx", "pdf", "pea", "pgm", "pic", "png", "pnm", "ppm", "psd", "pya", "pyc",
-    "pyo", "pyv", "qt", "rar", "ras", "raw", "rgb", "rip", "rlc", "rz", "s3m", "s7z", "scpt", "sgi", "shar", "sil",
-    "smv", "so", "sub", "swf", "tar", "tbz2", "tga", "tgz", "tif", "tiff", "tlz", "ts", "ttf", "uvh", "uvi", "uvm",
-    "uvp", "uvs", "uvu", "viv", "vob", "war", "wav", "wax", "wbmp", "wdp", "weba", "webm", "webp", "whl", "wm", "wma",
-    "wmv", "wmx", "woff", "woff2", "wvx", "xbm", "xif", "xm", "xpi", "xpm", "xwd", "xz", "z", "zip", "zipx"
+    ".3ds", ".3g2", ".3gp", ".7z", ".a", ".aac", ".adp", ".ai", ".aif", ".apk", ".ar", ".asf", ".au", ".avi",
+    ".bak", ".bin", ".bk", ".bmp", ".btif", ".bz2", ".cab", ".caf", ".cgm", ".cmx", ".cpio", ".cr2", ".dat", ".deb", ".djvu", ".dll",
+    ".dmg", ".dng", ".doc", ".docx", ".dra", ".DS_Store", ".dsk", ".dts", ".dtshd", ".dvb", ".dwg", ".dxf", ".ecelp4800",
+    ".ecelp7470", ".ecelp9600", ".egg", ".eol", ".eot", ".epub", ".exe", ".f4v", ".fbs", ".fh", ".fla", ".flac", ".fli", ".flv",
+    ".fpx", ".fst", ".fvt", ".g3", ".gif", ".gz", ".h261", ".h263", ".h264", ".ico", ".ief", ".img", ".ipa", ".iso", ".jar", ".jpeg",
+    ".jpg", ".jpgv", ".jpm", ".jxr", ".ktx", ".lvp", ".lz", ".lzma", ".lzo", ".m3u", ".m4a", ".m4v", ".mar", ".mdi", ".mid", ".mj2",
+    ".mka", ".mkv", ".mmr", ".mng", ".mov", ".movie", ".mp3", ".mp4", ".mp4a", ".mpeg", ".mpg", ".mpga", ".mxu", ".nef", ".npx", ".o",
+    ".oga", ".ogg", ".ogv", ".otf", ".pbm", ".pcx", ".pdf", ".pea", ".pgm", ".pic", ".png", ".pnm", ".ppm", ".psd", ".pya", ".pyc",
+    ".pyo", ".pyv", ".qt", ".rar", ".ras", ".raw", ".rgb", ".rip", ".rlc", ".rz", ".s3m", ".s7z", ".scpt", ".sgi", ".shar", ".sil",
+    ".smv", ".so", ".sub", ".swf", ".tar", ".tbz2", ".tga", ".tgz", ".tif", ".tiff", ".tlz", ".ts", ".ttf", ".uvh", ".uvi", ".uvm",
+    ".uvp", ".uvs", ".uvu", ".viv", ".vob", ".war", ".wav", ".wax", ".wbmp", ".wdp", ".weba", ".webm", ".webp", ".whl", ".wm", ".wma",
+    ".wmv", ".wmx", ".woff", ".woff2", ".wvx", ".xbm", ".xif", ".xm", ".xpi", ".xpm", ".xwd", ".xz", ".z", ".zip", ".zipx"
 ]
 
 PYPELINE_EXTENSIONS = utils.MARKDOWN_EXTENSIONS + ['.rst']
@@ -1478,6 +1478,10 @@ class Blob(object):
 
     @LazyProperty
     def has_html_view(self):
+        '''
+        Return true if file is a text file that can be displayed.
+        :return: boolean
+        '''
         if self.extension in BINARY_EXTENSIONS:
             return False
         if (self.content_type.startswith('text/') or

http://git-wip-us.apache.org/repos/asf/allura/blob/7133cb19/Allura/allura/tests/unit/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index 9008571..2e52ebe 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -153,13 +153,35 @@ class TestTree(unittest.TestCase):
 class TestBlob(unittest.TestCase):
 
     def test_pypeline_view(self):
-        blob = M.repository.Blob(Mock(), Mock(), Mock())
-        blob._id = 'blob1'
-        blob.path = Mock(return_value='path')
-        blob.name = 'INSTALL.mdown'
-        blob.extension = '.mdown'
+        blob = M.repository.Blob(Mock(), 'INSTALL.mdown', 'blob1')
         assert_equal(blob.has_pypeline_view, True)
 
+    def test_has_html_view_text_mime(self):
+        blob = M.repository.Blob(Mock(), 'INSTALL', 'blob1')
+        blob.content_type = 'text/plain'
+        assert_equal(blob.has_html_view, True)
+
+    def test_has_html_view_text_ext(self):
+        blob = M.repository.Blob(Mock(), 'INSTALL.txt', 'blob1')
+        blob.content_type = 'foo/bar'
+        assert_equal(blob.has_html_view, True)
+
+    def test_has_html_view_text_contents(self):
+        blob = M.repository.Blob(MagicMock(), 'INSTALL', 'blob1')
+        blob.content_type = 'foo/bar'
+        blob.text = 'hello world, this is text here'
+        assert_equal(blob.has_html_view, True)
+
+    def test_has_html_view_bin_ext(self):
+        blob = M.repository.Blob(Mock(), 'INSTALL.zip', 'blob1')
+        assert_equal(blob.has_html_view, False)
+
+    def test_has_html_view_bin_content(self):
+        blob = M.repository.Blob(MagicMock(), 'myfile', 'blob1')
+        blob.content_type = 'whatever'
+        blob.text = '\0\0\0\0'
+        assert_equal(blob.has_html_view, False)
+
 
 class TestCommit(unittest.TestCase):
 


[16/18] allura git commit: [#7925] join split lines into one again. We're ok >79 chars

Posted by he...@apache.org.
[#7925] join split lines into one again.  We're ok >79 chars


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

Branch: refs/heads/master
Commit: 5ac9651fa789d9fbf762a08375145b0d622acc2b
Parents: 9639112
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 4 20:32:26 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:38 2015 -0400

----------------------------------------------------------------------
 Allura/allura/tests/model/test_repo.py | 121 +++++++++-------------------
 1 file changed, 39 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5ac9651f/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index c0a6bc8..9b364aa 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -32,7 +32,6 @@ from allura.lib import helpers as h
 
 
 class TestGitLikeTree(object):
-
     def test_set_blob(self):
         tree = M.GitLikeTree()
         tree.set_blob('/dir/dir2/file', 'file-oid')
@@ -63,7 +62,6 @@ class TestGitLikeTree(object):
 
 
 class RepoImplTestBase(object):
-
     def test_commit_run(self):
         M.repository.CommitRunDoc.m.remove()
         commit_ids = list(self.repo.all_commit_ids())
@@ -100,7 +98,6 @@ class RepoImplTestBase(object):
 
 
 class RepoTestBase(unittest.TestCase):
-
     def setUp(self):
         setup_basic_test()
 
@@ -131,7 +128,6 @@ class RepoTestBase(unittest.TestCase):
 
 
 class TestLastCommit(unittest.TestCase):
-
     def setUp(self):
         setup_basic_test()
         setup_global_objects()
@@ -168,6 +164,7 @@ class TestLastCommit(unittest.TestCase):
             m = mock.Mock()
             m.name = p
             return m
+
         for p in tree_paths:
             if '/' in p:
                 node, sub = p.split('/', 1)
@@ -222,8 +219,7 @@ class TestLastCommit(unittest.TestCase):
             'dir1/file2',
         ])
         lcd = M.repository.LastCommit.get(commit1.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit1.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -231,13 +227,10 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_no_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         lcd = M.repository.LastCommit.get(commit3.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
@@ -247,13 +240,10 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_with_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file1', 'file2'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file1', 'file2'], [commit2])
         lcd = M.repository.LastCommit.get(commit3.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -262,13 +252,10 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_subdir_change(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
         lcd = M.repository.LastCommit.get(commit3.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -276,14 +263,11 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
         lcd = M.repository.LastCommit.get(tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -291,16 +275,12 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd_prev_commit(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
-        commit4 = self._add_commit(
-            'Commit 4', ['file1', 'dir1/file1', 'dir1/file2', 'file2'], ['file2'], [commit3])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit4 = self._add_commit('Commit 4', ['file1', 'dir1/file1', 'dir1/file2', 'file2'], ['file2'], [commit3])
         tree = self._build_tree(commit4, '/dir1', ['file1', 'file2'])
         lcd = M.repository.LastCommit.get(tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -308,32 +288,26 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd_always_empty(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'file2'], ['file2'], [commit1])
+        commit2 = self._add_commit('Commit 2', ['file1', 'file2'], ['file2'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
         lcd = M.repository.LastCommit.get(tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit1.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
     def test_subdir_lcd_emptied(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1'], ['dir1/file1'], [commit1])
+        commit2 = self._add_commit('Commit 2', ['file1'], ['dir1/file1'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
         lcd = M.repository.LastCommit.get(tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit2.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
     def test_existing_lcd_unchained(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'], [commit2])
         prev_lcd = M.repository.LastCommit(
             path='dir1',
             commit_id=commit2._id,
@@ -350,19 +324,15 @@ class TestLastCommit(unittest.TestCase):
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
         lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(lcd._id, prev_lcd._id)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit2.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, prev_lcd.entries)
 
     def test_existing_lcd_partial(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'file2'], ['file2'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'file2', 'file3'], ['file3'], [commit2])
-        commit4 = self._add_commit(
-            'Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2', 'file4'], [commit3])
+        commit2 = self._add_commit('Commit 2', ['file1', 'file2'], ['file2'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'file2', 'file3'], ['file3'], [commit2])
+        commit4 = self._add_commit('Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2', 'file4'], [commit3])
         prev_lcd = M.repository.LastCommit(
             path='',
             commit_id=commit3._id,
@@ -380,8 +350,7 @@ class TestLastCommit(unittest.TestCase):
         )
         session(prev_lcd).flush()
         lcd = M.repository.LastCommit.get(commit4.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit4.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit4.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 4)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -404,14 +373,11 @@ class TestLastCommit(unittest.TestCase):
 
     def test_timeout(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         with h.push_config(config, lcd_timeout=-1000):
             lcd = M.repository.LastCommit.get(commit3.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 1)
@@ -419,15 +385,12 @@ class TestLastCommit(unittest.TestCase):
 
     def test_loop(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit(
-            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit(
-            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         commit2.parent_ids = [commit3._id]
         session(commit2).flush(commit2)
         lcd = M.repository.LastCommit.get(commit3.tree)
-        self.assertEqual(
-            self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
@@ -436,7 +399,6 @@ class TestLastCommit(unittest.TestCase):
 
 
 class TestModelCache(unittest.TestCase):
-
     def setUp(self):
         self.cache = M.repository.ModelCache()
 
@@ -510,15 +472,11 @@ class TestModelCache(unittest.TestCase):
         self.assertEqual(self.cache._instance_cache,
                          {M.repository.Tree: {'OBJID': tree}})
         tree._id = '_id'
-        self.assertEqual(
-            self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
-        self.assertEqual(
-            self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
+        self.assertEqual(self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
+        self.assertEqual(self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
         self.cache.set(M.repository.Tree, {'val1': 'test_set2'}, tree)
-        self.assertEqual(
-            self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
-        self.assertEqual(
-            self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
+        self.assertEqual(self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
+        self.assertEqual(self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
 
     @mock.patch('bson.ObjectId')
     def test_set_none_val(self, obj_id):
@@ -727,7 +685,6 @@ class TestModelCache(unittest.TestCase):
 
 
 class TestMergeRequest(object):
-
     def setUp(self):
         setup_basic_test()
         setup_global_objects()


[12/18] allura git commit: [#7925] more info if file was changed during copy/rename. Don't show diff links if no diff is being displayed

Posted by he...@apache.org.
[#7925] more info if file was changed during copy/rename.  Don't show diff links if no diff is being displayed


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

Branch: refs/heads/master
Commit: 963911220644208590b3b767bc3753aececc51e0
Parents: 1919ec0
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 4 14:52:57 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:37 2015 -0400

----------------------------------------------------------------------
 Allura/allura/templates/repo/commit.html | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/96391122/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index adf57b2..7678a32 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -116,7 +116,9 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
   <tbody>
     {% for type, file, _, _ in artifacts %}
     <tr>
-        <td>{{ type }}</td>
+        <td>{{ type }}
+            {% if type in ('copied', 'renamed') and file.ratio != 1 %}(with changes){% endif %}
+        </td>
         <td><a href="#diff-{{loop.index}}">
             {% if type == 'copied' %}
               {{ '%s -> %s' % (h.really_unicode(file.old), h.really_unicode(file.new)) }}
@@ -137,7 +139,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
             {% if type in ('added', 'changed') %}
                 {% set file_url = commit.url() + 'tree/' + h.urlquote(h.really_unicode(file)) %}
                 <a href="{{ file_url }}">{{h.really_unicode(file)}}</a>
-                {% if obj_type != 'tree' %}
+                {% if obj_type != 'tree' and is_text %}
                     {% set diff_url = file_url + '?barediff=' + (prev[0]._id if prev else '') %}
                     <a class="commit-diff-link" href="{{ diff_url.replace('?barediff=', '?diff=') }}">Diff</a>
                     <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{ diff_url }}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>


[17/18] allura git commit: [#7925] use frozensets for faster O(1) checking of file extensions

Posted by he...@apache.org.
[#7925] use frozensets for faster O(1) checking of file extensions


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

Branch: refs/heads/master
Commit: d8e7ade5d7ec8fa35d09b4d2cb2a4ee2aa54bb29
Parents: 46baba1
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 7 18:04:45 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:38 2015 -0400

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d8e7ade5/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index acbc3d1..77c3fc4 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -65,10 +65,10 @@ config = utils.ConfigProxy(
     common_prefix='forgemail.url')
 
 README_RE = re.compile('^README(\.[^.]*)?$', re.IGNORECASE)
-VIEWABLE_EXTENSIONS = [
+VIEWABLE_EXTENSIONS = frozenset([
     '.php', '.py', '.js', '.java', '.html', '.htm', '.yaml', '.sh',
     '.rb', '.phtml', '.txt', '.bat', '.ps1', '.xhtml', '.css', '.cfm', '.jsp', '.jspx',
-    '.pl', '.php4', '.php3', '.rhtml', '.svg', '.markdown', '.json', '.ini', '.tcl', '.vbs', '.xsl']
+    '.pl', '.php4', '.php3', '.rhtml', '.svg', '.markdown', '.json', '.ini', '.tcl', '.vbs', '.xsl'])
 
 
 # Some schema types
@@ -77,7 +77,7 @@ SObjType = S.OneOf('blob', 'tree', 'submodule')
 
 # Used for when we're going to batch queries using $in
 QSIZE = 100
-BINARY_EXTENSIONS = [
+BINARY_EXTENSIONS = frozenset([
     ".3ds", ".3g2", ".3gp", ".7z", ".a", ".aac", ".adp", ".ai", ".aif", ".apk", ".ar", ".asf", ".au", ".avi",
     ".bak", ".bin", ".bk", ".bmp", ".btif", ".bz2", ".cab", ".caf", ".cgm", ".cmx", ".cpio", ".cr2", ".dat", ".deb", ".djvu", ".dll",
     ".dmg", ".dng", ".doc", ".docx", ".dra", ".DS_Store", ".dsk", ".dts", ".dtshd", ".dvb", ".dwg", ".dxf", ".ecelp4800",
@@ -90,9 +90,9 @@ BINARY_EXTENSIONS = [
     ".smv", ".so", ".sub", ".swf", ".tar", ".tbz2", ".tga", ".tgz", ".tif", ".tiff", ".tlz", ".ts", ".ttf", ".uvh", ".uvi", ".uvm",
     ".uvp", ".uvs", ".uvu", ".viv", ".vob", ".war", ".wav", ".wax", ".wbmp", ".wdp", ".weba", ".webm", ".webp", ".whl", ".wm", ".wma",
     ".wmv", ".wmx", ".woff", ".woff2", ".wvx", ".xbm", ".xif", ".xm", ".xpi", ".xpm", ".xwd", ".xz", ".z", ".zip", ".zipx"
-]
+])
 
-PYPELINE_EXTENSIONS = utils.MARKDOWN_EXTENSIONS + ['.rst']
+PYPELINE_EXTENSIONS = frozenset(utils.MARKDOWN_EXTENSIONS + ['.rst'])
 
 DIFF_SIMILARITY_THRESHOLD = .5  # used for determining file renames