allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [30/50] allura git commit: [#7925] show diffs of renames & copies (if they had changes)
Date Thu, 13 Aug 2015 18:06:57 GMT
[#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/ib/7922
Commit: b950a1fd6eeff1e3c7e0d7dc58b3387af70f70d3
Parents: 95f5648
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Jul 31 22:32:35 2015 +0000
Committer: Heith Seewald <hseewald@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': [],
             }],


Mime
View raw message